freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master 8c92f76 5/8: Make `FT_FACE_FLAG_VARIATION' work.


From: Werner LEMBERG
Subject: [freetype2] master 8c92f76 5/8: Make `FT_FACE_FLAG_VARIATION' work.
Date: Sat, 7 Oct 2017 07:46:28 -0400 (EDT)

branch: master
commit 8c92f7622cdf1e2a0354a818f67edfaa92e4cced
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    Make `FT_FACE_FLAG_VARIATION' work.
    
    * include/freetype/internal/tttypes.h (TT_Face): Remove
    `is_default_instance'; this can be replaced with a combination of
    `FT_IS_VARIATION' and `FT_IS_INSTANCE'.
    
    * src/cff/cffdrivr.c (cff_get_advances): Updated.
    
    * src/sfnt/sfdriver.c (sfnt_get_ps_name), src/sfnt/sfobjs.c
    (sfnt_init_face): Updated.
    
    * src/truetype/ttdriver.c (tt_get_advances), src/truetype/ttgload.c
    (TT_Process_Simple_Glyph, load_truetype_glyph, IS_DEFAULT_INSTANCE),
    src/truetype/ttgxvar.c (tt_set_mm_blend): Updated.
    * src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design):
    Handle `FT_FACE_FLAG_VARIATION'.
    
    * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Handle
    `FT_FACE_FLAG_VARIATION'.
---
 ChangeLog                           | 22 ++++++++++++++++++++++
 include/freetype/internal/tttypes.h |  5 -----
 src/cff/cffdrivr.c                  |  8 ++++----
 src/sfnt/sfdriver.c                 |  4 +++-
 src/sfnt/sfobjs.c                   |  2 --
 src/truetype/ttdriver.c             |  8 ++++----
 src/truetype/ttgload.c              | 12 ++++++++----
 src/truetype/ttgxvar.c              | 29 +++++++++++++++++++++--------
 src/type1/t1load.c                  | 26 ++++++++++++++++++++++++--
 9 files changed, 86 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0d8d006..1bdfbe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 2017-10-07  Werner Lemberg  <address@hidden>
 
+       Make `FT_FACE_FLAG_VARIATION' work.
+
+       * include/freetype/internal/tttypes.h (TT_Face): Remove
+       `is_default_instance'; this can be replaced with a combination of
+       `FT_IS_VARIATION' and `FT_IS_INSTANCE'.
+
+       * src/cff/cffdrivr.c (cff_get_advances): Updated.
+
+       * src/sfnt/sfdriver.c (sfnt_get_ps_name), src/sfnt/sfobjs.c
+       (sfnt_init_face): Updated.
+
+       * src/truetype/ttdriver.c (tt_get_advances), src/truetype/ttgload.c
+       (TT_Process_Simple_Glyph, load_truetype_glyph, IS_DEFAULT_INSTANCE),
+       src/truetype/ttgxvar.c (tt_set_mm_blend): Updated.
+       * src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design):
+       Handle `FT_FACE_FLAG_VARIATION'.
+
+       * src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Handle
+       `FT_FACE_FLAG_VARIATION'.
+
+2017-10-07  Werner Lemberg  <address@hidden>
+
        New function `FT_Set_Named_Instance'.
 
        No effect yet.
diff --git a/include/freetype/internal/tttypes.h 
b/include/freetype/internal/tttypes.h
index 0fcc6b0..3bc6c98 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1299,10 +1299,6 @@ FT_BEGIN_HEADER
   /*                            variation tables (rather like Multiple     */
   /*                            Master data).                              */
   /*                                                                       */
-  /*    is_default_instance  :: Set if the glyph outlines can be used      */
-  /*                            unmodified (i.e., without applying glyph   */
-  /*                            variation deltas).                         */
-  /*                                                                       */
   /*    variation_support    :: Flags that indicate which OpenType         */
   /*                            functionality related to font variation    */
   /*                            support is present, valid, and usable.     */
@@ -1512,7 +1508,6 @@ FT_BEGIN_HEADER
     FT_Bool               doblend;
     GX_Blend              blend;
 
-    FT_Bool               is_default_instance;   /* since 2.7.1 */
     FT_UInt32             variation_support;     /* since 2.7.1 */
 
     const char*           var_postscript_prefix;     /* since 2.7.2 */
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 3cecbc0..032ce37 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -217,8 +217,8 @@
       {
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
         /* no fast retrieval for blended MM fonts without VVAR table */
-        if ( !ttface->is_default_instance                               &&
-             !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
+        if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+             !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE )  )
           return FT_THROW( Unimplemented_Feature );
 #endif
 
@@ -249,8 +249,8 @@
       {
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
         /* no fast retrieval for blended MM fonts without HVAR table */
-        if ( !ttface->is_default_instance                               &&
-             !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
+        if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) &&
+             !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE )  )
           return FT_THROW( Unimplemented_Feature );
 #endif
 
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index b4f0842..fc4eaf7 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -1029,7 +1029,9 @@
       return face->postscript_name;
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-    if ( face->blend && !face->is_default_instance )
+    if ( face->blend                                 &&
+         ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+           FT_IS_VARIATION( FT_FACE( face ) )      ) )
     {
       face->postscript_name = sfnt_get_var_ps_name( face );
       return face->postscript_name;
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 69bf0a5..1764807 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -962,8 +962,6 @@
       FT_Byte*  instance_values = NULL;
 
 
-      face->is_default_instance = 1;
-
       instance_index = FT_ABS( face_instance_index ) >> 16;
 
       /* test whether current face is a GX font with named instances */
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index 22bb872..af36481 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -233,8 +233,8 @@
     {
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
       /* no fast retrieval for blended MM fonts without VVAR table */
-      if ( !face->is_default_instance                               &&
-           !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) )
+      if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
+           !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE )        )
         return FT_THROW( Unimplemented_Feature );
 #endif
 
@@ -253,8 +253,8 @@
     {
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
       /* no fast retrieval for blended MM fonts without HVAR table */
-      if ( !face->is_default_instance                               &&
-           !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) )
+      if ( ( FT_IS_NAMED_INSTANCE( ttface ) || FT_IS_VARIATION( ttface ) ) &&
+           !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE )        )
         return FT_THROW( Unimplemented_Feature );
 #endif
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 5e102c6..94ba256 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -889,7 +889,8 @@
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 
-    if ( !loader->face->is_default_instance )
+    if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) ||
+         FT_IS_VARIATION( FT_FACE( loader->face ) )      )
     {
       /* Deltas apply to the unscaled data. */
       error = TT_Vary_Apply_Glyph_Deltas( loader->face,
@@ -1577,7 +1578,8 @@
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 
-      if ( !loader->face->is_default_instance )
+      if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+           FT_IS_VARIATION( FT_FACE( face ) )      )
       {
         /* a small outline structure with four elements for */
         /* communication with `TT_Vary_Apply_Glyph_Deltas'  */
@@ -1751,7 +1753,8 @@
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
 
-      if ( !face->is_default_instance )
+      if ( FT_IS_NAMED_INSTANCE( FT_FACE( face ) ) ||
+           FT_IS_VARIATION( FT_FACE( face ) )      )
       {
         short        i, limit;
         FT_SubGlyph  subglyph;
@@ -2609,7 +2612,8 @@
     TT_LoaderRec  loader;
 
 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-#define IS_DEFAULT_INSTANCE  ( ( (TT_Face)glyph->face )->is_default_instance )
+#define IS_DEFAULT_INSTANCE  ( !( FT_IS_NAMED_INSTANCE( glyph->face ) ||  \
+                                  FT_IS_VARIATION( glyph->face )      ) )
 #else
 #define IS_DEFAULT_INSTANCE  1
 #endif
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 461b230..d2365ac 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2350,8 +2350,7 @@
     FT_MM_Var*  mmvar;
     FT_UInt     i, j;
 
-    FT_Bool     is_default_instance = TRUE;
-    FT_Bool     all_design_coords   = FALSE;
+    FT_Bool     all_design_coords = FALSE;
 
     FT_Memory   memory = face->root.memory;
 
@@ -2396,9 +2395,6 @@
         error = FT_THROW( Invalid_Argument );
         goto Exit;
       }
-
-      if ( coords[i] != 0 )
-        is_default_instance = FALSE;
     }
 
     FT_TRACE5(( "\n" ));
@@ -2517,8 +2513,6 @@
     if ( i < blend->mmvar->num_namedstyles )
       face->root.face_index |= ( i + 1 ) << 16;
 
-    face->is_default_instance = is_default_instance;
-
     /* enforce recomputation of the PostScript name; */
     FT_FREE( face->postscript_name );
     face->postscript_name = NULL;
@@ -2558,7 +2552,19 @@
                    FT_UInt    num_coords,
                    FT_Fixed*  coords )
   {
-    return tt_set_mm_blend( face, num_coords, coords, 1 );
+    FT_Error  error;
+
+
+    error = tt_set_mm_blend( face, num_coords, coords, 1 );
+    if ( error )
+      return error;
+
+    if ( num_coords )
+      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+    else
+      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+    return FT_Err_Ok;
   }
 
 
@@ -2721,6 +2727,13 @@
     ft_var_to_normalized( face, num_coords, blend->coords, normalized );
 
     error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 );
+    if ( error )
+      goto Exit;
+
+    if ( num_coords )
+      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+    else
+      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
 
   Exit:
     FT_FREE( normalized );
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 54c8b60..8ac3810 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -417,7 +417,19 @@
                    FT_UInt    num_coords,
                    FT_Fixed*  coords )
   {
-    return t1_set_mm_blend( face, num_coords, coords );
+    FT_Error  error;
+
+
+    error = t1_set_mm_blend( face, num_coords, coords );
+    if ( error )
+      return error;
+
+    if ( num_coords )
+      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+    else
+      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+    return FT_Err_Ok;
   }
 
 
@@ -461,6 +473,7 @@
                     FT_UInt   num_coords,
                     FT_Long*  coords )
   {
+    FT_Error  error;
     PS_Blend  blend = face->blend;
     FT_UInt   n, p;
     FT_Fixed  final_blends[T1_MAX_MM_DESIGNS];
@@ -527,7 +540,16 @@
       final_blends[n] = the_blend;
     }
 
-    return t1_set_mm_blend( face, blend->num_axis, final_blends );
+    error = t1_set_mm_blend( face, blend->num_axis, final_blends );
+    if ( error )
+      return error;
+
+    if ( num_coords )
+      face->root.face_flags |= FT_FACE_FLAG_VARIATION;
+    else
+      face->root.face_flags &= ~FT_FACE_FLAG_VARIATION;
+
+    return FT_Err_Ok;
   }
 
 



reply via email to

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