From a3873d27027fe24c335d85bb9a5e44f94a7ee4a7 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 23 Feb 2006 23:18:13 +0000 Subject: [PATCH] another try --- src/cache/ftccmap.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/src/cache/ftccmap.c b/src/cache/ftccmap.c index bdbbe7455..8b291af3c 100644 --- a/src/cache/ftccmap.c +++ b/src/cache/ftccmap.c @@ -302,14 +302,17 @@ * to FreeType 2.1.7. This is possible because the third parameter * is then a character code, and we've never seen any font with * more than a few charmaps, so if the index is very large... + * + * there is also little chance that a rogue client is interested + * by Unicode values 0 to 3 :-) */ if ( cmap_index >= 4 ) { FTC_OldCMapDesc desc = (FTC_OldCMapDesc) face_id; + char_code = (FT_UInt32)cmap_index; query.face_id = desc->face_id; - char_code = (FT_UInt32)cmap_index; switch ( desc->type ) { @@ -319,34 +322,17 @@ break; case FTC_OLD_CMAP_BY_ENCODING: - case FTC_OLD_CMAP_BY_ID: { FT_Face face; - FT_Int nn; error = FTC_Manager_LookupFace( cache->manager, desc->face_id, &face ); if ( error ) - return error; - - if ( desc->type == FTC_OLD_CMAP_BY_ENCODING ) - { - for ( nn = 0; nn < face->num_charmaps; nn++ ) - if ( face->charmaps[nn]->encoding == desc->u.encoding ) - break; - } - else - { - for ( nn = 0; nn < face->num_charmaps; nn++ ) - if ( face->charmaps[nn]->platform_id == desc->u.id.platform && - face->charmaps[nn]->encoding_id == desc->u.id.encoding ) - break; - } - - if ( nn >= face->num_charmaps ) return 0; - query.cmap_index = (FT_UInt)nn; + FT_Select_Charmap( face, desc->u.encoding ); + + return FT_Get_Char_Index( face, char_code ); } break; @@ -376,7 +362,7 @@ FT_ASSERT( (FT_UInt)( char_code - node->first ) < FTC_CMAP_INDICES_MAX ); /* something rotten can happen with rogue clients */ - if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) + if ( (FT_UInt)( char_code - node->first >= FTC_CMAP_INDICES_MAX ) ) return 0; gindex = node->indices[char_code - node->first];