Make find_unicode_charmap public and use it to choose the best charmap for building the reverse character map
This commit is contained in:
parent
37e3e348b5
commit
6650b9ebc7
|
@ -275,6 +275,26 @@ FT_BEGIN_HEADER
|
|||
FT_GlyphSlot slot,
|
||||
FT_Render_Mode mode );
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* find_unicode_charmap
|
||||
*
|
||||
* @Description:
|
||||
* This function finds a Unicode charmap, if there is one.
|
||||
* And if there is more than one, it tries to favour the more
|
||||
* extensive one, i.e., one that supports UCS-4 against those which
|
||||
* are limited to the BMP ( UCS-2 encoding.)
|
||||
*
|
||||
* If a unicode charmap is found, face->charmap is set to it.
|
||||
*
|
||||
* This function is called from open_face(),
|
||||
* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ),
|
||||
* and also from afadjust.c in the autofit module.
|
||||
*/
|
||||
FT_BASE( FT_Error )
|
||||
find_unicode_charmap( FT_Face face );
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
|
||||
|
||||
typedef void (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap* bitmap,
|
||||
|
|
|
@ -121,26 +121,16 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
|
|||
/* Search for a unicode charmap */
|
||||
/* If there isn't one, create a blank map */
|
||||
|
||||
/*TODO: change this to logic that searches for a "preferred" unicode charmap that maps the most codepoints*/
|
||||
/*see find_unicode_charmap*/
|
||||
/*TODO: use GSUB lookups */
|
||||
FT_TRACE4(( "af_reverse_character_map_new: building reverse character map\n" ));
|
||||
FT_CMap unicode_charmap = NULL;
|
||||
for ( FT_UInt i = 0; i < face->num_charmaps; i++ )
|
||||
{
|
||||
if ( face->charmaps[i]->encoding == FT_ENCODING_UNICODE )
|
||||
{
|
||||
unicode_charmap = FT_CMAP( face->charmaps[i] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( unicode_charmap == NULL )
|
||||
{
|
||||
*map = NULL;
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
FT_Error error;
|
||||
/* backup face->charmap because find_unicode_charmap sets it */
|
||||
FT_CharMap old_charmap = face->charmap;
|
||||
if (( error = find_unicode_charmap( face ) )) {
|
||||
*map = NULL;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
if ( FT_NEW( *map ) )
|
||||
{
|
||||
|
@ -160,7 +150,7 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
|
|||
for ( FT_Int i = 0; i < AF_ADJUSTMENT_DATABASE_LENGTH; i++ )
|
||||
{
|
||||
FT_UInt32 codepoint = adjustment_database[i].codepoint;
|
||||
FT_Int glyph = unicode_charmap->clazz->char_index(unicode_charmap, codepoint);
|
||||
FT_Int glyph = FT_Get_Char_Index( face, codepoint );
|
||||
if ( glyph == 0 )
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
|
@ -183,6 +173,7 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
|
|||
( *map )->length = size;
|
||||
|
||||
Exit:
|
||||
face->charmap = old_charmap;
|
||||
if ( error )
|
||||
{
|
||||
FT_TRACE4(( " error while building reverse character map. Using blank map.\n" ));
|
||||
|
|
|
@ -1358,21 +1358,7 @@
|
|||
driver );
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @Function:
|
||||
* find_unicode_charmap
|
||||
*
|
||||
* @Description:
|
||||
* This function finds a Unicode charmap, if there is one.
|
||||
* And if there is more than one, it tries to favour the more
|
||||
* extensive one, i.e., one that supports UCS-4 against those which
|
||||
* are limited to the BMP (said UCS-2 encoding.)
|
||||
*
|
||||
* This function is called from open_face() (just below), and also
|
||||
* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ).
|
||||
*/
|
||||
static FT_Error
|
||||
FT_Error
|
||||
find_unicode_charmap( FT_Face face )
|
||||
{
|
||||
FT_CharMap* first;
|
||||
|
|
Loading…
Reference in New Issue