From 5541b84b43dd49e60f130d52b976615d4cb6b9fe Mon Sep 17 00:00:00 2001 From: handa Date: Mon, 9 Jun 2003 12:45:50 +0000 Subject: [PATCH] *** empty log message *** --- example/Makefile.am | 5 +++- example/otflist.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ example/otfview.c | 25 +++++++++++++---- src/otfdrive.c | 10 +++---- src/otfopen.c | 8 +++--- 5 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 example/otflist.c diff --git a/example/Makefile.am b/example/Makefile.am index 6f0cb7f..73a7aa3 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -1,9 +1,12 @@ -bin_PROGRAMS = otfdump otfdraw otfview +bin_PROGRAMS = otfdump otfdraw otfview otflist INCLUDES = `freetype-config --cflags` CommonLDADD = ${top_builddir}/src/libotf.la CommonLDFLAGS = -all-static +otflist_SOURCE = otflist.c +otflist_LDADD = ${CommonLDADD} +otflist_LDFLAGS = `freetype-config --libs` ${CommonLDFLAGS} otfdump_SOURCE = otfdump.c otfdump_LDADD = ${CommonLDADD} diff --git a/example/otflist.c b/example/otflist.c new file mode 100644 index 0000000..5851b96 --- /dev/null +++ b/example/otflist.c @@ -0,0 +1,76 @@ +#include +#include +#include + +#include +#include FT_FREETYPE_H + +int +filter (const struct dirent *direntry) +{ + int len = strlen (direntry->d_name); + const char *ext = direntry->d_name + (len - 4); + + return (len >= 5 + && (! strncmp (ext, ".ttf", 4) + || ! strncmp (ext, ".TTF", 4) + || ! strncmp (ext, ".otf", 4) + || ! strncmp (ext, ".OTF", 4))); +} + +int +main () +{ + struct dirent **namelist; + int n = scandir (".", &namelist, filter, alphasort); + int i, j; + FT_Library ft_library; + FT_Face face; + + if (FT_Init_FreeType (&ft_library)) + exit (1); + + for (i = 0; i < n; i++) + if (! FT_New_Face (ft_library, namelist[i]->d_name, 0, &face)) + { + printf ("%s: %s: %s\n", namelist[i]->d_name, + face->family_name, face->style_name); + if (face->num_charmaps == 0) + continue; + for (j = 0; j < face->num_charmaps; j++) + { + if (face->charmaps[j]->encoding == ft_encoding_symbol) + printf (" symbol,"); + else if (face->charmaps[j]->encoding == ft_encoding_unicode) + printf (" unicode,"); + else if (face->charmaps[j]->encoding == ft_encoding_latin_1) + printf (" latin_1,"); + else if (face->charmaps[j]->encoding == ft_encoding_latin_2) + printf (" latin_2,"); + else if (face->charmaps[j]->encoding == ft_encoding_sjis) + printf (" sjis,"); + else if (face->charmaps[j]->encoding == ft_encoding_gb2312) + printf (" gb2312,"); + else if (face->charmaps[j]->encoding == ft_encoding_big5) + printf (" big5,"); + else if (face->charmaps[j]->encoding == ft_encoding_wansung) + printf (" wansung,"); + else if (face->charmaps[j]->encoding == ft_encoding_johab) + printf (" johab,"); + else if (face->charmaps[j]->encoding == ft_encoding_adobe_standard) + printf (" adobe_standard,"); + else if (face->charmaps[j]->encoding == ft_encoding_adobe_expert) + printf (" adobe_expert,"); + else if (face->charmaps[j]->encoding == ft_encoding_adobe_custom) + printf (" adobe_custom,"); + else if (face->charmaps[j]->encoding == ft_encoding_apple_roman) + printf (" apple_roman,"); + else if (face->charmaps[j]->encoding == ft_encoding_none) + printf (" none,"); + else + printf (" 0x%X,", (unsigned) face->charmaps[j]->encoding); + } + printf ("\n"); + } + exit (0); +} diff --git a/example/otfview.c b/example/otfview.c index 5706e4c..aae4f94 100644 --- a/example/otfview.c +++ b/example/otfview.c @@ -108,6 +108,8 @@ main (int argc, char **argv) OTF_Glyph *g; int unicode_seq[256]; int n_codes = 0; + int pixel_size = PIXEL_SIZE; + /* Window structure. +-------------------------+ @@ -151,6 +153,14 @@ main (int argc, char **argv) exit (1); } + { + char *p = getenv ("PIXEL_SIZE"); + int n; + + if (p && sscanf (p, "%d", &n) == 1) + pixel_size = n; + } + err = FT_Init_FreeType (&library); if (err) quit ("FT_Init_FreeType"); @@ -159,7 +169,7 @@ main (int argc, char **argv) quit ("FT_New_Face: unknown file format"); else if (err) quit ("FT_New_Face: unknown error"); - err = FT_Set_Pixel_Sizes (face, 0, PIXEL_SIZE); + err = FT_Set_Pixel_Sizes (face, 0, pixel_size); if (err) quit ("FT_Set_Char_Size"); @@ -201,6 +211,8 @@ main (int argc, char **argv) for (i = 0; i < 0x10000; i++) { + if (i >= 0xD800 && i < 0xE000) + continue; gstring.glyphs[i & 0xFF].c = i; if ((i & 0xFF) == 0xFF) { @@ -208,7 +220,8 @@ main (int argc, char **argv) for (j = 0; j < 0x100; j++) { utog[(i & 0xFF00) + j] = gstring.glyphs[j].glyph_id; - if (gstring.glyphs[j].glyph_id > 0) + if (gstring.glyphs[j].glyph_id > 0 + && gstring.glyphs[j].glyph_id < 0x10000) bitmap[gstring.glyphs[j].glyph_id].unicode = (i & 0xFF00) + j; } } @@ -392,19 +405,19 @@ main (int argc, char **argv) { case 1: case 2: if (g->f.f1.format & OTF_XPlacement) - xoff = PIXEL_SIZE * ((double) (g->f.f1.value->XPlacement) + xoff = pixel_size * ((double) (g->f.f1.value->XPlacement) * 100 / otf->head->unitsPerEm); if (g->f.f1.format & OTF_YPlacement) - yoff = PIXEL_SIZE * ((double) (g->f.f1.value->YPlacement) + yoff = pixel_size * ((double) (g->f.f1.value->YPlacement) * 100 / otf->head->unitsPerEm); break; case 4: - xoff = (PIXEL_SIZE + xoff = (pixel_size * ((double) (g->f.f4.base_anchor->XCoordinate - g->f.f4.mark_anchor->XCoordinate) * 100 / otf->head->unitsPerEm)); - yoff = (PIXEL_SIZE + yoff = (pixel_size * ((double) (g->f.f4.base_anchor->YCoordinate - g->f.f4.mark_anchor->YCoordinate) * 100 / otf->head->unitsPerEm)); diff --git a/src/otfdrive.c b/src/otfdrive.c index e1cf19d..7393bce 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -396,7 +396,7 @@ lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, int j; int orig_used; - printf ("GSUB 6-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); + // printf ("GSUB 6-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); class = get_class_def (&context2->InputClassDef, g->glyph_id); set = context2->ChainClassSet + class; for (j = 0; j < set->ChainClassRuleCnt; j++) @@ -579,7 +579,7 @@ lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, OTF_GPOS_Pair2 *pair2 = &subtable->u.pair2; unsigned class1, class2; - printf ("GPOS 2-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); + // printf ("GPOS 2-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); gidx++; class1 = get_class_def (&pair2->ClassDef1, g->glyph_id); class2 = get_class_def (&pair2->ClassDef2, g[1].glyph_id); @@ -615,7 +615,7 @@ lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, if (coverage_idx_base < 0) continue; - printf ("GPOS 4-1: c:0x%x g:0x%x\n", g->c, g->glyph_id); + // printf ("GPOS 4-1: c:0x%x g:0x%x\n", g->c, g->glyph_id); mark_record = mark_base1->MarkArray.MarkRecord + coverage_idx; base_record = mark_base1->BaseArray.AnchorRecord + coverage_idx_base; @@ -647,7 +647,7 @@ lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, if (coverage_idx_base < 0) continue; - printf ("GPOS 6-1: c:0x%x g:0x%x\n", g->c, g->glyph_id); + // printf ("GPOS 6-1: c:0x%x g:0x%x\n", g->c, g->glyph_id); mark1_record = mark_mark1->Mark1Array.MarkRecord + coverage_idx; mark2_record = mark_mark1->Mark2Array.AnchorRecord + coverage_idx_base; @@ -676,7 +676,7 @@ lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, int j; int orig_used; - printf ("GPOS 8-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); + // printf ("GPOS 8-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); class = get_class_def (&context2->InputClassDef, g->glyph_id); set = context2->ChainClassSet + class; for (j = 0; j < set->ChainClassRuleCnt; j++) diff --git a/src/otfopen.c b/src/otfopen.c index d931462..dbf990f 100644 --- a/src/otfopen.c +++ b/src/otfopen.c @@ -46,12 +46,12 @@ Boston, MA 02111-1307, USA. */ (1-10) "GPOS" table (1-11) Structure for OTF - (2) APIs for reading OTF + (2) API for reading OTF (2-1) OTF_open() (2-2) OTF_close() (2-3) OTF_get_table() - (5) APIs miscellaneous + (5) API miscellaneous */ /* (0) Stream handler @@ -2238,7 +2238,7 @@ read_header_part (OTF *otf, FILE *fp) } -/*** (2) APIs for reading OTF */ +/*** (2) API for reading OTF */ /*** (2-1) OTF_open() */ @@ -2374,7 +2374,7 @@ OTF_get_table (OTF *otf, char *name) } -/*** (5) APIs miscellaneous ***/ +/*** (5) API miscellaneous ***/ OTF_Tag OTF_tag (char *name) -- 1.7.10.4