freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] 6 commits: New Variation Font function


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] 6 commits: New Variation Font function `FT_Get_Default_Named_Instance`.
Date: Sat, 06 May 2023 16:54:36 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • fb982e78
    by Werner Lemberg at 2023-05-06T18:53:50+02:00
    New Variation Font function `FT_Get_Default_Named_Instance`.
    
    * include/freetype/ftmm.h, src/base/ftmm.c (FT_Get_Default_Named_Instance):
    New function.
    
    * include/freetype/internal/services/svmm.h
    (FT_Get_Default_Named_Instance_Func): New typedef.
    (FT_Service_MultiMasters): New field `get_default_named_instance`.
    (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
    
    * include/freetype/internal/tttypes.h (TT_Face): New field
    `var_default_named_instance`.
    
    * src/sfnt/sfobjc.s (sfnt_init_face): Initialize
    `var_default_named_instance`.
    
    * src/cff/cffdrivr.c (cff_get_default_named_instance): New function.
    (cff_service_multi_masters): Updated.
    
    * src/truetype/ttgxvar.c (TT_Get_MM_Var): Initialize
    `var_default_named_instance`.
    (TT_Get_Default_Named_Instance): New function.
    * src/truetype/ttgxvar.h: Updated.
    * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
    
    * src/type1/t1driver.c (t1_service_multi_masters): Updated.
    
    * docs/CHANGES: Updated.
    
  • fdcb14a2
    by Werner Lemberg at 2023-05-06T18:53:50+02:00
    s/set_instance/set_named_instance/
    
    * include/freetype/internal/services/svmm.h (FT_Set_Instance_Func): Renamed
    to...
    (FT_Set_Named_Instance_Func): ...this.
    (FT_Service_MultiMasters): Rename `set_instance` to `set_named_instance`.
    (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
    
    * src/base/ftmm.c (FT_Set_Named_Instance): Updated.
    
    * src/cff/cffdrivr.c (cff_set_instance): Renamed to...
    (cff_set_named_instance): ...this.
    (cff_service_multi_masters): Updated.
    * src/cff/cffobjs.c (cff_face_init): Updated.
    
    * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
    
    * src/type1/t1driver.c (t1_service_multi_masters): Updated.
    
  • 6713b1e4
    by Werner Lemberg at 2023-05-06T18:53:50+02:00
    [truetype] Fix deactivation of variation font handling.
    
    According to the documentation, the functions `FT_Set_Named_Instance`,
    `FT_Set_MM_Design_Coordinates`, `FT_Set_Var_Design_Coordinates`, and
    `FT_Set_Var_Blend_Coordinates` can unset the `FT_FACE_FLAG_VARIATION` flag.
    (The same is true for `FT_Set_MM_WeightVector` but this information was
    accidentally omitted from the documentation.)
    
    However, if a call of these functions didn't change the axis values this
    could fail because internal shortcuts exited too early.
    
    This commit reorganizes the code to handle `FT_FACE_FLAG_VARIATION` in the
    top-level API functions, also taking care of the issue at hand.
    
    * src/base/ftmm.c (FT_Set_MM_Design_Coordinates, FT_Set_MM_WeightVector,
    FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates,
    FT_Set_Var_Blend_Coordinates): Handle `FT_FACE_FLAG_VARIATION`.
    
    * src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design,
    TT_Set_Named_Instance) Don't handle `FT_FACE_FLAG_VARIATION`.
    
    * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_WeightVector,
    T1_Set_MM_Design): Ditto.
    
    * src/cff/cffobjs.c (cff_face_init): Use `FT_Set_Named_Instance` instead of
    low-level functions.
    
    * src/truetype/ttobjs.c (tt_face_init): Ditto.
    
  • 7af8fd00
    by Werner Lemberg at 2023-05-06T18:53:50+02:00
    * include/freetype/internal/services/svmm.h: Minor changes.
    
  • c8a24209
    by Werner Lemberg at 2023-05-06T18:53:50+02:00
    [truetype] Fix PostScript name handling for variation fonts.
    
    A variation font's PostScript name of a named instance is usually different
    from the PostScript name of an unnamed instance.  However, if a change
    between a named instance and an unnamed instance with exactly the same
    design axis values happened, it was possible that the PostScript name wasn't
    correctly updated.
    
    This commit reorganizes the code to handle this issue within the top-level
    API functions, using a new service to trigger recomputation of the
    PostScript name.
    
    * include/freetype/internal/services/svmm.h (FT_Construct_PS_Name_Func): New
    typedef.
    (FT_Service_MultiMasters): New field `construct_ps_name`.
    (FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
    
    * src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
    FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Call
    `mm->construct_ps_name` to handle `postscript_name`.
    (FT_Set_Named_Instance): Call `mm->construct_ps_name` to handle
    `postscript_name`.
    Use shortcut.
    * src/cff/cffdrivr.c (cff_construct_ps_name): New function.
    (cff_service_multi_masters): Updated.
    
    * src/truetype/ttgxvar.c (tt_set_mm_blend): Don't handle `postscript_name`.
    (TT_Set_MM_Blend): Simplify.
    (TT_Set_Named_Instance): Return -1 if axis values haven't changed.
    Don't set `face_index`.
    (tt_construct_ps_name): New function.
    
    * src/truetype/ttgxvar.h: Updated.
    
    * src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
    
    * src/type1/t1driver.c (t1_service_multi_masters): Updated.
    
    * src/type1/t1load.c (T1_Set_MM_Blend): Simplify.
    
  • 8fe50c2a
    by Werner Lemberg at 2023-05-06T18:53:50+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.
    

14 changed files:

Changes:

  • docs/CHANGES
    1
    +CHANGES BETWEEN 2.13.0 and 2.13.1 (2023-XXX-XX)
    
    2
    +
    
    3
    +  I. MISCELLANEOUS
    
    4
    +
    
    5
    +  - New function  `FT_Get_Default_Named_Instance` to get the  index of
    
    6
    +    the default named instance of an OpenType Variation Font.
    
    7
    +
    
    8
    +
    
    9
    +======================================================================
    
    10
    +
    
    1 11
     CHANGES BETWEEN 2.12.1 and 2.13.0 (2023-Feb-09)
    
    2 12
     
    
    3 13
       I. IMPORTANT CHANGES
    
    ... ... @@ -12,7 +22,7 @@ CHANGES BETWEEN 2.12.1 and 2.13.0 (2023-Feb-09)
    12 22
           https://learn.microsoft.com/en-us/typography/opentype/spec/colr
    
    13 23
     
    
    14 24
     
    
    15
    -  III. MISCELLANEOUS
    
    25
    +  II. MISCELLANEOUS
    
    16 26
     
    
    17 27
       - For  OpenType  Variable Fonts,  `avar`  table  format 2.0  is  now
    
    18 28
         supported.  The code was contributed by Behdad Esfahbod.
    

  • include/freetype/ftmm.h
    ... ... @@ -602,10 +602,12 @@ FT_BEGIN_HEADER
    602 602
        *
    
    603 603
        * @note:
    
    604 604
        *   Adobe Multiple Master fonts limit the number of designs, and thus the
    
    605
    -   *   length of the weight vector to~16.
    
    605
    +   *   length of the weight vector to 16~elements.
    
    606 606
        *
    
    607
    -   *   If `len` is zero and `weightvector` is `NULL`, the weight vector array
    
    608
    -   *   is reset to the default values.
    
    607
    +   *   If `len` is larger than zero, this function sets the
    
    608
    +   *   @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags` field (i.e.,
    
    609
    +   *   @FT_IS_VARIATION will return true).  If `len` is zero, this bit flag
    
    610
    +   *   is unset and the weight vector array is reset to the default values.
    
    609 611
        *
    
    610 612
        *   The Adobe documentation also states that the values in the
    
    611 613
        *   WeightVector array must total 1.0 +/-~0.001.  In practice this does
    
    ... ... @@ -753,6 +755,45 @@ FT_BEGIN_HEADER
    753 755
       FT_Set_Named_Instance( FT_Face  face,
    
    754 756
                              FT_UInt  instance_index );
    
    755 757
     
    
    758
    +
    
    759
    +  /**************************************************************************
    
    760
    +   *
    
    761
    +   * @function:
    
    762
    +   *   FT_Get_Default_Named_Instance
    
    763
    +   *
    
    764
    +   * @description:
    
    765
    +   *   Retrieve the index of the default named instance, to be used with
    
    766
    +   *   @FT_Set_Named_Instance.
    
    767
    +   *
    
    768
    +   *   The default instance of a variation font is that instance for which
    
    769
    +   *   the nth axis coordinate is equal to `axis[n].def` (as specified in the
    
    770
    +   *   @FT_MM_Var structure), with~n covering all axes.
    
    771
    +   *
    
    772
    +   *   FreeType synthesizes a named instance for the default instance if the
    
    773
    +   *   font does not contain such an entry.
    
    774
    +   *
    
    775
    +   * @input:
    
    776
    +   *   face ::
    
    777
    +   *     A handle to the source face.
    
    778
    +   *
    
    779
    +   * @output:
    
    780
    +   *   instance_index ::
    
    781
    +   *     The index of the default named instance.
    
    782
    +   *
    
    783
    +   * @return:
    
    784
    +   *   FreeType error code.  0~means success.
    
    785
    +   *
    
    786
    +   * @note:
    
    787
    +   *   For Adobe MM fonts (which don't have named instances) this function
    
    788
    +   *   always returns zero for `instance_index`.
    
    789
    +   *
    
    790
    +   * @since:
    
    791
    +   *   2.13.1
    
    792
    +   */
    
    793
    +  FT_EXPORT( FT_Error )
    
    794
    +  FT_Get_Default_Named_Instance( FT_Face   face,
    
    795
    +                                 FT_UInt  *instance_index );
    
    796
    +
    
    756 797
       /* */
    
    757 798
     
    
    758 799
     
    

  • include/freetype/internal/services/svmm.h
    ... ... @@ -70,8 +70,12 @@ FT_BEGIN_HEADER
    70 70
                                  FT_Fixed*  coords );
    
    71 71
     
    
    72 72
       typedef FT_Error
    
    73
    -  (*FT_Set_Instance_Func)( FT_Face  face,
    
    74
    -                           FT_UInt  instance_index );
    
    73
    +  (*FT_Set_Named_Instance_Func)( FT_Face  face,
    
    74
    +                                 FT_UInt  instance_index );
    
    75
    +
    
    76
    +  typedef FT_Error
    
    77
    +  (*FT_Get_Default_Named_Instance_Func)( FT_Face   face,
    
    78
    +                                         FT_UInt  *instance_index );
    
    75 79
     
    
    76 80
       typedef FT_Error
    
    77 81
       (*FT_Get_MM_Blend_Func)( FT_Face   face,
    
    ... ... @@ -86,7 +90,7 @@ FT_BEGIN_HEADER
    86 90
                                 FT_MM_Var*  *mm_var );
    
    87 91
     
    
    88 92
       typedef void
    
    89
    -  (*FT_Done_Blend_Func)( FT_Face );
    
    93
    +  (*FT_Done_Blend_Func)( FT_Face  face );
    
    90 94
     
    
    91 95
       typedef FT_Error
    
    92 96
       (*FT_Set_MM_WeightVector_Func)( FT_Face    face,
    
    ... ... @@ -98,6 +102,9 @@ FT_BEGIN_HEADER
    98 102
                                       FT_UInt*   len,
    
    99 103
                                       FT_Fixed*  weight_vector );
    
    100 104
     
    
    105
    +  typedef void
    
    106
    +  (*FT_Construct_PS_Name_Func)( FT_Face  face );
    
    107
    +
    
    101 108
       typedef FT_Error
    
    102 109
       (*FT_Var_Load_Delta_Set_Idx_Map_Func)( FT_Face            face,
    
    103 110
                                              FT_ULong           offset,
    
    ... ... @@ -134,11 +141,13 @@ FT_BEGIN_HEADER
    134 141
         FT_Get_MM_Var_Func                    get_mm_var;
    
    135 142
         FT_Set_Var_Design_Func                set_var_design;
    
    136 143
         FT_Get_Var_Design_Func                get_var_design;
    
    137
    -    FT_Set_Instance_Func                  set_instance;
    
    144
    +    FT_Set_Named_Instance_Func            set_named_instance;
    
    145
    +    FT_Get_Default_Named_Instance_Func    get_default_named_instance;
    
    138 146
         FT_Set_MM_WeightVector_Func           set_mm_weightvector;
    
    139 147
         FT_Get_MM_WeightVector_Func           get_mm_weightvector;
    
    140 148
     
    
    141 149
         /* for internal use; only needed for code sharing between modules */
    
    150
    +    FT_Construct_PS_Name_Func             construct_ps_name;
    
    142 151
         FT_Var_Load_Delta_Set_Idx_Map_Func    load_delta_set_idx_map;
    
    143 152
         FT_Var_Load_Item_Var_Store_Func       load_item_var_store;
    
    144 153
         FT_Var_Get_Item_Delta_Func            get_item_delta;
    
    ... ... @@ -149,43 +158,49 @@ FT_BEGIN_HEADER
    149 158
       };
    
    150 159
     
    
    151 160
     
    
    152
    -#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_,                  \
    
    153
    -                                           get_mm_,                 \
    
    154
    -                                           set_mm_design_,          \
    
    155
    -                                           set_mm_blend_,           \
    
    156
    -                                           get_mm_blend_,           \
    
    157
    -                                           get_mm_var_,             \
    
    158
    -                                           set_var_design_,         \
    
    159
    -                                           get_var_design_,         \
    
    160
    -                                           set_instance_,           \
    
    161
    -                                           set_weightvector_,       \
    
    162
    -                                           get_weightvector_,       \
    
    163
    -                                           load_delta_set_idx_map_, \
    
    164
    -                                           load_item_var_store_,    \
    
    165
    -                                           get_item_delta_,         \
    
    166
    -                                           done_item_var_store_,    \
    
    167
    -                                           done_delta_set_idx_map_, \
    
    168
    -                                           get_var_blend_,          \
    
    169
    -                                           done_blend_ )            \
    
    170
    -  static const FT_Service_MultiMastersRec  class_ =                 \
    
    171
    -  {                                                                 \
    
    172
    -    get_mm_,                                                        \
    
    173
    -    set_mm_design_,                                                 \
    
    174
    -    set_mm_blend_,                                                  \
    
    175
    -    get_mm_blend_,                                                  \
    
    176
    -    get_mm_var_,                                                    \
    
    177
    -    set_var_design_,                                                \
    
    178
    -    get_var_design_,                                                \
    
    179
    -    set_instance_,                                                  \
    
    180
    -    set_weightvector_,                                              \
    
    181
    -    get_weightvector_,                                              \
    
    182
    -    load_delta_set_idx_map_,                                        \
    
    183
    -    load_item_var_store_,                                           \
    
    184
    -    get_item_delta_,                                                \
    
    185
    -    done_item_var_store_,                                           \
    
    186
    -    done_delta_set_idx_map_,                                        \
    
    187
    -    get_var_blend_,                                                 \
    
    188
    -    done_blend_                                                     \
    
    161
    +#define FT_DEFINE_SERVICE_MULTIMASTERSREC( class_,                      \
    
    162
    +                                           get_mm_,                     \
    
    163
    +                                           set_mm_design_,              \
    
    164
    +                                           set_mm_blend_,               \
    
    165
    +                                           get_mm_blend_,               \
    
    166
    +                                           get_mm_var_,                 \
    
    167
    +                                           set_var_design_,             \
    
    168
    +                                           get_var_design_,             \
    
    169
    +                                           set_named_instance_,         \
    
    170
    +                                           get_default_named_instance_, \
    
    171
    +                                           set_mm_weightvector_,        \
    
    172
    +                                           get_mm_weightvector_,        \
    
    173
    +                                                                        \
    
    174
    +                                           construct_ps_name_,          \
    
    175
    +                                           load_delta_set_idx_map_,     \
    
    176
    +                                           load_item_var_store_,        \
    
    177
    +                                           get_item_delta_,             \
    
    178
    +                                           done_item_var_store_,        \
    
    179
    +                                           done_delta_set_idx_map_,     \
    
    180
    +                                           get_var_blend_,              \
    
    181
    +                                           done_blend_ )                \
    
    182
    +  static const FT_Service_MultiMastersRec  class_ =                     \
    
    183
    +  {                                                                     \
    
    184
    +    get_mm_,                                                            \
    
    185
    +    set_mm_design_,                                                     \
    
    186
    +    set_mm_blend_,                                                      \
    
    187
    +    get_mm_blend_,                                                      \
    
    188
    +    get_mm_var_,                                                        \
    
    189
    +    set_var_design_,                                                    \
    
    190
    +    get_var_design_,                                                    \
    
    191
    +    set_named_instance_,                                                \
    
    192
    +    get_default_named_instance_,                                        \
    
    193
    +    set_mm_weightvector_,                                               \
    
    194
    +    get_mm_weightvector_,                                               \
    
    195
    +                                                                        \
    
    196
    +    construct_ps_name_,                                                 \
    
    197
    +    load_delta_set_idx_map_,                                            \
    
    198
    +    load_item_var_store_,                                               \
    
    199
    +    get_item_delta_,                                                    \
    
    200
    +    done_item_var_store_,                                               \
    
    201
    +    done_delta_set_idx_map_,                                            \
    
    202
    +    get_var_blend_,                                                     \
    
    203
    +    done_blend_                                                         \
    
    189 204
       };
    
    190 205
     
    
    191 206
       /* */
    

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

  • src/base/ftmm.c
    ... ... @@ -185,6 +185,14 @@
    185 185
           error = FT_ERR( Invalid_Argument );
    
    186 186
           if ( service->set_mm_design )
    
    187 187
             error = service->set_mm_design( face, num_coords, coords );
    
    188
    +
    
    189
    +      if ( !error )
    
    190
    +      {
    
    191
    +        if ( num_coords )
    
    192
    +          face->face_flags |= FT_FACE_FLAG_VARIATION;
    
    193
    +        else
    
    194
    +          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    195
    +      }
    
    188 196
         }
    
    189 197
     
    
    190 198
         /* enforce recomputation of auto-hinting data */
    
    ... ... @@ -220,6 +228,14 @@
    220 228
           error = FT_ERR( Invalid_Argument );
    
    221 229
           if ( service->set_mm_weightvector )
    
    222 230
             error = service->set_mm_weightvector( face, len, weightvector );
    
    231
    +
    
    232
    +      if ( !error )
    
    233
    +      {
    
    234
    +        if ( len )
    
    235
    +          face->face_flags |= FT_FACE_FLAG_VARIATION;
    
    236
    +        else
    
    237
    +          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    238
    +      }
    
    223 239
         }
    
    224 240
     
    
    225 241
         /* enforce recomputation of auto-hinting data */
    
    ... ... @@ -283,6 +299,30 @@
    283 299
           if ( service_mm->set_var_design )
    
    284 300
             error = service_mm->set_var_design( face, num_coords, coords );
    
    285 301
     
    
    302
    +      if ( !error || error == -1 )
    
    303
    +      {
    
    304
    +        FT_Bool  is_variation_old = FT_IS_VARIATION( face );
    
    305
    +
    
    306
    +
    
    307
    +        if ( num_coords )
    
    308
    +          face->face_flags |= FT_FACE_FLAG_VARIATION;
    
    309
    +        else
    
    310
    +          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    311
    +
    
    312
    +        if ( service_mm->construct_ps_name )
    
    313
    +        {
    
    314
    +          if ( error == -1 )
    
    315
    +          {
    
    316
    +            /* The PS name of a named instance and a non-named instance */
    
    317
    +            /* usually differs, even if the axis values are identical.  */
    
    318
    +            if ( is_variation_old != FT_IS_VARIATION( face ) )
    
    319
    +              service_mm->construct_ps_name( face );
    
    320
    +          }
    
    321
    +          else
    
    322
    +            service_mm->construct_ps_name( face );
    
    323
    +        }
    
    324
    +      }
    
    325
    +
    
    286 326
           /* internal error code -1 means `no change'; we can exit immediately */
    
    287 327
           if ( error == -1 )
    
    288 328
             return FT_Err_Ok;
    
    ... ... @@ -359,6 +399,30 @@
    359 399
           if ( service_mm->set_mm_blend )
    
    360 400
             error = service_mm->set_mm_blend( face, num_coords, coords );
    
    361 401
     
    
    402
    +      if ( !error || error == -1 )
    
    403
    +      {
    
    404
    +        FT_Bool  is_variation_old = FT_IS_VARIATION( face );
    
    405
    +
    
    406
    +
    
    407
    +        if ( num_coords )
    
    408
    +          face->face_flags |= FT_FACE_FLAG_VARIATION;
    
    409
    +        else
    
    410
    +          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    411
    +
    
    412
    +        if ( service_mm->construct_ps_name )
    
    413
    +        {
    
    414
    +          if ( error == -1 )
    
    415
    +          {
    
    416
    +            /* The PS name of a named instance and a non-named instance */
    
    417
    +            /* usually differs, even if the axis values are identical.  */
    
    418
    +            if ( is_variation_old != FT_IS_VARIATION( face ) )
    
    419
    +              service_mm->construct_ps_name( face );
    
    420
    +          }
    
    421
    +          else
    
    422
    +            service_mm->construct_ps_name( face );
    
    423
    +        }
    
    424
    +      }
    
    425
    +
    
    362 426
           /* internal error code -1 means `no change'; we can exit immediately */
    
    363 427
           if ( error == -1 )
    
    364 428
             return FT_Err_Ok;
    
    ... ... @@ -410,6 +474,30 @@
    410 474
           if ( service_mm->set_mm_blend )
    
    411 475
             error = service_mm->set_mm_blend( face, num_coords, coords );
    
    412 476
     
    
    477
    +      if ( !error || error == -1 )
    
    478
    +      {
    
    479
    +        FT_Bool  is_variation_old = FT_IS_VARIATION( face );
    
    480
    +
    
    481
    +
    
    482
    +        if ( num_coords )
    
    483
    +          face->face_flags |= FT_FACE_FLAG_VARIATION;
    
    484
    +        else
    
    485
    +          face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    486
    +
    
    487
    +        if ( service_mm->construct_ps_name )
    
    488
    +        {
    
    489
    +          if ( error == -1 )
    
    490
    +          {
    
    491
    +            /* The PS name of a named instance and a non-named instance */
    
    492
    +            /* usually differs, even if the axis values are identical.  */
    
    493
    +            if ( is_variation_old != FT_IS_VARIATION( face ) )
    
    494
    +              service_mm->construct_ps_name( face );
    
    495
    +          }
    
    496
    +          else
    
    497
    +            service_mm->construct_ps_name( face );
    
    498
    +        }
    
    499
    +      }
    
    500
    +
    
    413 501
           /* internal error code -1 means `no change'; we can exit immediately */
    
    414 502
           if ( error == -1 )
    
    415 503
             return FT_Err_Ok;
    
    ... ... @@ -535,8 +623,35 @@
    535 623
         if ( !error )
    
    536 624
         {
    
    537 625
           error = FT_ERR( Invalid_Argument );
    
    538
    -      if ( service_mm->set_instance )
    
    539
    -        error = service_mm->set_instance( face, instance_index );
    
    626
    +      if ( service_mm->set_named_instance )
    
    627
    +        error = service_mm->set_named_instance( face, instance_index );
    
    628
    +
    
    629
    +      if ( !error || error == -1 )
    
    630
    +      {
    
    631
    +        FT_Bool  is_variation_old = FT_IS_VARIATION( face );
    
    632
    +
    
    633
    +
    
    634
    +        face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    635
    +        face->face_index  = ( instance_index << 16 )        |
    
    636
    +                            ( face->face_index & 0xFFFFL );
    
    637
    +
    
    638
    +        if ( service_mm->construct_ps_name )
    
    639
    +        {
    
    640
    +          if ( error == -1 )
    
    641
    +          {
    
    642
    +            /* The PS name of a named instance and a non-named instance */
    
    643
    +            /* usually differs, even if the axis values are identical.  */
    
    644
    +            if ( is_variation_old != FT_IS_VARIATION( face ) )
    
    645
    +              service_mm->construct_ps_name( face );
    
    646
    +          }
    
    647
    +          else
    
    648
    +            service_mm->construct_ps_name( face );
    
    649
    +        }
    
    650
    +      }
    
    651
    +
    
    652
    +      /* internal error code -1 means `no change'; we can exit immediately */
    
    653
    +      if ( error == -1 )
    
    654
    +        return FT_Err_Ok;
    
    540 655
         }
    
    541 656
     
    
    542 657
         if ( !error )
    
    ... ... @@ -554,11 +669,32 @@
    554 669
           face->autohint.data = NULL;
    
    555 670
         }
    
    556 671
     
    
    672
    +    return error;
    
    673
    +  }
    
    674
    +
    
    675
    +
    
    676
    +  /* documentation is in ftmm.h */
    
    677
    +
    
    678
    +  FT_EXPORT_DEF( FT_Error )
    
    679
    +  FT_Get_Default_Named_Instance( FT_Face   face,
    
    680
    +                                 FT_UInt  *instance_index )
    
    681
    +  {
    
    682
    +    FT_Error  error;
    
    683
    +
    
    684
    +    FT_Service_MultiMasters  service_mm = NULL;
    
    685
    +
    
    686
    +
    
    687
    +    /* check of `face' delayed to `ft_face_get_mm_service' */
    
    688
    +
    
    689
    +    error = ft_face_get_mm_service( face, &service_mm );
    
    557 690
         if ( !error )
    
    558 691
         {
    
    559
    -      face->face_index  = ( instance_index << 16 )        |
    
    560
    -                          ( face->face_index & 0xFFFFL );
    
    561
    -      face->face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    692
    +      /* no error if `get_default_named_instance` is not available */
    
    693
    +      if ( service_mm->get_default_named_instance )
    
    694
    +        error = service_mm->get_default_named_instance( face,
    
    695
    +                                                        instance_index );
    
    696
    +      else
    
    697
    +        error = FT_Err_Ok;
    
    562 698
         }
    
    563 699
     
    
    564 700
         return error;
    

  • src/cff/cffdrivr.c
    ... ... @@ -896,6 +896,16 @@
    896 896
       }
    
    897 897
     
    
    898 898
     
    
    899
    +  static void
    
    900
    +  cff_construct_ps_name( CFF_Face  face )
    
    901
    +  {
    
    902
    +    FT_Service_MultiMasters  mm = (FT_Service_MultiMasters)face->mm;
    
    903
    +
    
    904
    +
    
    905
    +    mm->construct_ps_name( FT_FACE( face ) );
    
    906
    +  }
    
    907
    +
    
    908
    +
    
    899 909
       static FT_Error
    
    900 910
       cff_get_mm_var( CFF_Face     face,
    
    901 911
                       FT_MM_Var*  *master )
    
    ... ... @@ -932,13 +942,24 @@
    932 942
     
    
    933 943
     
    
    934 944
       static FT_Error
    
    935
    -  cff_set_instance( CFF_Face  face,
    
    936
    -                    FT_UInt   instance_index )
    
    945
    +  cff_set_named_instance( CFF_Face  face,
    
    946
    +                          FT_UInt   instance_index )
    
    937 947
       {
    
    938 948
         FT_Service_MultiMasters  mm = (FT_Service_MultiMasters)face->mm;
    
    939 949
     
    
    940 950
     
    
    941
    -    return mm->set_instance( FT_FACE( face ), instance_index );
    
    951
    +    return mm->set_named_instance( FT_FACE( face ), instance_index );
    
    952
    +  }
    
    953
    +
    
    954
    +
    
    955
    +  static FT_Error
    
    956
    +  cff_get_default_named_instance( CFF_Face  face,
    
    957
    +                                  FT_UInt  *instance_index )
    
    958
    +  {
    
    959
    +    FT_Service_MultiMasters  mm = (FT_Service_MultiMasters)face->mm;
    
    960
    +
    
    961
    +
    
    962
    +    return mm->get_default_named_instance( FT_FACE( face ), instance_index );
    
    942 963
       }
    
    943 964
     
    
    944 965
     
    
    ... ... @@ -1009,36 +1030,45 @@
    1009 1030
       FT_DEFINE_SERVICE_MULTIMASTERSREC(
    
    1010 1031
         cff_service_multi_masters,
    
    1011 1032
     
    
    1012
    -    (FT_Get_MM_Func)        NULL,               /* get_mm                    */
    
    1013
    -    (FT_Set_MM_Design_Func) NULL,               /* set_mm_design             */
    
    1014
    -    (FT_Set_MM_Blend_Func)  cff_set_mm_blend,   /* set_mm_blend              */
    
    1015
    -    (FT_Get_MM_Blend_Func)  cff_get_mm_blend,   /* get_mm_blend              */
    
    1016
    -    (FT_Get_MM_Var_Func)    cff_get_mm_var,     /* get_mm_var                */
    
    1017
    -    (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design            */
    
    1018
    -    (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design            */
    
    1019
    -    (FT_Set_Instance_Func)  cff_set_instance,   /* set_instance              */
    
    1033
    +    (FT_Get_MM_Func)        NULL,               /* get_mm                     */
    
    1034
    +    (FT_Set_MM_Design_Func) NULL,               /* set_mm_design              */
    
    1035
    +    (FT_Set_MM_Blend_Func)  cff_set_mm_blend,   /* set_mm_blend               */
    
    1036
    +    (FT_Get_MM_Blend_Func)  cff_get_mm_blend,   /* get_mm_blend               */
    
    1037
    +    (FT_Get_MM_Var_Func)    cff_get_mm_var,     /* get_mm_var                 */
    
    1038
    +    (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design             */
    
    1039
    +    (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design             */
    
    1040
    +    (FT_Set_Named_Instance_Func)
    
    1041
    +                            cff_set_named_instance,
    
    1042
    +                                                /* set_named_instance         */
    
    1043
    +    (FT_Get_Default_Named_Instance_Func)
    
    1044
    +                            cff_get_default_named_instance,
    
    1045
    +                                                /* get_default_named_instance */
    
    1020 1046
         (FT_Set_MM_WeightVector_Func)
    
    1021 1047
                                 cff_set_mm_weightvector,
    
    1022
    -                                                /* set_mm_weightvector       */
    
    1048
    +                                                /* set_mm_weightvector        */
    
    1023 1049
         (FT_Get_MM_WeightVector_Func)
    
    1024 1050
                                 cff_get_mm_weightvector,
    
    1025
    -                                                /* get_mm_weightvector       */
    
    1051
    +                                                /* get_mm_weightvector        */
    
    1052
    +
    
    1053
    +    (FT_Construct_PS_Name_Func)
    
    1054
    +                            cff_construct_ps_name,
    
    1055
    +                                                /* construct_ps_name          */
    
    1026 1056
         (FT_Var_Load_Delta_Set_Idx_Map_Func)
    
    1027 1057
                                 cff_load_delta_set_index_mapping,
    
    1028
    -                                                /* load_delta_set_idx_map    */
    
    1058
    +                                                /* load_delta_set_idx_map     */
    
    1029 1059
         (FT_Var_Load_Item_Var_Store_Func)
    
    1030 1060
                                 cff_load_item_variation_store,
    
    1031
    -                                                /* load_item_variation_store */
    
    1061
    +                                                /* load_item_variation_store  */
    
    1032 1062
         (FT_Var_Get_Item_Delta_Func)
    
    1033
    -                            cff_get_item_delta, /* get_item_delta            */
    
    1063
    +                            cff_get_item_delta, /* get_item_delta             */
    
    1034 1064
         (FT_Var_Done_Item_Var_Store_Func)
    
    1035 1065
                                 cff_done_item_variation_store,
    
    1036
    -                                                /* done_item_variation_store */
    
    1066
    +                                                /* done_item_variation_store  */
    
    1037 1067
         (FT_Var_Done_Delta_Set_Idx_Map_Func)
    
    1038 1068
                                 cff_done_delta_set_index_map,
    
    1039
    -                                                /* done_delta_set_index_map  */
    
    1040
    -    (FT_Get_Var_Blend_Func) cff_get_var_blend,  /* get_var_blend             */
    
    1041
    -    (FT_Done_Blend_Func)    cff_done_blend      /* done_blend                */
    
    1069
    +                                                /* done_delta_set_index_map   */
    
    1070
    +    (FT_Get_Var_Blend_Func) cff_get_var_blend,  /* get_var_blend              */
    
    1071
    +    (FT_Done_Blend_Func)    cff_done_blend      /* done_blend                 */
    
    1042 1072
       )
    
    1043 1073
     
    
    1044 1074
     
    

  • src/cff/cffobjs.c
    ... ... @@ -719,24 +719,15 @@
    719 719
     
    
    720 720
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    721 721
           {
    
    722
    -        FT_Service_MultiMasters
    
    723
    -          mm = (FT_Service_MultiMasters)face->mm;
    
    724
    -        FT_Service_MetricsVariations
    
    725
    -          var = (FT_Service_MetricsVariations)face->face_var;
    
    726
    -
    
    727 722
             FT_UInt  instance_index = (FT_UInt)face_index >> 16;
    
    728 723
     
    
    729 724
     
    
    730 725
             if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
    
    731
    -             mm                                 &&
    
    732 726
                  instance_index > 0                 )
    
    733 727
             {
    
    734
    -          error = mm->set_instance( cffface, instance_index );
    
    728
    +          error = FT_Set_Named_Instance( cffface, instance_index );
    
    735 729
               if ( error )
    
    736 730
                 goto Exit;
    
    737
    -
    
    738
    -          if ( var )
    
    739
    -            var->metrics_adjust( cffface );
    
    740 731
             }
    
    741 732
           }
    
    742 733
     #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
    

  • src/sfnt/sfobjs.c
    ... ... @@ -698,6 +698,9 @@
    698 698
               instance_offset += instance_size;
    
    699 699
             }
    
    700 700
     
    
    701
    +        /* named instance indices start with value 1 */
    
    702
    +        face->var_default_named_instance = i + 1;
    
    703
    +
    
    701 704
             if ( i == num_instances )
    
    702 705
             {
    
    703 706
               /* no default instance in named instance table; */
    
    ... ... @@ -1060,6 +1063,16 @@
    1060 1063
             GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
    
    1061 1064
         }
    
    1062 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
    +
    
    1063 1076
         /* now set up root fields */
    
    1064 1077
         {
    
    1065 1078
           FT_Face  root  = &face->root;
    
    ... ... @@ -1506,6 +1519,7 @@
    1506 1519
     
    
    1507 1520
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    1508 1521
         FT_FREE( face->var_postscript_prefix );
    
    1522
    +    FT_FREE( face->non_var_style_name );
    
    1509 1523
     #endif
    
    1510 1524
     
    
    1511 1525
         /* freeing glyph color palette data */
    

  • src/truetype/ttdriver.c
    ... ... @@ -517,34 +517,41 @@
    517 517
       FT_DEFINE_SERVICE_MULTIMASTERSREC(
    
    518 518
         tt_service_gx_multi_masters,
    
    519 519
     
    
    520
    -    (FT_Get_MM_Func)        NULL,                  /* get_mm                    */
    
    521
    -    (FT_Set_MM_Design_Func) NULL,                  /* set_mm_design             */
    
    522
    -    (FT_Set_MM_Blend_Func)  TT_Set_MM_Blend,       /* set_mm_blend              */
    
    523
    -    (FT_Get_MM_Blend_Func)  TT_Get_MM_Blend,       /* get_mm_blend              */
    
    524
    -    (FT_Get_MM_Var_Func)    TT_Get_MM_Var,         /* get_mm_var                */
    
    525
    -    (FT_Set_Var_Design_Func)TT_Set_Var_Design,     /* set_var_design            */
    
    526
    -    (FT_Get_Var_Design_Func)TT_Get_Var_Design,     /* get_var_design            */
    
    527
    -    (FT_Set_Instance_Func)  TT_Set_Named_Instance, /* set_instance              */
    
    520
    +    (FT_Get_MM_Func)        NULL,                  /* get_mm                     */
    
    521
    +    (FT_Set_MM_Design_Func) NULL,                  /* set_mm_design              */
    
    522
    +    (FT_Set_MM_Blend_Func)  TT_Set_MM_Blend,       /* set_mm_blend               */
    
    523
    +    (FT_Get_MM_Blend_Func)  TT_Get_MM_Blend,       /* get_mm_blend               */
    
    524
    +    (FT_Get_MM_Var_Func)    TT_Get_MM_Var,         /* get_mm_var                 */
    
    525
    +    (FT_Set_Var_Design_Func)TT_Set_Var_Design,     /* set_var_design             */
    
    526
    +    (FT_Get_Var_Design_Func)TT_Get_Var_Design,     /* get_var_design             */
    
    527
    +    (FT_Set_Named_Instance_Func)
    
    528
    +                            TT_Set_Named_Instance, /* set_named_instance         */
    
    529
    +    (FT_Get_Default_Named_Instance_Func)
    
    530
    +                            TT_Get_Default_Named_Instance,
    
    531
    +                                                   /* get_default_named_instance */
    
    528 532
         (FT_Set_MM_WeightVector_Func)
    
    529
    -                            NULL,                  /* set_mm_weightvector       */
    
    533
    +                            NULL,                  /* set_mm_weightvector        */
    
    530 534
         (FT_Get_MM_WeightVector_Func)
    
    531
    -                            NULL,                  /* get_mm_weightvector       */
    
    535
    +                            NULL,                  /* get_mm_weightvector        */
    
    536
    +
    
    537
    +    (FT_Construct_PS_Name_Func)
    
    538
    +                            tt_construct_ps_name,  /* construct_ps_name          */
    
    532 539
         (FT_Var_Load_Delta_Set_Idx_Map_Func)
    
    533 540
                                 tt_var_load_delta_set_index_mapping,
    
    534
    -                                                   /* load_delta_set_idx_map    */
    
    541
    +                                                   /* load_delta_set_idx_map     */
    
    535 542
         (FT_Var_Load_Item_Var_Store_Func)
    
    536 543
                                 tt_var_load_item_variation_store,
    
    537
    -                                                   /* load_item_variation_store */
    
    544
    +                                                   /* load_item_variation_store  */
    
    538 545
         (FT_Var_Get_Item_Delta_Func)
    
    539
    -                            tt_var_get_item_delta, /* get_item_delta            */
    
    546
    +                            tt_var_get_item_delta, /* get_item_delta             */
    
    540 547
         (FT_Var_Done_Item_Var_Store_Func)
    
    541 548
                                 tt_var_done_item_variation_store,
    
    542
    -                                                   /* done_item_variation_store */
    
    549
    +                                                   /* done_item_variation_store  */
    
    543 550
         (FT_Var_Done_Delta_Set_Idx_Map_Func)
    
    544 551
                                 tt_var_done_delta_set_index_map,
    
    545
    -                                                   /* done_delta_set_index_map  */
    
    546
    -    (FT_Get_Var_Blend_Func) tt_get_var_blend,      /* get_var_blend             */
    
    547
    -    (FT_Done_Blend_Func)    tt_done_blend          /* done_blend                */
    
    552
    +                                                   /* done_delta_set_index_map   */
    
    553
    +    (FT_Get_Var_Blend_Func) tt_get_var_blend,      /* get_var_blend              */
    
    554
    +    (FT_Done_Blend_Func)    tt_done_blend          /* done_blend                 */
    
    548 555
       )
    
    549 556
     
    
    550 557
       FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
    

  • src/truetype/ttgxvar.c
    ... ... @@ -2630,8 +2630,10 @@
    2630 2630
             FT_UInt  strid = ~0U;
    
    2631 2631
     
    
    2632 2632
     
    
    2633
    -        /* the default instance is missing in array the   */
    
    2634
    -        /* of named instances; try to synthesize an entry */
    
    2633
    +        /* The default instance is missing in array the    */
    
    2634
    +        /* of named instances; try to synthesize an entry. */
    
    2635
    +        /* If this fails, `default_named_instance` remains */
    
    2636
    +        /* at value zero, which doesn't do any harm.       */
    
    2635 2637
             found = sfnt->get_name_id( face,
    
    2636 2638
                                        TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY,
    
    2637 2639
                                        &dummy1,
    
    ... ... @@ -2659,6 +2661,9 @@
    2659 2661
                 FT_TRACE5(( "TT_Get_MM_Var:"
    
    2660 2662
                             " Adding default instance to named instances\n" ));
    
    2661 2663
     
    
    2664
    +            /* named instance indices start with value 1 */
    
    2665
    +            face->var_default_named_instance = num_instances;
    
    2666
    +
    
    2662 2667
                 ns = &mmvar->namedstyle[fvar_head.instanceCount];
    
    2663 2668
     
    
    2664 2669
                 ns->strid = strid;
    
    ... ... @@ -2931,9 +2936,6 @@
    2931 2936
           }
    
    2932 2937
         }
    
    2933 2938
     
    
    2934
    -    /* enforce recomputation of the PostScript name; */
    
    2935
    -    FT_FREE( face->postscript_name );
    
    2936
    -
    
    2937 2939
       Exit:
    
    2938 2940
         return error;
    
    2939 2941
       }
    
    ... ... @@ -2973,19 +2975,7 @@
    2973 2975
                        FT_UInt    num_coords,
    
    2974 2976
                        FT_Fixed*  coords )
    
    2975 2977
       {
    
    2976
    -    FT_Error  error;
    
    2977
    -
    
    2978
    -
    
    2979
    -    error = tt_set_mm_blend( face, num_coords, coords, 1 );
    
    2980
    -    if ( error )
    
    2981
    -      return error;
    
    2982
    -
    
    2983
    -    if ( num_coords )
    
    2984
    -      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
    
    2985
    -    else
    
    2986
    -      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    2987
    -
    
    2988
    -    return FT_Err_Ok;
    
    2978
    +    return tt_set_mm_blend( face, num_coords, coords, 1 );
    
    2989 2979
       }
    
    2990 2980
     
    
    2991 2981
     
    
    ... ... @@ -3203,11 +3193,6 @@
    3203 3193
         if ( error )
    
    3204 3194
           goto Exit;
    
    3205 3195
     
    
    3206
    -    if ( num_coords )
    
    3207
    -      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
    
    3208
    -    else
    
    3209
    -      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    3210
    -
    
    3211 3196
       Exit:
    
    3212 3197
         FT_FREE( normalized );
    
    3213 3198
         return error;
    
    ... ... @@ -3310,7 +3295,8 @@
    3310 3295
        *     Value 0 indicates to not use an instance.
    
    3311 3296
        *
    
    3312 3297
        * @Return:
    
    3313
    -   *   FreeType error code.  0~means success.
    
    3298
    +   *   FreeType error code.  0~means success, -1 means success and unchanged
    
    3299
    +   *   axis values.
    
    3314 3300
        */
    
    3315 3301
       FT_LOCAL_DEF( FT_Error )
    
    3316 3302
       TT_Set_Named_Instance( TT_Face  face,
    
    ... ... @@ -3320,6 +3306,8 @@
    3320 3306
         GX_Blend    blend;
    
    3321 3307
         FT_MM_Var*  mmvar;
    
    3322 3308
     
    
    3309
    +    FT_Memory  memory = face->root.memory;
    
    3310
    +
    
    3323 3311
         FT_UInt  num_instances;
    
    3324 3312
     
    
    3325 3313
     
    
    ... ... @@ -3343,8 +3331,7 @@
    3343 3331
     
    
    3344 3332
         if ( instance_index > 0 )
    
    3345 3333
         {
    
    3346
    -      FT_Memory     memory = face->root.memory;
    
    3347
    -      SFNT_Service  sfnt   = (SFNT_Service)face->sfnt;
    
    3334
    +      SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
    
    3348 3335
     
    
    3349 3336
           FT_Var_Named_Style*  named_style;
    
    3350 3337
           FT_String*           style_name;
    
    ... ... @@ -3366,26 +3353,73 @@
    3366 3353
           error = TT_Set_Var_Design( face,
    
    3367 3354
                                      mmvar->num_axis,
    
    3368 3355
                                      named_style->coords );
    
    3369
    -      if ( error )
    
    3370
    -      {
    
    3371
    -        /* internal error code -1 means `no change' */
    
    3372
    -        if ( error == -1 )
    
    3373
    -          error = FT_Err_Ok;
    
    3374
    -        goto Exit;
    
    3375
    -      }
    
    3376 3356
         }
    
    3377 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;
    
    3378 3363
           error = TT_Set_Var_Design( face, 0, NULL );
    
    3364
    +    }
    
    3379 3365
     
    
    3380
    -    face->root.face_index  = ( instance_index << 16 )             |
    
    3381
    -                             ( face->root.face_index & 0xFFFFL );
    
    3382
    -    face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    3366
    +  Exit:
    
    3367
    +    return error;
    
    3368
    +  }
    
    3369
    +
    
    3370
    +
    
    3371
    +  /**************************************************************************
    
    3372
    +   *
    
    3373
    +   * @Function:
    
    3374
    +   *   TT_Get_Default_Named_Instance
    
    3375
    +   *
    
    3376
    +   * @Description:
    
    3377
    +   *   Get the default named instance.
    
    3378
    +   *
    
    3379
    +   * @Input:
    
    3380
    +   *   face ::
    
    3381
    +   *     A handle to the source face.
    
    3382
    +   *
    
    3383
    +   * @Output:
    
    3384
    +   *   instance_index ::
    
    3385
    +   *     The default named instance index.
    
    3386
    +   *
    
    3387
    +   * @Return:
    
    3388
    +   *   FreeType error code.  0~means success.
    
    3389
    +   */
    
    3390
    +  FT_LOCAL_DEF( FT_Error )
    
    3391
    +  TT_Get_Default_Named_Instance( TT_Face   face,
    
    3392
    +                                 FT_UInt  *instance_index )
    
    3393
    +  {
    
    3394
    +    FT_Error  error = FT_Err_Ok;
    
    3395
    +
    
    3396
    +
    
    3397
    +    if ( !face->blend )
    
    3398
    +    {
    
    3399
    +      if ( FT_SET_ERROR( TT_Get_MM_Var( face, NULL ) ) )
    
    3400
    +        goto Exit;
    
    3401
    +    }
    
    3402
    +
    
    3403
    +    *instance_index = face->var_default_named_instance;
    
    3383 3404
     
    
    3384 3405
       Exit:
    
    3385 3406
         return error;
    
    3386 3407
       }
    
    3387 3408
     
    
    3388 3409
     
    
    3410
    +  /* This function triggers (lazy) recomputation of the `postscript_name` */
    
    3411
    +  /* field in `TT_Face`.                                                  */
    
    3412
    +
    
    3413
    +  FT_LOCAL_DEF( void )
    
    3414
    +  tt_construct_ps_name( TT_Face  face )
    
    3415
    +  {
    
    3416
    +    FT_Memory  memory = face->root.memory;
    
    3417
    +
    
    3418
    +
    
    3419
    +    FT_FREE( face->postscript_name );
    
    3420
    +  }
    
    3421
    +
    
    3422
    +
    
    3389 3423
       /*************************************************************************/
    
    3390 3424
       /*************************************************************************/
    
    3391 3425
       /*****                                                               *****/
    

  • src/truetype/ttgxvar.h
    ... ... @@ -374,6 +374,13 @@ FT_BEGIN_HEADER
    374 374
       TT_Set_Named_Instance( TT_Face  face,
    
    375 375
                              FT_UInt  instance_index );
    
    376 376
     
    
    377
    +  FT_LOCAL( FT_Error )
    
    378
    +  TT_Get_Default_Named_Instance( TT_Face   face,
    
    379
    +                                 FT_UInt  *instance_index );
    
    380
    +
    
    381
    +  FT_LOCAL( void )
    
    382
    +  tt_construct_ps_name( TT_Face  face );
    
    383
    +
    
    377 384
       FT_LOCAL( FT_Error )
    
    378 385
       tt_face_vary_cvt( TT_Face    face,
    
    379 386
                         FT_Stream  stream );
    
    ... ... @@ -397,7 +404,6 @@ FT_BEGIN_HEADER
    397 404
       FT_LOCAL( void )
    
    398 405
       tt_apply_mvar( TT_Face  face );
    
    399 406
     
    
    400
    -
    
    401 407
       FT_LOCAL( FT_Error )
    
    402 408
       tt_var_load_item_variation_store( TT_Face          face,
    
    403 409
                                         FT_ULong         offset,
    

  • src/truetype/ttobjs.c
    ... ... @@ -777,7 +777,6 @@
    777 777
         }
    
    778 778
     
    
    779 779
     #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
    
    780
    -
    
    781 780
         {
    
    782 781
           FT_UInt  instance_index = (FT_UInt)face_index >> 16;
    
    783 782
     
    
    ... ... @@ -785,14 +784,11 @@
    785 784
           if ( FT_HAS_MULTIPLE_MASTERS( ttface ) &&
    
    786 785
                instance_index > 0                )
    
    787 786
           {
    
    788
    -        error = TT_Set_Named_Instance( face, instance_index );
    
    787
    +        error = FT_Set_Named_Instance( ttface, instance_index );
    
    789 788
             if ( error )
    
    790 789
               goto Exit;
    
    791
    -
    
    792
    -        tt_apply_mvar( face );
    
    793 790
           }
    
    794 791
         }
    
    795
    -
    
    796 792
     #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
    
    797 793
     
    
    798 794
         /* initialize standard glyph loading routines */
    

  • src/type1/t1driver.c
    ... ... @@ -121,30 +121,36 @@
    121 121
     #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT
    
    122 122
       static const FT_Service_MultiMastersRec  t1_service_multi_masters =
    
    123 123
       {
    
    124
    -    (FT_Get_MM_Func)        T1_Get_Multi_Master,    /* get_mm                    */
    
    125
    -    (FT_Set_MM_Design_Func) T1_Set_MM_Design,       /* set_mm_design             */
    
    126
    -    (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,        /* set_mm_blend              */
    
    127
    -    (FT_Get_MM_Blend_Func)  T1_Get_MM_Blend,        /* get_mm_blend              */
    
    128
    -    (FT_Get_MM_Var_Func)    T1_Get_MM_Var,          /* get_mm_var                */
    
    129
    -    (FT_Set_Var_Design_Func)T1_Set_Var_Design,      /* set_var_design            */
    
    130
    -    (FT_Get_Var_Design_Func)T1_Get_Var_Design,      /* get_var_design            */
    
    131
    -    (FT_Set_Instance_Func)  T1_Reset_MM_Blend,      /* set_instance              */
    
    124
    +    (FT_Get_MM_Func)        T1_Get_Multi_Master,    /* get_mm                     */
    
    125
    +    (FT_Set_MM_Design_Func) T1_Set_MM_Design,       /* set_mm_design              */
    
    126
    +    (FT_Set_MM_Blend_Func)  T1_Set_MM_Blend,        /* set_mm_blend               */
    
    127
    +    (FT_Get_MM_Blend_Func)  T1_Get_MM_Blend,        /* get_mm_blend               */
    
    128
    +    (FT_Get_MM_Var_Func)    T1_Get_MM_Var,          /* get_mm_var                 */
    
    129
    +    (FT_Set_Var_Design_Func)T1_Set_Var_Design,      /* set_var_design             */
    
    130
    +    (FT_Get_Var_Design_Func)T1_Get_Var_Design,      /* get_var_design             */
    
    131
    +    (FT_Set_Named_Instance_Func)
    
    132
    +                            T1_Reset_MM_Blend,      /* set_named_instance         */
    
    133
    +    (FT_Get_Default_Named_Instance_Func)
    
    134
    +                            NULL,                   /* get_default_named_instance */
    
    132 135
         (FT_Set_MM_WeightVector_Func)
    
    133
    -                            T1_Set_MM_WeightVector, /* set_mm_weightvector       */
    
    136
    +                            T1_Set_MM_WeightVector, /* set_mm_weightvector        */
    
    134 137
         (FT_Get_MM_WeightVector_Func)
    
    135
    -                            T1_Get_MM_WeightVector, /* get_mm_weightvector       */
    
    138
    +                            T1_Get_MM_WeightVector, /* get_mm_weightvector        */
    
    139
    +
    
    140
    +    (FT_Construct_PS_Name_Func)
    
    141
    +                            NULL,                   /* construct_ps_name          */
    
    136 142
         (FT_Var_Load_Delta_Set_Idx_Map_Func)
    
    137
    -                            NULL,                   /* load_delta_set_idx_map    */
    
    143
    +                            NULL,                   /* load_delta_set_idx_map     */
    
    138 144
         (FT_Var_Load_Item_Var_Store_Func)
    
    139
    -                            NULL,                   /* load_item_variation_store */
    
    145
    +                            NULL,                   /* load_item_variation_store  */
    
    140 146
         (FT_Var_Get_Item_Delta_Func)
    
    141
    -                            NULL,                   /* get_item_delta            */
    
    147
    +                            NULL,                   /* get_item_delta             */
    
    142 148
         (FT_Var_Done_Item_Var_Store_Func)
    
    143
    -                            NULL,                   /* done_item_variation_store */
    
    149
    +                            NULL,                   /* done_item_variation_store  */
    
    144 150
         (FT_Var_Done_Delta_Set_Idx_Map_Func)
    
    145
    -                            NULL,                   /* done_delta_set_index_map  */
    
    146
    -    (FT_Get_Var_Blend_Func) NULL,                   /* get_var_blend             */
    
    147
    -    (FT_Done_Blend_Func)    T1_Done_Blend           /* done_blend                */
    
    151
    +                            NULL,                   /* done_delta_set_index_map   */
    
    152
    +    (FT_Get_Var_Blend_Func) NULL,                   /* get_var_blend              */
    
    153
    +    (FT_Done_Blend_Func)    T1_Done_Blend           /* done_blend                 */
    
    148 154
       };
    
    149 155
     #endif
    
    150 156
     
    

  • src/type1/t1load.c
    ... ... @@ -442,19 +442,7 @@
    442 442
                        FT_UInt    num_coords,
    
    443 443
                        FT_Fixed*  coords )
    
    444 444
       {
    
    445
    -    FT_Error  error;
    
    446
    -
    
    447
    -
    
    448
    -    error = t1_set_mm_blend( face, num_coords, coords );
    
    449
    -    if ( error )
    
    450
    -      return error;
    
    451
    -
    
    452
    -    if ( num_coords )
    
    453
    -      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
    
    454
    -    else
    
    455
    -      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    456
    -
    
    457
    -    return FT_Err_Ok;
    
    445
    +    return t1_set_mm_blend( face, num_coords, coords );
    
    458 446
       }
    
    459 447
     
    
    460 448
     
    
    ... ... @@ -522,11 +510,6 @@
    522 510
     
    
    523 511
           for ( ; i < blend->num_designs; i++ )
    
    524 512
             blend->weight_vector[i] = (FT_Fixed)0;
    
    525
    -
    
    526
    -      if ( len )
    
    527
    -        face->root.face_flags |= FT_FACE_FLAG_VARIATION;
    
    528
    -      else
    
    529
    -        face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    530 513
         }
    
    531 514
     
    
    532 515
         return FT_Err_Ok;
    
    ... ... @@ -638,11 +621,6 @@
    638 621
         if ( error )
    
    639 622
           return error;
    
    640 623
     
    
    641
    -    if ( num_coords )
    
    642
    -      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
    
    643
    -    else
    
    644
    -      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
    
    645
    -
    
    646 624
         return FT_Err_Ok;
    
    647 625
       }
    
    648 626
     
    


  • reply via email to

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