freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][dev/wl/VF-fixes] [truetype] Fix style name hand


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][dev/wl/VF-fixes] [truetype] Fix style name handling for variation fonts.
Date: Fri, 28 Apr 2023 11:51:54 +0000

Werner Lemberg pushed to branch dev/wl/VF-fixes at FreeType / FreeType

Commits:

  • 36e9878c
    by Werner Lemberg at 2023-04-28T13:45:49+02:00
    [truetype] Fix style name handling for variation fonts.
    
    * include/freetype/internal/tttypes.h (TT_FaceRec): New field
    `non_var_style_name`.
    
    * src/sfnt/sfobjs.c (sfnt_load_face): Initialize `non_var_style_name`.
    (sfnt_done_face): Free `non_var_style_name`.
    
    * src/truetype/ttgxvar.c (TT_Set_Named_Instance): Restore non-VF style name
    if switching back to non-VF mode.
    

3 changed files:

Changes:

  • include/freetype/internal/tttypes.h
    ... ... @@ -1318,6 +1318,9 @@ FT_BEGIN_HEADER
    1318 1318
        *   var_default_named_instance ::
    
    1319 1319
        *     The index of the default named instance.
    
    1320 1320
        *
    
    1321
    +   *   non_var_style_name ::
    
    1322
    +   *     The non-variation style name, used as a backup.
    
    1323
    +   *
    
    1321 1324
        *   horz_metrics_size ::
    
    1322 1325
        *     The size of the 'hmtx' table.
    
    1323 1326
        *
    
    ... ... @@ -1556,6 +1559,8 @@ FT_BEGIN_HEADER
    1556 1559
         FT_UInt               var_postscript_prefix_len; /* since 2.7.2 */
    
    1557 1560
     
    
    1558 1561
         FT_UInt               var_default_named_instance;  /* since 2.13.1 */
    
    1562
    +
    
    1563
    +    const char*           non_var_style_name;  /* since 2.13.1 */
    
    1559 1564
     #endif
    
    1560 1565
     
    
    1561 1566
         /* since version 2.2 */
    

  • src/sfnt/sfobjs.c
    ... ... @@ -1063,6 +1063,16 @@
    1063 1063
             GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
    
    1064 1064
         }
    
    1065 1065
     
    
    1066
    +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    1067
    +    {
    
    1068
    +      FT_Memory  memory = face->root.memory;
    
    1069
    +
    
    1070
    +
    
    1071
    +      if ( FT_STRDUP( face->non_var_style_name, face->root.style_name ) )
    
    1072
    +        goto Exit;
    
    1073
    +    }
    
    1074
    +#endif
    
    1075
    +
    
    1066 1076
         /* now set up root fields */
    
    1067 1077
         {
    
    1068 1078
           FT_Face  root  = &face->root;
    
    ... ... @@ -1509,6 +1519,7 @@
    1509 1519
     
    
    1510 1520
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    1511 1521
         FT_FREE( face->var_postscript_prefix );
    
    1522
    +    FT_FREE( face->non_var_style_name );
    
    1512 1523
     #endif
    
    1513 1524
     
    
    1514 1525
         /* freeing glyph color palette data */
    

  • src/truetype/ttgxvar.c
    ... ... @@ -3306,6 +3306,8 @@
    3306 3306
         GX_Blend    blend;
    
    3307 3307
         FT_MM_Var*  mmvar;
    
    3308 3308
     
    
    3309
    +    FT_Memory  memory = face->root.memory;
    
    3310
    +
    
    3309 3311
         FT_UInt  num_instances;
    
    3310 3312
     
    
    3311 3313
     
    
    ... ... @@ -3329,8 +3331,7 @@
    3329 3331
     
    
    3330 3332
         if ( instance_index > 0 )
    
    3331 3333
         {
    
    3332
    -      FT_Memory     memory = face->root.memory;
    
    3333
    -      SFNT_Service  sfnt   = (SFNT_Service)face->sfnt;
    
    3334
    +      SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
    
    3334 3335
     
    
    3335 3336
           FT_Var_Named_Style*  named_style;
    
    3336 3337
           FT_String*           style_name;
    
    ... ... @@ -3354,7 +3355,13 @@
    3354 3355
                                      named_style->coords );
    
    3355 3356
         }
    
    3356 3357
         else
    
    3358
    +    {
    
    3359
    +      /* restore non-VF style name */
    
    3360
    +      FT_FREE( face->root.style_name );
    
    3361
    +      if ( FT_STRDUP( face->root.style_name, face->non_var_style_name ) )
    
    3362
    +        goto Exit;
    
    3357 3363
           error = TT_Set_Var_Design( face, 0, NULL );
    
    3364
    +    }
    
    3358 3365
     
    
    3359 3366
       Exit:
    
    3360 3367
         return error;
    


  • reply via email to

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