2 * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Copyright 2004, François Revol. All rights reserved.
4 * Distributed under the terms of the MIT License.
11 #include <Application.h>
16 static struct option
const kLongOptions
[] = {
17 {"styles", no_argument
, 0, 's'},
18 {"long", no_argument
, 0, 'l'},
19 {"tuned", no_argument
, 0, 't'},
20 {"help", no_argument
, 0, 'h'},
24 extern const char *__progname
;
25 static const char *sProgramName
= __progname
;
31 printf("%s [-s] [-l]\n", sProgramName
);
32 printf("lists currently installed font families.\n");
33 printf("\t-s --styles list styles for each family\n");
34 printf("\t-l --long long listing with more info (spacing, encoding,\n"
35 "\t\t\theight (ascent/descent/leading), ...)\n");
36 printf("\t-t --tuned display tuned fonts\n");
38 printf("\t-u update font families\n");
44 main(int argc
, char **argv
)
46 // parse command line parameters
48 bool displayStyles
= false;
49 bool displayLong
= false;
50 bool displayTuned
= false;
52 bool updateFamilies
= false;
56 while ((c
= getopt_long(argc
, argv
, "sltuh", kLongOptions
, NULL
)) != -1) {
76 updateFamilies
= true;
82 BApplication
app("application/x-vnd.Haiku-listfont");
86 bool changed
= update_font_families(true);
87 printf("font families %s.\n", changed
? "changed" : "did not change");
92 int32 familyCount
= count_font_families();
95 printf("name/style face spc. enc. "
96 "height (a, d, l) flags\n\n");
99 for (int32 f
= 0; f
< familyCount
; f
++) {
101 if (get_font_family(f
, &family
) < B_OK
)
103 if (!displayStyles
) {
104 printf("%s\n", family
);
108 int32 styleCount
= count_font_styles(family
);
110 for (int32 s
= 0; s
< styleCount
; s
++) {
114 if (get_font_style(family
, s
, &style
, &face
, &flags
) < B_OK
)
118 printf("%s/%s\n", family
, style
);
123 fontName
<< family
<< "/" << style
;
124 printf("%-37s", fontName
.String());
127 font
.SetFamilyAndStyle(family
, style
);
128 printf(" 0x%02x %-4d %-4d", face
, font
.Spacing(), font
.Encoding());
132 printf(" %5.2f, %4.2f, %4.2f ", fh
.ascent
, fh
.descent
, fh
.leading
);
133 if ((flags
& B_IS_FIXED
) != 0)
136 if ((flags
& B_HAS_TUNED_FONT
) != 0) {
139 else if ((flags
& B_IS_FIXED
) != 0)
142 int32 tunedCount
= font
.CountTuned();
143 printf("%ld tuned", tunedCount
);
147 for (int32 i
= 0; i
< tunedCount
; i
++) {
148 tuned_font_info info
;
149 font
.GetTunedInfo(i
, &info
);
150 printf("\n\t(size %4.1f, shear %5.3f, rot. %5.3f, flags 0x%lx, face 0x%x)",
152 info
.shear
, info
.rotation
, info
.flags
, info
.face
);