[base, truetype] New function `FT_Get_Var_Axis_Flags'. The reserved `flags' field got a value in OpenType version 1.8.2; unfortunately, the public `FT_Var_Axis' structure misses the corresponding element. Since we can't add a new field, we add an access function. * src/base/ftmm.c (FT_Get_Var_Axis_Flags): New function. * include/freetype/ftmm.h (FT_VAR_AXIS_FLAG_HIDDEN): New macro. Updated. * src/truetype/ttgxvar.c (TT_Get_MM_Var): Increase allocated memory of `mmvar' to hold axis flags. Fill the axis flags array. * docs/CHANGES: Updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
diff --git a/ChangeLog b/ChangeLog
index 6243e18..30f18b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2017-08-05 Werner Lemberg <wl@gnu.org>
+
+ [base, truetype] New function `FT_Get_Var_Axis_Flags'.
+
+ The reserved `flags' field got a value in OpenType version 1.8.2;
+ unfortunately, the public `FT_Var_Axis' structure misses the
+ corresponding element. Since we can't add a new field, we add an
+ access function.
+
+ * src/base/ftmm.c (FT_Get_Var_Axis_Flags): New function.
+
+ * include/freetype/ftmm.h (FT_VAR_AXIS_FLAG_HIDDEN): New macro.
+ Updated.
+
+ * src/truetype/ttgxvar.c (TT_Get_MM_Var): Increase allocated memory
+ of `mmvar' to hold axis flags.
+ Fill the axis flags array.
+
+ * docs/CHANGES: Updated.
+
2017-08-03 Nikolaus Waxweiler <madigens@gmail.com>
[truetype] Fix metrics of B/W hinting in v40 mode.
diff --git a/docs/CHANGES b/docs/CHANGES
index cea3f27..a62aab7 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -12,6 +12,10 @@ CHANGES BETWEEN 2.8 and 2.8.1
II. MISCELLANEOUS
+ - Using the new function `FT_Get_Var_Axis_Flags', an application
+ can access the `flags' field of a variation axis (introduced in
+ OpenType version 1.8.2)
+
- More sanity checks.
diff --git a/include/freetype/ftmm.h b/include/freetype/ftmm.h
index b1bc1ed..b4c5941 100644
--- a/include/freetype/ftmm.h
+++ b/include/freetype/ftmm.h
@@ -196,7 +196,7 @@ FT_BEGIN_HEADER
/* FT_MM_Var */
/* */
/* <Description> */
- /* A structure to model the axes and space of a Adobe MM, TrueType */
+ /* A structure to model the axes and space of an Adobe MM, TrueType */
/* GX, or OpenType variation font. */
/* */
/* Some fields are specific to one format and not to the others. */
@@ -480,6 +480,50 @@ FT_BEGIN_HEADER
FT_UInt num_coords,
FT_Fixed* coords );
+
+ /*************************************************************************/
+ /* */
+ /* <Enum> */
+ /* FT_VAR_AXIS_FLAG_XXX */
+ /* */
+ /* <Description> */
+ /* A list of bit flags used in the return value of */
+ /* @FT_Get_Var_Axis_Flags. */
+ /* */
+ /* <Values> */
+ /* FT_VAR_AXIS_FLAG_HIDDEN :: */
+ /* The variation axis should not be exposed to user interfaces. */
+ /* */
+#define FT_VAR_AXIS_FLAG_HIDDEN 1
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Var_Axis_Flags */
+ /* */
+ /* <Description> */
+ /* Get the `flags' field of an OpenType Variation Axis Record. */
+ /* */
+ /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */
+ /* */
+ /* <Input> */
+ /* master :: The variation descriptor. */
+ /* */
+ /* axis_index :: The index of the requested variation axis. */
+ /* */
+ /* <Output> */
+ /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */
+ /* possible values. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0~means success. */
+ /* */
+ FT_EXPORT( FT_Error )
+ FT_Get_Var_Axis_Flags( FT_MM_Var* master,
+ FT_UInt axis_index,
+ FT_UInt* flags );
+
/* */
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 2cb56a3..c845008 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -402,4 +402,28 @@
}
+ /* documentation is in ftmm.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Get_Var_Axis_Flags( FT_MM_Var* master,
+ FT_UInt axis_index,
+ FT_UInt* flags )
+ {
+ FT_UShort* axis_flags;
+
+
+ if ( !master || !flags )
+ return FT_THROW( Invalid_Argument );
+
+ if ( axis_index >= master->num_axis )
+ return FT_THROW( Invalid_Argument );
+
+ /* the axis flags array immediately follows the data of `master' */
+ axis_flags = (FT_UShort*)&( master[1] );
+ *flags = axis_flags[axis_index];
+
+ return FT_Err_Ok;
+ }
+
+
/* END */
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 5a87df1..49aa53a 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -395,14 +395,14 @@
/* some macros we need */
- #define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
+#define FT_FIXED_ONE ( (FT_Fixed)0x10000 )
- #define FT_fdot14ToFixed( x ) \
- ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
- #define FT_intToFixed( i ) \
- ( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
- #define FT_fixedToInt( x ) \
- ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
+#define FT_fdot14ToFixed( x ) \
+ ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
+#define FT_intToFixed( i ) \
+ ( (FT_Fixed)( (FT_ULong)(i) << 16 ) )
+#define FT_fixedToInt( x ) \
+ ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
static FT_Error
@@ -1956,6 +1956,7 @@
GX_FVar_Head fvar_head;
FT_Bool usePsName;
FT_UInt num_instances;
+ FT_UShort* axis_flags;
static const FT_Frame_Field fvar_fields[] =
{
@@ -2041,14 +2042,16 @@
/* in fvar's table of named instances */
num_instances = face->root.style_flags >> 16;
- /* cannot overflow 32-bit arithmetic because of the size limits */
- /* used in the `fvar' table validity check in `sfnt_init_face' */
+ /* prepare storage area for MM data; this cannot overflow */
+ /* 32-bit arithmetic because of the size limits used in the */
+ /* `fvar' table validity check in `sfnt_init_face' */
face->blend->mmvar_len =
sizeof ( FT_MM_Var ) +
+ fvar_head.axisCount * sizeof ( FT_UShort ) +
fvar_head.axisCount * sizeof ( FT_Var_Axis ) +
num_instances * sizeof ( FT_Var_Named_Style ) +
num_instances * fvar_head.axisCount * sizeof ( FT_Fixed ) +
- 5 * fvar_head.axisCount;
+ fvar_head.axisCount * 5;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
@@ -2065,8 +2068,12 @@
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
num_instances;
+
+ /* alas, no public field in `FT_Var_Axis' for axis flags */
+ axis_flags =
+ (FT_UShort*)&( mmvar[1] );
mmvar->axis =
- (FT_Var_Axis*)&( mmvar[1] );
+ (FT_Var_Axis*)&( axis_flags[fvar_head.axisCount] );
mmvar->namedstyle =
(FT_Var_Named_Style*)&( mmvar->axis[fvar_head.axisCount] );
@@ -2110,6 +2117,8 @@
a->name[3] = (FT_String)( ( a->tag ) & 0xFF );
a->name[4] = '\0';
+ *axis_flags = axis_rec.flags;
+
if ( a->minimum > a->def ||
a->def > a->maximum )
{
@@ -2121,13 +2130,17 @@
a->maximum = a->def;
}
- FT_TRACE5(( " \"%s\": minimum=%.5f, default=%.5f, maximum=%.5f\n",
+ FT_TRACE5(( " \"%s\":"
+ " minimum=%.5f, default=%.5f, maximum=%.5f,"
+ " flags=0x%04X\n",
a->name,
a->minimum / 65536.0,
a->def / 65536.0,
- a->maximum / 65536.0 ));
+ a->maximum / 65536.0,
+ *axis_flags ));
a++;
+ axis_flags++;
}
FT_TRACE5(( "\n" ));
@@ -2244,13 +2257,15 @@
goto Exit;
FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
+ axis_flags =
+ (FT_UShort*)&( mmvar[1] );
mmvar->axis =
- (FT_Var_Axis*)&( mmvar[1] );
+ (FT_Var_Axis*)&( axis_flags[mmvar->num_axis] );
mmvar->namedstyle =
(FT_Var_Named_Style*)&( mmvar->axis[mmvar->num_axis] );
+
next_coords =
(FT_Fixed*)&( mmvar->namedstyle[mmvar->num_namedstyles] );
-
for ( n = 0; n < mmvar->num_namedstyles; n++ )
{
mmvar->namedstyle[n].coords = next_coords;