1 #include <Application.h> 2 #include <Font.h> 3 #include <stdio.h> 4 5 6 #define PRINT_FACE_FLAG(x) \ 7 if (face & x) { \ 8 printf(#x); \ 9 face &= ~x; \ 10 if (face != 0) \ 11 printf(", "); \ 12 } 13 14 15 int main() 16 { 17 BApplication app("application/x-vnd-Test.DumpFontList"); 18 19 int32 familyCount = count_font_families(); 20 for (int32 i = 0; i < familyCount; i++) { 21 font_family family; 22 uint32 familyFlags = 0; 23 24 if (get_font_family(i, &family, &familyFlags) == B_OK) { 25 printf("family \"%s\" (0x%08lx)\n", family, familyFlags); 26 27 int32 styleCount = count_font_styles(family); 28 for (int32 j = 0; j < styleCount; j++) { 29 font_style style; 30 uint32 styleFlags = 0; 31 32 if (get_font_style(family, j, &style, &styleFlags) == B_OK) { 33 printf("\tstyle \"%s\" (0x%08lx)\n", style, styleFlags); 34 35 BFont font; 36 font.SetFamilyAndStyle(family, style); 37 printf("\t\tcode: 0x%08lx\n", font.FamilyAndStyle()); 38 printf("\t\tsize: %f\n", font.Size()); 39 printf("\t\tshear: %f\n", font.Shear()); 40 printf("\t\trotation: %f\n", font.Rotation()); 41 printf("\t\tspacing: %u\n", font.Spacing()); 42 printf("\t\tencoding: %u\n", font.Encoding()); 43 44 uint16 face = font.Face(); 45 printf("\t\tface: 0x%04x (", face); 46 PRINT_FACE_FLAG(B_ITALIC_FACE); 47 PRINT_FACE_FLAG(B_UNDERSCORE_FACE); 48 PRINT_FACE_FLAG(B_NEGATIVE_FACE); 49 PRINT_FACE_FLAG(B_OUTLINED_FACE); 50 PRINT_FACE_FLAG(B_STRIKEOUT_FACE); 51 PRINT_FACE_FLAG(B_BOLD_FACE); 52 PRINT_FACE_FLAG(B_REGULAR_FACE); 53 if (face != 0) 54 printf("unknown 0x%04x", face); 55 printf(")\n"); 56 57 printf("\t\tflags: 0x%08lx\n", font.Flags()); 58 59 switch (font.Direction()) { 60 case B_FONT_LEFT_TO_RIGHT: 61 printf("\t\tdirection: left to right\n"); 62 break; 63 64 case B_FONT_RIGHT_TO_LEFT: 65 printf("\t\tdirection: right to left\n"); 66 break; 67 68 default: 69 printf("\t\tdirection: unknown (%d)\n", font.Direction()); 70 break; 71 } 72 73 printf("\t\tis fixed: %s\n", font.IsFixed() ? "yes" : "no"); 74 printf("\t\tfull/half fixed: %s\n", font.IsFullAndHalfFixed() ? "yes" : "no"); 75 76 switch (font.FileFormat()) { 77 case B_TRUETYPE_WINDOWS: 78 printf("\t\tfiletype: truetype\n"); 79 break; 80 81 case B_POSTSCRIPT_TYPE1_WINDOWS: 82 printf("\t\tfiletype: postscript type 1\n"); 83 break; 84 85 default: 86 printf("\t\tfiletype: unknown (%d)\n", font.FileFormat()); 87 break; 88 } 89 90 //printf("\t\ttuned count: %ld\n", font.CountTuned()); 91 printf("\n"); 92 } else 93 printf("\tgetting style %ld failed\n", j); 94 } 95 } else 96 printf("getting family %ld failed\n", i); 97 } 98 } 99