From: handa Date: Mon, 16 Jun 2003 00:17:14 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: REL-0-9-1~107 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9edd835499a02d6f88fb3766a52db89188926e9;p=m17n%2Flibotf.git *** empty log message *** --- diff --git a/example/otflist.c b/example/otflist.c index 5851b96..e38378e 100644 --- a/example/otflist.c +++ b/example/otflist.c @@ -15,7 +15,11 @@ filter (const struct dirent *direntry) && (! strncmp (ext, ".ttf", 4) || ! strncmp (ext, ".TTF", 4) || ! strncmp (ext, ".otf", 4) - || ! strncmp (ext, ".OTF", 4))); + || ! strncmp (ext, ".OTF", 4) + || ! strncmp (ext, ".PFA", 4) + || ! strncmp (ext, ".pfa", 4) + || ! strncmp (ext, ".PFB", 4) + || ! strncmp (ext, ".pfb", 4))); } int @@ -40,35 +44,37 @@ main () for (j = 0; j < face->num_charmaps; j++) { if (face->charmaps[j]->encoding == ft_encoding_symbol) - printf (" symbol,"); + printf (" symbol"); else if (face->charmaps[j]->encoding == ft_encoding_unicode) - printf (" unicode,"); + printf (" unicode"); else if (face->charmaps[j]->encoding == ft_encoding_latin_1) - printf (" latin_1,"); + printf (" latin_1"); else if (face->charmaps[j]->encoding == ft_encoding_latin_2) - printf (" latin_2,"); + printf (" latin_2"); else if (face->charmaps[j]->encoding == ft_encoding_sjis) - printf (" sjis,"); + printf (" sjis"); else if (face->charmaps[j]->encoding == ft_encoding_gb2312) - printf (" gb2312,"); + printf (" gb2312"); else if (face->charmaps[j]->encoding == ft_encoding_big5) - printf (" big5,"); + printf (" big5"); else if (face->charmaps[j]->encoding == ft_encoding_wansung) - printf (" wansung,"); + printf (" wansung"); else if (face->charmaps[j]->encoding == ft_encoding_johab) - printf (" johab,"); + printf (" johab"); else if (face->charmaps[j]->encoding == ft_encoding_adobe_standard) - printf (" adobe_standard,"); + printf (" adobe_standard"); else if (face->charmaps[j]->encoding == ft_encoding_adobe_expert) - printf (" adobe_expert,"); + printf (" adobe_expert"); else if (face->charmaps[j]->encoding == ft_encoding_adobe_custom) - printf (" adobe_custom,"); + printf (" adobe_custom"); else if (face->charmaps[j]->encoding == ft_encoding_apple_roman) - printf (" apple_roman,"); + printf (" apple_roman"); else if (face->charmaps[j]->encoding == ft_encoding_none) - printf (" none,"); + printf (" none"); else - printf (" 0x%X,", (unsigned) face->charmaps[j]->encoding); + printf (" 0x%X", (unsigned) face->charmaps[j]->encoding); + printf ("(%d-%d),", face->charmaps[j]->platform_id, + face->charmaps[j]->encoding_id); } printf ("\n"); } diff --git a/src/otf.h b/src/otf.h index 31ff7b5..bd0704d 100644 --- a/src/otf.h +++ b/src/otf.h @@ -40,12 +40,13 @@ 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() + (2-4) OTF_check_table() - (3) APIs for driving OTF + (3) API for driving OTF (3-1) Structure for glyph string (3-2) OTF_drive_cmap() (3-3) OTF_drive_gdef() @@ -53,11 +54,11 @@ Boston, MA 02111-1307, USA. */ (3-5) OTF_drive_gpos() (3-6) OTF_drive_tables() - (4) APIs for error handling + (4) API for error handling (4-1) Error codes (4-2) OTF_perror() - (5) APIs miscellaneous + (5) API miscellaneous */ @@ -965,7 +966,7 @@ typedef struct } OTF; -/*** (2) APIs for reading OTF */ +/*** (2) API for reading OTF */ /*** (2-1) otf_open () */ @@ -996,8 +997,8 @@ extern OTF *OTF_open (char *name); /*** Close OpenType font - The OTF_close() function closes the OpenType font pointed by $OTF - which must be what the OTF_open() returned. + The OTF_close() function closes the OpenType font $OTF which must + be what the OTF_open() function returned. See also OTF_open(). */ @@ -1009,8 +1010,8 @@ extern void OTF_close (OTF *otf); /*** Get OpenType font table - The OTF_get_table() function setups one of the OTF tables - specified by $NAME in the structure pointed by $OTF. + The OTF_get_table() function setups one of the OTF table specified + by $NAME in the OpenType font $OTF. $NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and "GPOS", and a member of the same name is setup. @@ -1022,8 +1023,22 @@ extern void OTF_close (OTF *otf); extern int OTF_get_table (OTF *otf, char *name); +/*** (2-4) OTF_check_table () */ -/*** (3) APIs for driving OTF */ +/*** + Check the existence of OpenType font table + + The OTF_check_table() function checks if the the OTF table + specified by $NAME exists in OpenType font $OTF. + + If the table exists, return 0, else return -1. + + See also OTF_open(). */ + +extern int OTF_check_table (OTF *otf, char *name); + + +/*** (3) API for driving OTF */ /*** (3-1) Structure for glyph string */ @@ -1166,7 +1181,7 @@ extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring, char *gsub_features, char *gpos_features); -/*** (4) APIs for error handling ***/ +/*** (4) API for error handling ***/ /*** (4-1) Error codes ***/ @@ -1236,7 +1251,7 @@ extern int OTF_error; extern void OTF_perror (char *prefix); -/*** (5) APIs miscellaneous ***/ +/*** (5) API miscellaneous ***/ /*** Return OTF tag of a specified name string. diff --git a/src/otfdrive.c b/src/otfdrive.c index 7393bce..f7b86b5 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -788,7 +788,7 @@ lookup_cmap (OTF_cmap *cmap, int c) -/* APIs */ +/* API */ int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring) diff --git a/src/otfopen.c b/src/otfopen.c index dbf990f..7bfbea0 100644 --- a/src/otfopen.c +++ b/src/otfopen.c @@ -50,6 +50,7 @@ Boston, MA 02111-1307, USA. */ (2-1) OTF_open() (2-2) OTF_close() (2-3) OTF_get_table() + (2-4) OTF_check_table() (5) API miscellaneous */ @@ -2237,6 +2238,44 @@ read_header_part (OTF *otf, FILE *fp) return 0; } +static OTF_TableInfo * +get_table_info (OTF *otf, char *name) +{ + char *errfmt = "OTF Table Read%s"; + OTF_TableInfo *errret = NULL; + OTF_InternalData *internal_data = otf->internal_data; + OTF_TableInfo *table_info; + OTF_Tag tag = OTF_tag (name); + + if (! tag) + OTF_ERROR (OTF_ERROR_TABLE, " (invalid table name)"); + + if (tag == OTF_tag ("head")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_HEAD; + else if (tag == OTF_tag ("name")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_NAME; + else if (tag == OTF_tag ("cmap")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_CMAP; + else if (tag == OTF_tag ("GDEF")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_GDEF; + else if (tag == OTF_tag ("GSUB")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_GSUB; + else if (tag == OTF_tag ("GPOS")) + table_info = internal_data->table_info + OTF_TABLE_TYPE_GPOS; + else + OTF_ERROR (OTF_ERROR_TABLE, " (not yet supported table name)"); + + if (*table_info->address) + /* Already read. */ + return table_info; + if (! table_info->stream) + OTF_ERROR (OTF_ERROR_TABLE, " (table not found)"); + if (! table_info->reader) + OTF_ERROR (OTF_ERROR_TABLE, " (invalid contents)"); + return table_info; +} + + /*** (2) API for reading OTF */ @@ -2329,37 +2368,10 @@ OTF_close (OTF *otf) int OTF_get_table (OTF *otf, char *name) { - char *errfmt = "OTF Table Read%s"; - int errret = -1; - OTF_InternalData *internal_data = otf->internal_data; - OTF_TableInfo *table_info; - OTF_Tag tag = OTF_tag (name); - - if (! tag) - OTF_ERROR (OTF_ERROR_TABLE, " (invalid table name)"); - - if (tag == OTF_tag ("head")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_HEAD; - else if (tag == OTF_tag ("name")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_NAME; - else if (tag == OTF_tag ("cmap")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_CMAP; - else if (tag == OTF_tag ("GDEF")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_GDEF; - else if (tag == OTF_tag ("GSUB")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_GSUB; - else if (tag == OTF_tag ("GPOS")) - table_info = internal_data->table_info + OTF_TABLE_TYPE_GPOS; - else - OTF_ERROR (OTF_ERROR_TABLE, " (not yet supported table name)"); + OTF_TableInfo *table_info = get_table_info (otf, name); - if (*table_info->address) - /* Already read. */ - return 0; - if (! table_info->stream) - OTF_ERROR (OTF_ERROR_TABLE, " (table not found)"); - if (! table_info->reader) - OTF_ERROR (OTF_ERROR_TABLE, " (invalid contents)"); + if (! table_info) + return -1; *table_info->address = (*table_info->reader) (otf, table_info->stream); free_stream (table_info->stream); @@ -2367,12 +2379,21 @@ OTF_get_table (OTF *otf, char *name) if (! *table_info->address) { table_info->reader = NULL; - return errret; + return -1; } - return 0; } +/*** (2-4) OTF_check_table() */ + +int +OTF_check_table (OTF *otf, char *name) +{ + return (get_table_info (otf, name) ? 0 : -1); +} + + + /*** (5) API miscellaneous ***/