ref: 3bd79cc257499f1850a1bace21f3ae371e3b40f0
parent: aa0c4b4f55f88a489cf5f766c26ba0c285ac738a
author: Werner Lemberg <[email protected]>
date: Thu Dec 15 09:34:57 EST 2016
[truetype] Provide HVAR advance width variation as a service. Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT. * src/truetype/ttdriver.c (tt_service_metrics_variations): Updated. * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Prevent double adjustment of advance width. * src/sfnt/ttmtx.c: Include FT_SERVICE_METRICS_VARIATIONS_H. (tt_face_get_metrics): Apply metrics variations.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,25 @@
+2016-12-15 Werner Lemberg <[email protected]>
+ Dave Arnold <[email protected]>
+
+ [truetype] Provide HVAR advance width variation as a service.
+
+ Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
+
+ * src/truetype/ttdriver.c (tt_service_metrics_variations): Updated.
+
+ * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Prevent
+ double adjustment of advance width.
+
+ * src/sfnt/ttmtx.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
+ (tt_face_get_metrics): Apply metrics variations.
+
2016-12-15 Dave Arnold <[email protected]>
Werner Lemberg <[email protected]>
[truetype] Provide function to apply `HVAR' advance width variation.
+ Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
+
* src/truetype/ttgxvar.c (tt_hadvance_adjust): New function.
* src/truetype/ttgxvar.h: Updated.
@@ -15,6 +32,8 @@
variation.
Activation of the code follows in another commit.
+
+ Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.
* include/freetype/ftmm.h (FT_Var_Named_Style): Add `psid' member.
--- a/src/sfnt/ttmtx.c
+++ b/src/sfnt/ttmtx.c
@@ -20,6 +20,11 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+#include FT_SERVICE_METRICS_VARIATIONS_H
+#endif
+
#include "ttmtx.h"
#include "sferrors.h"
@@ -214,7 +219,12 @@
FT_ULong table_pos, table_size, table_end;
FT_UShort k;
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ FT_Service_MetricsVariations var =
+ (FT_Service_MetricsVariations)face->var;
+#endif
+
if ( vertical )
{
void* v = &face->vertical;
@@ -274,6 +284,34 @@
*abearing = 0;
*aadvance = 0;
}
+
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+ if ( var )
+ {
+ FT_Face f = FT_FACE( face );
+ FT_Int a = (FT_Int)*aadvance;
+ FT_Int b = (FT_Int)*abearing;
+
+
+ if ( vertical )
+ {
+ if ( var->vadvance_adjust )
+ var->vadvance_adjust( f, gindex, &a );
+ if ( var->tsb_adjust )
+ var->tsb_adjust( f, gindex, &b );
+ }
+ else
+ {
+ if ( var->hadvance_adjust )
+ var->hadvance_adjust( f, gindex, &a );
+ if ( var->lsb_adjust )
+ var->lsb_adjust( f, gindex, &b );
+ }
+
+ *aadvance = (FT_Short)a;
+ *abearing = (FT_UShort)b;
+ }
+#endif
}
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -484,7 +484,7 @@
FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
tt_service_metrics_variations,
- (FT_HAdvance_Adjust_Func)NULL, /* hadvance_adjust */
+ (FT_HAdvance_Adjust_Func)tt_hadvance_adjust, /* hadvance_adjust */
(FT_LSB_Adjust_Func) NULL, /* lsb_adjust */
(FT_RSB_Adjust_Func) NULL, /* rsb_adjust */
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -2629,7 +2629,13 @@
FT_Pos delta_y = FT_MulFix( deltas_y[j], apply );
- outline->points[j].x += delta_x;
+ /* Experimental fix for double adjustment of advance width: */
+ /* adjust phantom point 2 only if there's no HVAR. */
+ /* */
+ /* TODO: handle LSB (pp1) and VVAR (pp3, pp4) too */
+ if ( j != ( n_points - 3 ) || blend->hvar_checked == FALSE )
+ outline->points[j].x += delta_x;
+
outline->points[j].y += delta_y;
#ifdef FT_DEBUG_LEVEL_TRACE