From: handa Date: Thu, 6 May 2004 07:00:28 +0000 (+0000) Subject: Include . X-Git-Tag: REL-0-9-1~62 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b46ba59c76ac57eff720aa527e0bd50b8e0445ca;p=m17n%2Flibotf.git Include . (FATAL_ERROR): New macro. (print_tag, print_gsub_gpos_info, help_and_exit): New functions. (main): Handle -h, --help, -l args. Prefer family/style names extracted by the otf library. --- diff --git a/example/otflist.c b/example/otflist.c index e21dec5..78c0678 100644 --- a/example/otflist.c +++ b/example/otflist.c @@ -39,6 +39,63 @@ write to the Free Software Foundation, Inc., 59 Temple Place, Suite exit (1); \ } while (0) + +void +print_tag (OTF_Tag tag) +{ + char name[5]; + + OTF_tag_name (tag, name); + printf ("%s", name); +} + +void +print_gsub_gpos_info (OTF *otf, char *table) +{ + int i, j; + + if (OTF_get_table (otf, table) == 0) + { + OTF_ScriptList *scripts; + OTF_FeatureList *features; + + if (! strcmp (table, "GSUB")) + scripts = &otf->gsub->ScriptList, features = &otf->gsub->FeatureList; + else + scripts = &otf->gpos->ScriptList, features = &otf->gpos->FeatureList; + + printf (" %s scripts: ", table); + for (i = 0; i < scripts->ScriptCount; i++) + { + OTF_Script *script = scripts->Script + i; + + if (i > 0) + printf (", "); + print_tag (script->ScriptTag); + if (script->LangSysCount > 0) + { + printf (" ("); + for (j = 0; j < script->LangSysCount; j++) + { + if (j > 0) + printf (", "); + print_tag (script->LangSysRecord[j].LangSysTag); + } + printf (" )"); + } + } + printf ("\n"); + + printf (" %s features: ", table); + for (i = 0; i < features->FeatureCount; i++) + { + if (i > 0) + printf (","); + print_tag (features->Feature[i].FeatureTag); + } + printf ("\n"); + } +} void help_and_exit (char *prog) { @@ -79,7 +136,7 @@ main (int argc, char **argv) int i, j; if (FT_Init_FreeType (&ft_library)) - exit (1); + FATAL_ERROR ("%s\n", "!! Freetype initialization failed."); if (argc > 1) { @@ -99,7 +156,7 @@ main (int argc, char **argv) if (! FT_New_Face (ft_library, namelist[i]->d_name, 0, &face)) { OTF *otf = OTF_open (namelist[i]->d_name); - char *name, *family, *style; + char *name, *family = NULL, *style = NULL; if (otf) { @@ -124,6 +181,13 @@ main (int argc, char **argv) printf (" %d-%d", face->charmaps[j]->platform_id, face->charmaps[j]->encoding_id); printf ("\n"); + if (otf && long_format) + { + print_gsub_gpos_info (otf, "GSUB"); + print_gsub_gpos_info (otf, "GPOS"); + } + if (otf) + OTF_close (otf); } else {