From bd65ed97aaa613cc7e8d9ad37c6000d12b773443 Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 17 Jul 2002 21:14:23 +0000 Subject: [PATCH] * 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 --- src/bdf/bdfdrivr.c | 79 ------------------------------- src/pcf/pcfdriver.c | 107 ------------------------------------------ src/type42/t42objs.c | 83 ++------------------------------ src/winfonts/winfnt.c | 82 +------------------------------- 4 files changed, 5 insertions(+), 346 deletions(-) diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index e0e894b18..2ca69b594 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -46,9 +46,6 @@ THE SOFTWARE. #define FT_COMPONENT trace_bdfdriver -#ifdef FT_CONFIG_OPTION_USE_CMAPS - - typedef struct BDF_CMapRec_ { FT_CMapRec cmap; @@ -171,39 +168,6 @@ THE SOFTWARE. }; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - - static FT_UInt - BDF_Get_Char_Index( FT_CharMap charmap, - FT_ULong char_code ) - { - BDF_Face face = (BDF_Face)charmap->face; - BDF_encoding_el* en_table = face->en_table; - int low, high, mid; - - - FT_TRACE4(( "BDF_Get_Char_Index %ld\n", char_code )); - - low = 0; - high = face->bdffont->glyphs_used - 1; - - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return en_table[mid].glyph + 1; - } - - return face->bdffont->default_glyph + 1; - } - - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ FT_CALLBACK_DEF( FT_Error ) @@ -429,8 +393,6 @@ THE SOFTWARE. !ft_strcmp( face->charset_encoding, "1" ) ) ) unicode_charmap = 1; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; @@ -454,32 +416,12 @@ THE SOFTWARE. root->charmap = root->charmaps[0]; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - face->charmap.encoding = ft_encoding_none; - face->charmap.platform_id = 0; - face->charmap.encoding_id = 0; - if ( unicode_charmap ) - { - face->charmap.encoding = ft_encoding_unicode; - face->charmap.platform_id = 3; - face->charmap.encoding_id = 1; - } - face->charmap.face = root; - face->charmap_handle = &face->charmap; - - root->charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - goto Exit; } } /* otherwise assume Adobe standard encoding */ -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; @@ -495,19 +437,6 @@ THE SOFTWARE. if (root->num_charmaps) root->charmap = root->charmaps[0]; } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - face->charmap.encoding = ft_encoding_adobe_standard; - face->charmap.platform_id = 7; /* taken from t1objs.c */ - face->charmap.encoding_id = 0; - face->charmap.face = root; - face->charmap_handle = &face->charmap; - - root->charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - } } @@ -733,21 +662,13 @@ THE SOFTWARE. (FT_Slot_LoadFunc) BDF_Glyph_Load, -#ifdef FT_CONFIG_OPTION_USE_CMAPS (FT_CharMap_CharIndexFunc)0, -#else - (FT_CharMap_CharIndexFunc)BDF_Get_Char_Index, -#endif (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0, -#ifdef FT_CONFIG_OPTION_USE_CMAPS (FT_CharMap_CharNextFunc) 0 -#else - (FT_CharMap_CharNextFunc) 0 /* BDF_Get_Next_Char */ -#endif }; diff --git a/src/pcf/pcfdriver.c b/src/pcf/pcfdriver.c index c86bbfb8c..455ad0a03 100644 --- a/src/pcf/pcfdriver.c +++ b/src/pcf/pcfdriver.c @@ -41,8 +41,6 @@ THE SOFTWARE. #define FT_COMPONENT trace_pcfread -#ifdef FT_CONFIG_OPTION_USE_CMAPS - typedef struct PCF_CMapRec_ { FT_CMapRec cmap; @@ -164,77 +162,6 @@ THE SOFTWARE. (FT_CMap_CharNextFunc) pcf_cmap_char_next }; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - static FT_UInt - PCF_Char_Get_Index( FT_CharMap charmap, - FT_Long char_code ) - { - PCF_Face face = (PCF_Face)charmap->face; - PCF_Encoding en_table = face->encodings; - int low, high, mid; - - - FT_TRACE4(( "get_char_index %ld\n", char_code )); - - low = 0; - high = face->nencodings - 1; - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return en_table[mid].glyph + 1; - } - - return 0; - } - - - static FT_Long - PCF_Char_Get_Next( FT_CharMap charmap, - FT_Long char_code ) - { - PCF_Face face = (PCF_Face)charmap->face; - PCF_Encoding en_table = face->encodings; - int low, high, mid; - - - FT_TRACE4(( "get_next_char %ld\n", char_code )); - - char_code++; - low = 0; - high = face->nencodings - 1; - - while ( low <= high ) - { - mid = ( low + high ) / 2; - if ( char_code < en_table[mid].enc ) - high = mid - 1; - else if ( char_code > en_table[mid].enc ) - low = mid + 1; - else - return char_code; - } - - if ( high < 0 ) - high = 0; - - while ( high < face->nencodings ) - { - if ( en_table[high].enc >= char_code ) - return en_table[high].enc; - high++; - } - - return 0; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - /*************************************************************************/ /* */ @@ -321,8 +248,6 @@ THE SOFTWARE. unicode_charmap = 1; } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; @@ -345,30 +270,6 @@ THE SOFTWARE. if (face->root.num_charmaps) face->root.charmap = face->root.charmaps[0]; } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* XXX: charmaps. For now, report unicode for Unicode and Latin 1 */ - face->root.charmaps = &face->charmap_handle; - face->root.num_charmaps = 1; - - face->charmap.encoding = ft_encoding_none; - face->charmap.platform_id = 0; - face->charmap.encoding_id = 0; - - if ( unicode_charmap ) - { - face->charmap.encoding = ft_encoding_unicode; - face->charmap.platform_id = 3; - face->charmap.encoding_id = 1; - } - - face->charmap.face = &face->root; - face->charmap_handle = &face->charmap; - face->root.charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - } Exit: @@ -559,21 +460,13 @@ THE SOFTWARE. (FT_Slot_LoadFunc) PCF_Glyph_Load, -#ifndef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharIndexFunc)PCF_Char_Get_Index, -#else (FT_CharMap_CharIndexFunc)0, -#endif (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0, -#ifndef FT_CONFIG_OPTION_USE_CMAPS - (FT_CharMap_CharNextFunc) PCF_Char_Get_Next, -#else (FT_CharMap_CharNextFunc) 0 -#endif }; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 7e90cfc50..16211b68e 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -283,8 +283,6 @@ if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL ) root->face_flags |= FT_FACE_FLAG_VERTICAL; -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { if ( psnames && psaux ) { @@ -344,79 +342,6 @@ root->charmap = root->charmaps[0]; } } - -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* charmap support -- synthetize unicode charmap if possible */ - { - FT_CharMap charmap = face->charmaprecs; - - - /* synthesize a Unicode charmap if there is support in the `PSNames' */ - /* module */ - if ( psnames && 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++; - } - - /* XXX: Is the following code correct? It is used in t1objs.c */ - - /* simply clear the error in case of failure (which really) */ - /* means that out of memory or no unicode glyph names */ - error = T42_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(( "T42_Face_Init: invalid encoding\n" )); - error = T42_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; } @@ -718,7 +643,7 @@ FT_Activate_Size(size->ttsize); - + return FT_Set_Char_Size( t42face->ttf_face, char_width, char_height, @@ -737,7 +662,7 @@ FT_Activate_Size(size->ttsize); - + return FT_Set_Pixel_Sizes( t42face->ttf_face, pixel_width, pixel_height ); @@ -807,10 +732,10 @@ glyph->bitmap = t42slot->ttslot->bitmap; glyph->bitmap_left = t42slot->ttslot->bitmap_left; glyph->bitmap_top = t42slot->ttslot->bitmap_top; - + glyph->num_subglyphs = t42slot->ttslot->num_subglyphs; glyph->subglyphs = t42slot->ttslot->subglyphs; - + glyph->control_data = t42slot->ttslot->control_data; glyph->control_len = t42slot->ttslot->control_len; } diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index 5344c684f..54c0a97c1 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -310,8 +310,6 @@ } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - typedef struct FNT_CMapRec_ { @@ -393,57 +391,6 @@ static FT_CMap_Class fnt_cmap_class = &fnt_cmap_class_rec; -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - - static FT_UInt - FNT_Get_Char_Index( FT_CharMap charmap, - FT_Long char_code ) - { - FT_Long result = char_code; - - - if ( charmap ) - { - FNT_Font font = ((FNT_Face)charmap->face)->fonts; - FT_Long first = font->header.first_char; - FT_Long count = font->header.last_char - first + 1; - - - char_code -= first; - if ( char_code < count ) - result = char_code + 1; - else - result = 0; - } - - return result; - } - - - static FT_Long - FNT_Get_Next_Char( FT_CharMap charmap, - FT_Long char_code ) - { - char_code++; - if ( charmap ) - { - FNT_Font font = ((FNT_Face)charmap->face)->fonts; - FT_Long first = font->header.first_char; - - - if ( char_code < first ) - char_code = first; - if ( char_code <= font->header.last_char ) - return char_code; - } - else - return char_code; - return 0; - } - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - static void FNT_Face_Done( FNT_Face face ) @@ -534,8 +481,6 @@ } } -#ifdef FT_CONFIG_OPTION_USE_CMAPS - { FT_CharMapRec charmap; @@ -556,23 +501,6 @@ root->charmap = root->charmaps[0]; } -#else /* !FT_CONFIG_OPTION_USE_CMAPS */ - - /* Setup the `charmaps' array */ - root->charmaps = &face->charmap_handle; - root->num_charmaps = 1; - - face->charmap.encoding = ft_encoding_unicode; - face->charmap.platform_id = 3; - face->charmap.encoding_id = 1; - face->charmap.face = root; - - face->charmap_handle = &face->charmap; - - root->charmap = face->charmap_handle; - -#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ - /* setup remaining flags */ root->num_glyphs = fonts->header.last_char - fonts->header.first_char + 1; @@ -754,22 +682,14 @@ (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels, (FT_Slot_LoadFunc) FNT_Load_Glyph, -#ifdef FT_CONFIG_OPTION_USE_CMAPS (FT_CharMap_CharIndexFunc)0, -#else - (FT_CharMap_CharIndexFunc)FNT_Get_Char_Index, -#endif - + (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0, -#ifdef FT_CONFIG_OPTION_USE_CMAPS (FT_CharMap_CharNextFunc) 0 -#else - (FT_CharMap_CharNextFunc) FNT_Get_Next_Char -#endif };