aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2017-01-21 18:10:08 -0800
committerBehdad Esfahbod <behdad@behdad.org>2017-01-21 18:10:08 -0800
commit47ee34e84745756a9aaeb964772377b6c1417ed1 (patch)
treeae04d6b53f192a2bf96f939512733f204489df65
parent111f3e55178f7cd5a8ae4e8ae111cb48aea4acb5 (diff)
downloadharfbuzz_ng-47ee34e84745756a9aaeb964772377b6c1417ed1.tar.gz
[var] Hook up variations to FreeType face
hb-view correctly renders variations with ft font-funcs now. hb-ot-font needs HVAR implementation.
-rw-r--r--src/hb-ft.cc10
-rw-r--r--util/helper-cairo.cc16
2 files changed, 25 insertions, 1 deletions
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index d5f8d5295..acb7bb1d0 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -736,6 +736,16 @@ hb_ft_font_set_funcs (hb_font_t *font)
FT_Set_Transform (ft_face, &matrix, NULL);
}
+ unsigned int num_coords;
+ int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
+ if (num_coords)
+ {
+ FT_Fixed ft_coords[num_coords];
+ for (unsigned int i = 0; i < num_coords; i++)
+ ft_coords[i] = coords[i] << 2;
+ FT_Set_Var_Blend_Coordinates (ft_face, num_coords, ft_coords);
+ }
+
ft_face->generic.data = blob;
ft_face->generic.finalizer = (FT_Generic_Finalizer) _release_blob;
diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc
index 8f30eea14..df5173b59 100644
--- a/util/helper-cairo.cc
+++ b/util/helper-cairo.cc
@@ -28,6 +28,7 @@
#include <cairo-ft.h>
#include <hb-ft.h>
+#include FT_MULTIPLE_MASTERS_H
#include "helper-cairo-ansi.hh"
#ifdef CAIRO_HAS_SVG_SURFACE
@@ -76,7 +77,8 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
cairo_font_face_t *cairo_face;
/* We cannot use the FT_Face from hb_font_t, as doing so will confuse hb_font_t because
- * cairo will reset the face size. As such, create new face... */
+ * cairo will reset the face size. As such, create new face...
+ * TODO Perhaps add API to hb-ft to encapsulate this code. */
FT_Face ft_face = NULL;//hb_ft_font_get_face (font);
if (!ft_face)
{
@@ -100,7 +102,19 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
CAIRO_FONT_WEIGHT_NORMAL);
}
else
+ {
+ unsigned int num_coords;
+ int *coords = hb_font_get_var_coords_normalized (font, &num_coords);
+ if (num_coords)
+ {
+ FT_Fixed ft_coords[num_coords];
+ for (unsigned int i = 0; i < num_coords; i++)
+ ft_coords[i] = coords[i] << 2;
+ FT_Set_Var_Blend_Coordinates (ft_face, num_coords, ft_coords);
+ }
+
cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+ }
cairo_matrix_t ctm, font_matrix;
cairo_font_options_t *font_options;