diff --git a/ChangeLog b/ChangeLog index aa61bd481..964002be5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,13 @@ src/cache/ftccache.c: cleaning up the cache sub-system code, linear hashing is now the default + * include/freetype/config/ftoption.h, include/freetype/internal/tttypes.h, + src/base/ftobjs.c, src/bdf/bdfdrivr.c, src/cff/cffobjs.c, + src/pcf/pcfdrivr.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c, + src/sfnt/ttcmap0.h, src/sfnt/ttload.c, src/type1/t1objs.c, + src/type42/t42objs.c, src/winfonts/winfnt.c: code cleanup, + FT_CONFIG_OPTION_USE_CMAPS is now the default + 2002-07-11 David Turner * src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttdriver.c: changing diff --git a/include/freetype/internal/ftdriver.h b/include/freetype/internal/ftdriver.h index 875d0909d..1ad9607af 100644 --- a/include/freetype/internal/ftdriver.h +++ b/include/freetype/internal/ftdriver.h @@ -186,12 +186,10 @@ FT_BEGIN_HEADER FT_Size_ResetPixelsFunc set_pixel_sizes; FT_Slot_LoadFunc load_glyph; - FT_CharMap_CharIndexFunc get_char_index; FT_Face_GetKerningFunc get_kerning; FT_Face_AttachFunc attach_file; FT_Face_GetAdvancesFunc get_advances; - FT_CharMap_CharNextFunc get_next_char; } FT_Driver_ClassRec, *FT_Driver_Class; diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index ec3df9da8..94a89051d 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -1483,18 +1483,9 @@ FT_BEGIN_HEADER TT_OS2 os2; /* TrueType OS/2 table */ TT_Postscript postscript; /* TrueType Postscript table */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_Byte* cmap_table; /* extracted 'cmap' table */ FT_ULong cmap_size; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_Int num_charmaps; - TT_CharMap charmaps; /* array of TT_CharMapRec */ - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - TT_Loader_GotoTableFunc goto_table; TT_Loader_StartGlyphFunc access_glyph_frame; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index c37072db3..d5fb51846 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -631,8 +631,6 @@ if ( face->generic.finalizer ) face->generic.finalizer( face ); -#ifdef FT_CONFIG_OPTION_USE_CMAPS - /* discard charmaps */ { FT_Int n; @@ -652,8 +650,6 @@ face->num_charmaps = 0; } -#endif /* FT_CONFIG_OPTION_USE_CMAPS */ - /* finalize format-specific stuff */ if ( clazz->done_face ) @@ -1520,8 +1516,6 @@ /* documentation is in freetype.h */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ) @@ -1539,25 +1533,6 @@ return result; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_EXPORT_DEF( FT_UInt ) - FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ) - { - FT_UInt result = 0; - FT_Driver driver; - - - if ( face && face->charmap ) - { - driver = face->driver; - result = driver->clazz->get_char_index( face->charmap, charcode ); - } - return result; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ @@ -1586,8 +1561,6 @@ /* documentation is in freetype.h */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_EXPORT_DEF( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong charcode, @@ -1613,37 +1586,6 @@ return result; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_EXPORT_DEF( FT_ULong ) - FT_Get_Next_Char( FT_Face face, - FT_ULong charcode, - FT_UInt *agindex ) - { - FT_ULong result = 0; - FT_UInt gindex = 0; - FT_Driver driver; - - - if ( face && face->charmap ) - { - driver = face->driver; - result = driver->clazz->get_next_char( face->charmap, charcode ); - if ( result != 0 ) - { - gindex = driver->clazz->get_char_index( face->charmap, result ); - if ( gindex == 0 ) - result = 0; - } - } - - if ( agindex ) - *agindex = gindex; - - return result; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 2ca69b594..5af8e3ad6 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -662,13 +662,9 @@ THE SOFTWARE. (FT_Slot_LoadFunc) BDF_Glyph_Load, - (FT_CharMap_CharIndexFunc)0, - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) 0 + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index 07c467caf..91ce8823f 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -275,94 +275,6 @@ } - /*************************************************************************/ - /* */ - /* */ - /* cff_get_char_index */ - /* */ - /* */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Glyph index. 0 means `undefined character code'. */ - /* */ - static FT_UInt - cff_get_char_index( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - CFF_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (CFF_Face)charmap->root.face; - - /* Load table if needed */ - if ( !cmap->loaded ) - { - SFNT_Service sfnt = (SFNT_Service)face->sfnt; - - - error = sfnt->load_charmap( face, cmap, face->root.stream ); - if ( error ) - return 0; - - cmap->loaded = TRUE; - } - - return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 ); - } - - - /*************************************************************************/ - /* */ - /* */ - /* cff_get_next_char */ - /* */ - /* */ - /* Uses a charmap to return the next encoded charcode. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Char code. 0 means `no encoded chars above the given one'. */ - /* */ - static FT_Long - cff_get_next_char( TT_CharMap charmap, - FT_Long charcode ) - { - FT_Error error; - CFF_Face face; - TT_CMapTable cmap; - - - cmap = &charmap->cmap; - face = (CFF_Face)charmap->root.face; - - /* Load table if needed */ - if ( !cmap->loaded ) - { - SFNT_Service sfnt = (SFNT_Service)face->sfnt; - - - error = sfnt->load_charmap( face, cmap, face->root.stream ); - if ( error ) - return 0; - - cmap->loaded = TRUE; - } - - return ( cmap->get_next_char ? cmap->get_next_char( cmap, charcode ) - : 0 ); - } - /*************************************************************************/ /* */ @@ -469,7 +381,7 @@ ft_module_font_driver | ft_module_driver_scalable | ft_module_driver_has_hinter, - + sizeof( CFF_DriverRec ), "cff", 0x10000L, @@ -498,13 +410,10 @@ (FT_Size_ResetPixelsFunc) cff_size_reset, (FT_Slot_LoadFunc) Load_Glyph, - (FT_CharMap_CharIndexFunc)cff_get_char_index, (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) cff_get_next_char }; diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 32515a86b..bb04664aa 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -447,12 +447,12 @@ root->style_flags = flags; } - + /*******************************************************************/ /* */ /* Compute char maps. */ /* */ - + /* try to synthetize a Unicode charmap if there is none available */ /* already. If an OpenType font contains a Unicode "cmap", we */ /* will use it, wathever be in the CFF part of the file.. */ @@ -461,30 +461,28 @@ FT_CharMap cmap; FT_UInt nn; CFF_Encoding encoding = &cff->encoding; - + for ( nn = 0; nn < (FT_UInt) root->num_charmaps; nn++ ) { cmap = root->charmaps[nn]; - + /* Windows Unicode (3,1) ? */ if ( cmap->platform_id == 3 && cmap->encoding_id == 1 ) goto Skip_Unicode; - + /* Deprecated Unicode platform id ?? */ if ( cmap->platform_id == 0 ) goto Skip_Unicode; /* Standard Unicode (deprecated) */ } - - /* we didn't find a Unicode charmap, synthetize one */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS + /* we didn't find a Unicode charmap, synthetize one */ cmaprec.face = root; cmaprec.platform_id = 3; cmaprec.encoding_id = 1; cmaprec.encoding = ft_encoding_unicode; nn = (FT_UInt) root->num_charmaps; - + FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL ); /* if no Unicode charmap was previously selected, select this one */ @@ -495,7 +493,7 @@ if ( encoding->count > 0 ) { FT_CMap_Class clazz; - + cmaprec.face = root; cmaprec.platform_id = 7; /* Adobe platform id */ @@ -506,28 +504,22 @@ cmaprec.encoding = ft_encoding_adobe_standard; clazz = &cff_cmap_encoding_class_rec; break; - + case 1: cmaprec.encoding_id = 1; cmaprec.encoding = ft_encoding_adobe_expert; clazz = &cff_cmap_encoding_class_rec; break; - + default: cmaprec.encoding_id = 3; cmaprec.encoding = ft_encoding_adobe_custom; clazz = &cff_cmap_encoding_class_rec; } - + FT_CMap_New( clazz, NULL, &cmaprec, NULL ); - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* unimplemented !! */ - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ } - + } } diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 0d0a5fbfa..3a175b82f 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -40,11 +40,11 @@ cid_get_postscript_name( CID_Face face ) { const char* result = face->cid.cid_font_name; - + if ( result && result[0] == '/' ) result++; - + return result; } @@ -63,227 +63,6 @@ } -#if 0 /* unimplemented yet */ - - static FT_Error - cid_Get_Kerning( T1_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_Vector* kerning ) - { - CID_AFM* afm; - - - kerning->x = 0; - kerning->y = 0; - - afm = (CID_AFM*)face->afm_data; - if ( afm ) - CID_Get_Kerning( afm, left_glyph, right_glyph, kerning ); - - return CID_Err_Ok; - } - -#endif /* 0 */ - - - /*************************************************************************/ - /* */ - /* */ - /* Cid_Get_Char_Index */ - /* */ - /* */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Glyph index. 0 means `undefined character code'. */ - /* */ - static FT_UInt - CID_Get_Char_Index( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - FT_UInt result = 0; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph. */ - if ( result == 0xFFFF ) - result = 0; - goto Exit; - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - if ( charcode >= encoding->code_first && - charcode <= encoding->code_last ) - result = encoding->char_index[charcode]; - goto Exit; - } - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - if ( charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - break; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - { - result = n; - break; - } - } - } - } - - Exit: - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* Cid_Get_Next_Char */ - /* */ - /* */ - /* Uses a charmap to return the next encoded char after. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Next char code. 0 means `no more char codes'. */ - /* */ - static FT_Long - CID_Get_Next_Char( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - return psnames->next_unicode (&face->unicode_map, - (FT_ULong)charcode ); - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - charcode++; - if ( charcode < encoding->code_first ) - charcode = encoding->code_first; - while ( charcode <= encoding->code_last ) - { - if ( encoding->char_index[charcode] ) - return charcode; - charcode++; - } - } - break; - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - while ( ++charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - continue; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - { - return charcode; - } - } - } - } - - return 0; - } - FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec t1cid_driver_class = @@ -293,7 +72,7 @@ ft_module_font_driver | ft_module_driver_scalable | ft_module_driver_has_hinter , - + sizeof( FT_DriverRec ), "t1cid", /* module name */ 0x10000L, /* version 1.0 of driver */ @@ -323,14 +102,11 @@ (FT_Size_ResetPixelsFunc) CID_Size_Reset, (FT_Slot_LoadFunc) CID_Load_Glyph, - (FT_CharMap_CharIndexFunc)CID_Get_Char_Index, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) CID_Get_Next_Char }; diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c index 455ad0a03..cc6cb91af 100644 --- a/src/pcf/pcfdriver.c +++ b/src/pcf/pcfdriver.c @@ -460,13 +460,9 @@ THE SOFTWARE. (FT_Slot_LoadFunc) PCF_Glyph_Load, - (FT_CharMap_CharIndexFunc)0, - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) 0 + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c index 64041f306..a4fcc4204 100644 --- a/src/pfr/pfrdrivr.c +++ b/src/pfr/pfrdrivr.c @@ -57,13 +57,10 @@ (FT_Size_ResetPointsFunc) NULL, (FT_Size_ResetPixelsFunc) NULL, (FT_Slot_LoadFunc) pfr_slot_load, - (FT_CharMap_CharIndexFunc)NULL, (FT_Face_GetKerningFunc) pfr_face_get_kerning, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) NULL + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index fb672356b..3b55d633d 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -578,7 +578,6 @@ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS TT_Build_CMaps( face ); /* ignore errors */ @@ -605,41 +604,6 @@ } } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - { - TT_CharMap charmap = face->charmaps; - - - charmap = face->charmaps; - root->num_charmaps = face->num_charmaps; - - /* allocate table of pointers */ - if ( FT_NEW_ARRAY( root->charmaps, root->num_charmaps ) ) - goto Exit; - - for ( n = 0; n < root->num_charmaps; n++, charmap++ ) - { - FT_Int platform = charmap->cmap.platformID; - FT_Int encoding = charmap->cmap.platformEncodingID; - - - charmap->root.face = (FT_Face)face; - charmap->root.platform_id = (FT_UShort)platform; - charmap->root.encoding_id = (FT_UShort)encoding; - charmap->root.encoding = sfnt_find_encoding( platform, encoding ); - - /* now, set root->charmap with a unicode charmap */ - /* wherever available */ - if ( !root->charmap && - charmap->root.encoding == ft_encoding_unicode ) - root->charmap = (FT_CharMap)charmap; - - root->charmaps[n] = (FT_CharMap)charmap; - } - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS @@ -808,8 +772,6 @@ FT_FREE( face->dir_tables ); face->num_tables = 0; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_Stream stream = FT_FACE_STREAM( face ); @@ -819,27 +781,6 @@ face->cmap_size = 0; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* freeing the character mapping tables */ - if ( sfnt && sfnt->load_charmaps ) - { - FT_UShort n; - - - for ( n = 0; n < face->num_charmaps; n++ ) - sfnt->free_charmap( face, &face->charmaps[n].cmap ); - } - - FT_FREE( face->charmaps ); - face->num_charmaps = 0; - - FT_FREE( face->root.charmaps ); - face->root.num_charmaps = 0; - face->root.charmap = 0; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - /* freeing the horizontal metrics */ FT_FREE( face->horizontal.long_metrics ); FT_FREE( face->horizontal.short_metrics ); diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c index 0cd5d7314..2940ac3ac 100644 --- a/src/sfnt/ttcmap0.c +++ b/src/sfnt/ttcmap0.c @@ -1628,8 +1628,6 @@ #endif /* TT_CONFIG_CMAP_FORMAT_12 */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - static const TT_CMap_Class tt_cmap_classes[] = { #ifdef TT_CONFIG_CMAP_FORMAT_0 @@ -1744,7 +1742,5 @@ return 0; } -#endif /* FT_CONFIG_OPTION_USE_CMAPS */ - /* END */ diff --git a/src/sfnt/ttcmap0.h b/src/sfnt/ttcmap0.h index a37e909c6..efead241c 100644 --- a/src/sfnt/ttcmap0.h +++ b/src/sfnt/ttcmap0.h @@ -54,7 +54,7 @@ FT_BEGIN_HEADER { FT_ValidatorRec validator; FT_UInt num_glyphs; - + } TT_ValidatorRec, *TT_Validator; @@ -62,13 +62,9 @@ FT_BEGIN_HEADER #define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_LOCAL( FT_Error ) TT_Build_CMaps( TT_Face face ); -#endif - FT_END_HEADER diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 4b27f58d6..6fe6b3c37 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -1200,8 +1200,6 @@ /* FreeType error code. 0 means success. */ /* */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - FT_LOCAL_DEF( FT_Error ) TT_Load_CMap( TT_Face face, FT_Stream stream ) @@ -1229,105 +1227,6 @@ return error; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - FT_LOCAL_DEF( FT_Error ) - TT_Load_CMap( TT_Face face, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - FT_Long table_start; - TT_CMapDirRec cmap_dir; - - const FT_Frame_Field cmap_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TT_CMapDirRec - - FT_FRAME_START( 4 ), - FT_FRAME_USHORT( tableVersionNumber ), - FT_FRAME_USHORT( numCMaps ), - FT_FRAME_END - }; - - const FT_Frame_Field cmap_rec_fields[] = - { -#undef FT_STRUCTURE -#define FT_STRUCTURE TT_CMapTableRec - - FT_FRAME_START( 4 ), - FT_FRAME_USHORT( format ), - FT_FRAME_USHORT( length ), - FT_FRAME_END - }; - - - FT_TRACE2(( "CMaps " )); - - error = face->goto_table( face, TTAG_cmap, stream, 0 ); - if ( error ) - { - error = SFNT_Err_CMap_Table_Missing; - goto Exit; - } - - table_start = FT_STREAM_POS(); - - if ( FT_STREAM_READ_FIELDS( cmap_fields, &cmap_dir ) ) - goto Exit; - - /* reserve space in face table for cmap tables */ - if ( FT_NEW_ARRAY( face->charmaps, cmap_dir.numCMaps ) ) - goto Exit; - - face->num_charmaps = cmap_dir.numCMaps; - { - TT_CharMap charmap = face->charmaps; - TT_CharMap limit = charmap + face->num_charmaps; - - - /* read the header of each charmap first */ - if ( FT_FRAME_ENTER( face->num_charmaps * 8L ) ) - goto Exit; - - for ( ; charmap < limit; charmap++ ) - { - TT_CMapTable cmap; - - - charmap->root.face = (FT_Face)face; - cmap = &charmap->cmap; - - cmap->loaded = FALSE; - cmap->platformID = FT_GET_USHORT(); - cmap->platformEncodingID = FT_GET_USHORT(); - cmap->offset = (FT_ULong)FT_GET_LONG(); - } - - FT_FRAME_EXIT(); - - /* now read the rest of each table */ - for ( charmap = face->charmaps; charmap < limit; charmap++ ) - { - TT_CMapTable cmap = &charmap->cmap; - - - if ( FT_STREAM_SEEK( table_start + (FT_Long)cmap->offset ) || - FT_STREAM_READ_FIELDS( cmap_rec_fields, cmap ) ) - goto Exit; - - cmap->offset = FT_STREAM_POS(); - } - } - - FT_TRACE2(( "loaded\n" )); - - Exit: - return error; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /*************************************************************************/ diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index d0678a3c8..62ba5775d 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -516,13 +516,10 @@ (FT_Size_ResetPointsFunc) Set_Char_Sizes, (FT_Size_ResetPixelsFunc) Set_Pixel_Sizes, (FT_Slot_LoadFunc) Load_Glyph, - (FT_CharMap_CharIndexFunc)Get_Char_Index, (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) Get_Next_Char + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 968f767df..b255f9d7c 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -227,233 +227,6 @@ #endif /* T1_CONFIG_OPTION_NO_AFM */ - /*************************************************************************/ - /* */ - /* */ - /* Get_Char_Index */ - /* */ - /* */ - /* Uses a charmap to return a given character code's glyph index. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Glyph index. 0 means `undefined character code'. */ - /* */ - static FT_UInt - Get_Char_Index( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - FT_UInt result = 0; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - result = 0; - goto Exit; - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - /* ISOLatin1 is the first page of Unicode */ - if ( charcode < 256 && psnames->unicode_value ) - { - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - result = 0; - } - goto Exit; - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - if ( charcode >= encoding->code_first && - charcode <= encoding->code_last ) - result = encoding->char_index[charcode]; - goto Exit; - } - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - if ( charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - break; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - { - result = n; - break; - } - } - } - } - Exit: - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* Get_Next_Char */ - /* */ - /* */ - /* Uses a charmap to return the next encoded char. */ - /* */ - /* */ - /* charmap :: A handle to the source charmap object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* */ - /* Next char code. 0 means `no more char codes'. */ - /* */ - static FT_Long - Get_Next_Char( FT_CharMap charmap, - FT_Long charcode ) - { - T1_Face face; - PSNames_Service psnames; - - - face = (T1_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - return psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - { - FT_Long code; - - - /* use the `PSNames' module to synthetize the Unicode charmap */ - code = psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - if ( code < 256 ) - return code; - break; - } - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - charcode++; - if ( charcode < encoding->code_first ) - charcode = encoding->code_first; - while ( charcode <= encoding->code_last ) - { - if ( encoding->char_index[charcode] ) - return charcode; - charcode++; - } - } - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - while ( ++charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - continue; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - return charcode; - } - } - } - - return 0; - } FT_CALLBACK_TABLE_DEF @@ -491,7 +264,6 @@ (FT_Size_ResetPointsFunc) T1_Size_Reset, (FT_Size_ResetPixelsFunc) T1_Size_Reset, (FT_Slot_LoadFunc) T1_Load_Glyph, - (FT_CharMap_CharIndexFunc)Get_Char_Index, #ifdef T1_CONFIG_OPTION_NO_AFM (FT_Face_GetKerningFunc) 0, @@ -500,9 +272,7 @@ (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) T1_Read_AFM, #endif - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) Get_Next_Char + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 5a6008d29..64863dee1 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -427,8 +427,6 @@ root->internal->max_contours = 0; } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_Face root = &face->root; @@ -492,81 +490,6 @@ } } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* charmap support -- synthetize unicode charmap if possible */ - { - FT_Face root = &face->root; - FT_CharMap charmap = face->charmaprecs; - - - /* synthesize a Unicode charmap if there is support in the `PSNames' */ - /* module */ - if ( psnames ) - { - if ( psnames->unicode_value ) - { - error = psnames->build_unicodes( - root->memory, - face->type1.num_glyphs, - (const char**)face->type1.glyph_names, - &face->unicode_map ); - if ( !error ) - { - root->charmap = charmap; - charmap->face = (FT_Face)face; - charmap->encoding = ft_encoding_unicode; - charmap->platform_id = 3; - charmap->encoding_id = 1; - charmap++; - } - - /* simply clear the error in case of failure (which really) */ - /* means that out of memory or no unicode glyph names */ - error = T1_Err_Ok; - } - } - - /* now, support either the standard, expert, or custom encoding */ - charmap->face = (FT_Face)face; - charmap->platform_id = 7; /* a new platform id for Adobe fonts? */ - - switch ( face->type1.encoding_type ) - { - case T1_ENCODING_TYPE_STANDARD: - charmap->encoding = ft_encoding_adobe_standard; - charmap->encoding_id = 0; - break; - - case T1_ENCODING_TYPE_EXPERT: - charmap->encoding = ft_encoding_adobe_expert; - charmap->encoding_id = 1; - break; - - case T1_ENCODING_TYPE_ARRAY: - charmap->encoding = ft_encoding_adobe_custom; - charmap->encoding_id = 2; - break; - - case T1_ENCODING_TYPE_ISOLATIN1: - charmap->encoding = ft_encoding_latin_1; - charmap->encoding_id = 3; - break; - - default: - FT_ERROR(( "T1_Face_Init: invalid encoding\n" )); - error = T1_Err_Invalid_File_Format; - goto Exit; - } - - root->charmaps = face->charmaps; - root->num_charmaps = charmap - face->charmaprecs + 1; - face->charmaps[0] = &face->charmaprecs[0]; - face->charmaps[1] = &face->charmaprecs[1]; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - Exit: return error; } diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c index a05331851..65bf2e8aa 100644 --- a/src/type42/t42drivr.c +++ b/src/type42/t42drivr.c @@ -61,10 +61,10 @@ { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); - + if ( len >= buffer_max ) len = buffer_max - 1; - + FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } @@ -158,14 +158,11 @@ (FT_Size_ResetPointsFunc) T42_Size_SetChars, (FT_Size_ResetPixelsFunc) T42_Size_SetPixels, (FT_Slot_LoadFunc) T42_GlyphSlot_Load, - (FT_CharMap_CharIndexFunc)T42_CMap_CharIndex, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) T42_CMap_CharNext, + (FT_Face_GetAdvancesFunc) 0 }; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 16211b68e..3669d242f 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -436,118 +436,6 @@ } - FT_LOCAL_DEF( FT_UInt ) - T42_CMap_CharIndex( FT_CharMap charmap, - FT_Long charcode ) - { - T42_Face face; - FT_UInt result = 0; - PSNames_Service psnames; - - - face = (T42_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - if (!psnames ) - goto Exit; - - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* if this charmap is used, we ignore the encoding of the font and */ - /* use the `PSNames' module to synthetize the Unicode charmap */ - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - result = 0; - - /* The result returned is the index (position)in the CharStrings */ - /* array. This must be used now to get the value associated to */ - /* that glyph_name, which is the real index within the truetype */ - /* structure. */ - result = ft_atoi( (const char*)face->type1.charstrings[result] ); - goto Exit; - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - /* ISOLatin1 is the first page of Unicode */ - if ( charcode < 256 && psnames->unicode_value ) - { - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /* the function returns 0xFFFF if the Unicode charcode has */ - /* no corresponding glyph */ - if ( result == 0xFFFFU ) - result = 0; - } - goto Exit; - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - if ( charcode >= encoding->code_first && - charcode <= encoding->code_last ) - { - FT_UInt idx = encoding->char_index[charcode]; - - - result = ft_atoi( (const char *)face->type1.charstrings[idx] ); - } - goto Exit; - } - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - if ( charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - break; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - if ( gname && ( ft_strcmp( gname, glyph_name ) == 0 ) ) - { - result = ft_atoi( (const char *)face->type1.charstrings[n] ); - break; - } - } - } - } - - Exit: - return result; - } FT_LOCAL_DEF( FT_Error ) @@ -744,101 +632,4 @@ } - - FT_LOCAL_DEF( FT_Long ) - T42_CMap_CharNext( FT_CharMap charmap, - FT_Long charcode ) - { - T42_Face face; - PSNames_Service psnames; - - - face = (T42_Face)charmap->face; - psnames = (PSNames_Service)face->psnames; - - if ( psnames ) - switch ( charmap->encoding ) - { - /*******************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - /* use the `PSNames' module to synthetize the Unicode charmap */ - return psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - - /*******************************************************************/ - /* */ - /* ISOLatin1 encoding support */ - /* */ - case ft_encoding_latin_1: - { - FT_ULong code; - - - /* use the `PSNames' module to synthetize the Unicode charmap */ - code = psnames->next_unicode( &face->unicode_map, - (FT_ULong)charcode ); - if ( code < 256 ) - return code; - break; - } - - /*******************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: - { - T1_Encoding encoding = &face->type1.encoding; - - - charcode++; - if ( charcode < encoding->code_first ) - charcode = encoding->code_first; - while ( charcode <= encoding->code_last ) { - if ( encoding->char_index[charcode] ) - return charcode; - charcode++; - } - } - - - /*******************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - while ( ++charcode < 256 ) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - - code = psnames->adobe_std_encoding[charcode]; - if ( charmap->encoding == ft_encoding_adobe_expert ) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings( code ); - if ( !glyph_name ) - continue; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - - if ( gname && gname[0] == glyph_name[0] && - ft_strcmp( gname, glyph_name ) == 0 ) - return charcode; - } - } - } - - return 0; - } - - /* END */ diff --git a/src/type42/t42objs.h b/src/type42/t42objs.h index c6ce12766..fceb81193 100644 --- a/src/type42/t42objs.h +++ b/src/type42/t42objs.h @@ -109,15 +109,6 @@ FT_BEGIN_HEADER T42_GlyphSlot_Done( T42_GlyphSlot slot ); - FT_LOCAL( FT_UInt ) - T42_CMap_CharIndex( FT_CharMap charmap, - FT_Long charcode ); - - FT_LOCAL( FT_Long ) - T42_CMap_CharNext( FT_CharMap charmap, - FT_Long charcode ); - - FT_LOCAL( FT_Error ) T42_Driver_Init( T42_Driver driver ); diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index 54c0a97c1..48153a4a0 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -682,14 +682,9 @@ (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels, (FT_Slot_LoadFunc) FNT_Load_Glyph, - (FT_CharMap_CharIndexFunc)0, - - (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, - (FT_Face_GetAdvancesFunc) 0, - - (FT_CharMap_CharNextFunc) 0 + (FT_Face_GetAdvancesFunc) 0 };