1 #include "harfbuzz-open-private.h"
2 #include "harfbuzz-gdef-private.h"
8 main (int argc, char **argv)
11 fprintf (stderr, "usage: %s font-file.ttf\n", argv[0]);
15 GMappedFile *mf = g_mapped_file_new (argv[1], FALSE, NULL);
16 const char *font_data = g_mapped_file_get_contents (mf);
17 int len = g_mapped_file_get_length (mf);
19 printf ("Opened font file %s: %d bytes long\n", argv[1], len);
21 const OpenTypeFontFile &ot = OpenTypeFontFile::get (font_data);
24 case OpenTypeFontFile::TrueTypeTag:
25 printf ("OpenType font with TrueType outlines\n");
27 case OpenTypeFontFile::CFFTag:
28 printf ("OpenType font with CFF (Type1) outlines\n");
30 case OpenTypeFontFile::TTCTag:
31 printf ("TrueType Collection of OpenType fonts\n");
34 printf ("Unknown font format\n");
38 int num_fonts = ot.get_len ();
39 printf ("%d font(s) found in file\n", num_fonts);
40 for (int n_font = 0; n_font < num_fonts; n_font++) {
41 const OpenTypeFontFace &font = ot[n_font];
42 printf ("Font %d of %d:\n", n_font+1, num_fonts);
44 int num_tables = font.get_len ();
45 printf (" %d table(s) found in font\n", num_tables);
46 for (int n_table = 0; n_table < num_tables; n_table++) {
47 const OpenTypeTable &table = font[n_table];
48 printf (" Table %2d of %2d: %.4s (0x%06x+0x%06x)\n", n_table+1, num_tables,
49 (const char *)table.tag, (int)table.offset, (int)table.length);
51 if (table.tag == "GSUB" || table.tag == "GPOS") {
52 const GSUBGPOSHeader &g = (const GSUBGPOSHeader&)*ot[table];
54 const ScriptList &scripts = *g.get_script_list();
55 int num_scripts = scripts.get_len ();
56 printf (" %d script(s) found in table\n", num_scripts);
57 for (int n_script = 0; n_script < num_scripts; n_script++) {
58 const Script &script = scripts[n_script];
59 printf (" Script %2d of %2d: %.4s\n", n_script+1, num_scripts,
60 (const char *)scripts.get_tag(n_script));
62 if (script.get_default_language_system () == NULL)
63 printf (" No default language system\n");
64 int num_langsys = script.get_len ();
65 printf (" %d language system(s) found in script\n", num_langsys);
66 for (int n_langsys = 0; n_langsys < num_langsys; n_langsys++) {
67 const LangSys &langsys = script[n_langsys];
68 printf (" Language System %2d of %2d: %.4s; %d features\n", n_langsys+1, num_langsys,
69 (const char *)script.get_tag(n_langsys),
71 if (!langsys.get_required_feature_index ())
72 printf (" No required feature\n");
76 const FeatureList &features = *g.get_feature_list();
77 int num_features = features.get_len ();
78 printf (" %d feature(s) found in table\n", num_features);
79 for (int n_feature = 0; n_feature < num_features; n_feature++) {
80 const Feature &feature = features[n_feature];
81 printf (" Feature %2d of %2d: %.4s; %d lookup(s)\n", n_feature+1, num_features,
82 (const char *)features.get_tag(n_feature),
83 (int)feature.lookupCount);
86 const LookupList &lookups = *g.get_lookup_list();
87 int num_lookups = lookups.get_len ();
88 printf (" %d lookup(s) found in table\n", num_lookups);
89 for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) {
90 const Lookup &lookup = lookups[n_lookup];
91 printf (" Lookup %2d of %2d: type %d, flags %04x\n", n_lookup+1, num_lookups,
92 (int)lookup.lookupType, (unsigned int)lookup.lookupFlag);