[truetype] Again some GX code shuffling. We need this later on for MVAR also. * src/truetype/ttgxvar.c (tt_hadvance_adjust): Split off computing an item store variation delta into... (ft_var_get_item_delta): ...new function.
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
diff --git a/ChangeLog b/ChangeLog
index ae04c26..d9811d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2017-01-08 Werner Lemberg <wl@gnu.org>
+ [truetype] Again some GX code shuffling.
+
+ We need this later on for MVAR also.
+
+ * src/truetype/ttgxvar.c (tt_hadvance_adjust): Split off computing
+ an item store variation delta into...
+ (ft_var_get_item_delta): ...new function.
+
+2017-01-08 Werner Lemberg <wl@gnu.org>
+
[truetype] Adjust font variation flags for MVAR.
* include/freetype/internal/tttypes.h (TT_FACE_FLAG_VAR_XXX):
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 40176ca..b012871 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -795,110 +795,38 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* tt_hadvance_adjust */
- /* */
- /* <Description> */
- /* Apply HVAR advance width adjustment of a given glyph. */
- /* */
- /* <Input> */
- /* gindex :: The glyph index. */
- /* */
- /* <InOut> */
- /* face :: The font face. */
- /* */
- /* adelta :: Points to width value that gets modified. */
- /* */
- FT_LOCAL_DEF( FT_Error )
- tt_hadvance_adjust( TT_Face face,
- FT_UInt gindex,
- FT_Int *avalue )
+ static FT_Int
+ ft_var_get_item_delta( TT_Face face,
+ GX_ItemVarStore itemStore,
+ FT_UInt outerIndex,
+ FT_UInt innerIndex )
{
- FT_Error error = FT_Err_Ok;
-
GX_ItemVarData varData;
+ FT_Short* deltaSet;
- FT_UInt master, j;
- FT_Fixed netAdjustment = 0; /* accumulated adjustment */
- FT_Fixed scaledDelta;
- FT_Short* deltaSet;
- FT_Fixed delta;
-
+ FT_UInt master, j;
+ FT_Fixed netAdjustment = 0; /* accumulated adjustment */
+ FT_Fixed scaledDelta;
+ FT_Fixed delta;
- if ( !face->doblend || !face->blend )
- goto Exit;
-
- if ( !face->blend->hvar_loaded )
- {
- /* initialize hvar table */
- face->blend->hvar_error = ft_var_load_hvar( face );
- }
-
- if ( !face->blend->hvar_checked )
- {
- error = face->blend->hvar_error;
- goto Exit;
- }
-
- /* advance width adjustments are always present in an `HVAR' table, */
- /* so need to test for this capability */
-
- if ( face->blend->hvar_table->widthMap.innerIndex )
- {
- FT_UInt innerIndex, outerIndex;
-
-
- if ( gindex >= face->blend->hvar_table->widthMap.mapCount )
- {
- FT_TRACE2(( "gindex %d out of range\n", gindex ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- /* trust that HVAR parser has checked indices */
- outerIndex = face->blend->hvar_table->widthMap.outerIndex[gindex];
- innerIndex = face->blend->hvar_table->widthMap.innerIndex[gindex];
- varData = &face->blend->hvar_table->itemStore.varData[outerIndex];
- deltaSet = &varData->deltaSet[varData->regionIdxCount * innerIndex];
- }
- else
- {
- /* no widthMap data; use glyph index as inner index instead */
- /* (and value 0 for outer index) */
-
- varData = &face->blend->hvar_table->itemStore.varData[0];
-
- if ( gindex >= varData->itemCount )
- {
- FT_TRACE2(( "gindex %d out of range\n", gindex ));
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- deltaSet = &varData->deltaSet[varData->regionIdxCount * gindex];
- }
/* See pseudo code from `Font Variations Overview' */
/* in the OpenType specification. */
+ varData = &itemStore->varData[outerIndex];
+ deltaSet = &varData->deltaSet[varData->regionIdxCount * innerIndex];
+
/* outer loop steps through master designs to be blended */
for ( master = 0; master < varData->regionIdxCount; master++ )
{
FT_Fixed scalar = FT_FIXED_ONE;
FT_UInt regionIndex = varData->regionIndices[master];
- GX_AxisCoords axis = face->blend
- ->hvar_table
- ->itemStore.varRegionList[regionIndex]
- .axisList;
+ GX_AxisCoords axis = itemStore->varRegionList[regionIndex].axisList;
/* inner loop steps through axes in this region */
- for ( j = 0;
- j < face->blend->hvar_table->itemStore.axisCount;
- j++, axis++ )
+ for ( j = 0; j < itemStore->axisCount; j++, axis++ )
{
FT_Fixed axisScalar;
@@ -952,12 +880,96 @@
} /* per-region loop */
+ return FT_fixedToInt( netAdjustment );
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* tt_hadvance_adjust */
+ /* */
+ /* <Description> */
+ /* Apply HVAR advance width adjustment of a given glyph. */
+ /* */
+ /* <Input> */
+ /* gindex :: The glyph index. */
+ /* */
+ /* <InOut> */
+ /* face :: The font face. */
+ /* */
+ /* adelta :: Points to width value that gets modified. */
+ /* */
+ FT_LOCAL_DEF( FT_Error )
+ tt_hadvance_adjust( TT_Face face,
+ FT_UInt gindex,
+ FT_Int *avalue )
+ {
+ FT_Error error = FT_Err_Ok;
+ FT_UInt innerIndex, outerIndex;
+ FT_Int delta;
+
+
+ if ( !face->doblend || !face->blend )
+ goto Exit;
+
+ if ( !face->blend->hvar_loaded )
+ {
+ /* initialize hvar table */
+ face->blend->hvar_error = ft_var_load_hvar( face );
+ }
+
+ if ( !face->blend->hvar_checked )
+ {
+ error = face->blend->hvar_error;
+ goto Exit;
+ }
+
+ /* advance width adjustments are always present in an `HVAR' table, */
+ /* so need to test for this capability */
+
+ if ( face->blend->hvar_table->widthMap.innerIndex )
+ {
+ if ( gindex >= face->blend->hvar_table->widthMap.mapCount )
+ {
+ FT_TRACE2(( "gindex %d out of range\n", gindex ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+
+ /* trust that HVAR parser has checked indices */
+ outerIndex = face->blend->hvar_table->widthMap.outerIndex[gindex];
+ innerIndex = face->blend->hvar_table->widthMap.innerIndex[gindex];
+ }
+ else
+ {
+ GX_ItemVarData varData;
+
+
+ /* no widthMap data */
+ outerIndex = 0;
+ innerIndex = gindex;
+
+ varData = &face->blend->hvar_table->itemStore.varData[outerIndex];
+ if ( gindex >= varData->itemCount )
+ {
+ FT_TRACE2(( "gindex %d out of range\n", gindex ));
+ error = FT_THROW( Invalid_Argument );
+ goto Exit;
+ }
+ }
+
+ delta = ft_var_get_item_delta( face,
+ &face->blend->hvar_table->itemStore,
+ outerIndex,
+ innerIndex );
+
/* apply the accumulated adjustment to derive the interpolated value */
FT_TRACE5(( "horizontal width %d adjusted by %d units (HVAR)\n",
*avalue,
- FT_fixedToInt( netAdjustment ) ));
+ delta ));
- *avalue += FT_fixedToInt( netAdjustment );
+ *avalue += delta;
Exit:
return error;