freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][gsoc-craig-2023] Make find_unicode_charmap publ


From: Craig White (@gerzytet)
Subject: [Git][freetype/freetype][gsoc-craig-2023] Make find_unicode_charmap public and use it to choose the best charmap for...
Date: Thu, 29 Jun 2023 01:04:14 +0000

Craig White pushed to branch gsoc-craig-2023 at FreeType / FreeType

Commits:

  • 6650b9eb
    by Craig White at 2023-06-28T21:03:22-04:00
    Make find_unicode_charmap public and use it to choose the best charmap for building the reverse character map
    

3 changed files:

Changes:

  • include/freetype/internal/ftobjs.h
    ... ... @@ -275,6 +275,26 @@ FT_BEGIN_HEADER
    275 275
                       FT_GlyphSlot    slot,
    
    276 276
                       FT_Render_Mode  mode );
    
    277 277
     
    
    278
    +  /**************************************************************************
    
    279
    +   *
    
    280
    +   * @Function:
    
    281
    +   *   find_unicode_charmap
    
    282
    +   *
    
    283
    +   * @Description:
    
    284
    +   *   This function finds a Unicode charmap, if there is one.
    
    285
    +   *   And if there is more than one, it tries to favour the more
    
    286
    +   *   extensive one, i.e., one that supports UCS-4 against those which
    
    287
    +   *   are limited to the BMP ( UCS-2 encoding.)
    
    288
    +   *
    
    289
    +   *   If a unicode charmap is found, face->charmap is set to it.
    
    290
    +   *
    
    291
    +   *   This function is called from open_face(),
    
    292
    +   *   from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ),
    
    293
    +   *   and also from afadjust.c in the autofit module.
    
    294
    +   */
    
    295
    +  FT_BASE( FT_Error )
    
    296
    +  find_unicode_charmap( FT_Face  face );
    
    297
    +
    
    278 298
     #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    
    279 299
     
    
    280 300
       typedef void  (*FT_Bitmap_LcdFilterFunc)( FT_Bitmap*      bitmap,
    

  • src/autofit/afadjust.c
    ... ... @@ -121,27 +121,17 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
    121 121
         /* Search for a unicode charmap */
    
    122 122
         /* If there isn't one, create a blank map */
    
    123 123
     
    
    124
    -    /*TODO: change this to logic that searches for a "preferred" unicode charmap that maps the most codepoints*/
    
    125
    -    /*see find_unicode_charmap*/
    
    126 124
         /*TODO: use GSUB lookups    */
    
    127 125
         FT_TRACE4(( "af_reverse_character_map_new: building reverse character map\n" ));
    
    128
    -    FT_CMap unicode_charmap = NULL;
    
    129
    -    for ( FT_UInt i = 0; i < face->num_charmaps; i++ )
    
    130
    -    {
    
    131
    -        if ( face->charmaps[i]->encoding == FT_ENCODING_UNICODE )
    
    132
    -        {
    
    133
    -            unicode_charmap = FT_CMAP( face->charmaps[i] );
    
    134
    -        }
    
    135
    -    }
    
    136 126
     
    
    137
    -    if ( unicode_charmap == NULL )
    
    138
    -    {
    
    127
    +    FT_Error error;
    
    128
    +    /* backup face->charmap because find_unicode_charmap sets it */
    
    129
    +    FT_CharMap old_charmap = face->charmap;
    
    130
    +    if (( error = find_unicode_charmap( face ) )) {
    
    139 131
             *map = NULL;
    
    140
    -        return FT_Err_Ok;
    
    132
    +        goto Exit;
    
    141 133
         }
    
    142 134
     
    
    143
    -    FT_Error error;
    
    144
    -
    
    145 135
         if ( FT_NEW( *map ) )
    
    146 136
         {
    
    147 137
             goto Exit;
    
    ... ... @@ -160,7 +150,7 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
    160 150
         for ( FT_Int i = 0; i < AF_ADJUSTMENT_DATABASE_LENGTH; i++ )
    
    161 151
         {
    
    162 152
             FT_UInt32 codepoint = adjustment_database[i].codepoint;
    
    163
    -        FT_Int glyph = unicode_charmap->clazz->char_index(unicode_charmap, codepoint);
    
    153
    +        FT_Int glyph = FT_Get_Char_Index( face, codepoint );
    
    164 154
             if ( glyph == 0 )
    
    165 155
             {
    
    166 156
     #ifdef FT_DEBUG_LEVEL_TRACE
    
    ... ... @@ -183,6 +173,7 @@ af_reverse_character_map_new( FT_Face face, AF_ReverseCharacterMap *map, FT_Memo
    183 173
         ( *map )->length = size;
    
    184 174
     
    
    185 175
     Exit:
    
    176
    +    face->charmap = old_charmap;
    
    186 177
         if ( error )
    
    187 178
         {
    
    188 179
             FT_TRACE4(( "    error while building reverse character map.  Using blank map.\n" ));
    

  • src/base/ftobjs.c
    ... ... @@ -1358,21 +1358,7 @@
    1358 1358
                           driver );
    
    1359 1359
       }
    
    1360 1360
     
    
    1361
    -  /**************************************************************************
    
    1362
    -   *
    
    1363
    -   * @Function:
    
    1364
    -   *   find_unicode_charmap
    
    1365
    -   *
    
    1366
    -   * @Description:
    
    1367
    -   *   This function finds a Unicode charmap, if there is one.
    
    1368
    -   *   And if there is more than one, it tries to favour the more
    
    1369
    -   *   extensive one, i.e., one that supports UCS-4 against those which
    
    1370
    -   *   are limited to the BMP (said UCS-2 encoding.)
    
    1371
    -   *
    
    1372
    -   *   This function is called from open_face() (just below), and also
    
    1373
    -   *   from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ).
    
    1374
    -   */
    
    1375
    -  static FT_Error
    
    1361
    +  FT_Error
    
    1376 1362
       find_unicode_charmap( FT_Face  face )
    
    1377 1363
       {
    
    1378 1364
         FT_CharMap*  first;
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]