summaryrefslogtreecommitdiff
path: root/pango/pangocairo-fcfont.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-09-05 07:37:31 -0400
committerBehdad Esfahbod <behdad@behdad.org>2018-01-03 12:41:46 +0000
commitefa66e7b634050ef395418b544b012a4a5183973 (patch)
tree4823301a56e843fb864b7e25b8aef5f530e51f2d /pango/pangocairo-fcfont.c
parent95c2aaaa9a1f0167e832a3d31700ae51e519fff4 (diff)
downloadpango-efa66e7b634050ef395418b544b012a4a5183973.tar.gz
Add initial support for OpenType font variations
This commit lets PangoFontDescription carry font variation information as a string. Only pangocairo has been updated to make use of this information. We pass it to harfbuzz for shaping, and we pass it to cairo when creating scaled fonts.
Diffstat (limited to 'pango/pangocairo-fcfont.c')
-rw-r--r--pango/pangocairo-fcfont.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 30ecde4d..ef4273e7 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -33,6 +33,9 @@
#include "pangofc-private.h"
#include "pango-impl-utils.h"
+#include <hb-ot.h>
+#include <freetype/ftmm.h>
+
#define PANGO_TYPE_CAIRO_FC_FONT (pango_cairo_fc_font_get_type ())
#define PANGO_CAIRO_FC_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_CAIRO_FC_FONT, PangoCairoFcFont))
#define PANGO_CAIRO_FC_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_CAIRO_FC_FONT, PangoCairoFcFontClass))
@@ -222,6 +225,8 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap,
FcMatrix fc_matrix, *fc_matrix_val;
double size;
int i;
+ cairo_font_options_t *options;
+ const char *variations;
g_return_val_if_fail (PANGO_IS_CAIRO_FC_FONT_MAP (cffontmap), NULL);
g_return_val_if_fail (pattern != NULL, NULL);
@@ -247,13 +252,23 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap,
cairo_matrix_scale (&font_matrix, size, size);
+ options = pango_fc_font_key_get_context_key (key);
+ variations = pango_fc_font_key_get_variations (key);
+ if (variations) {
+ options = cairo_font_options_copy (options);
+ cairo_font_options_set_variations (options, variations);
+ }
+
_pango_cairo_font_private_initialize (&cffont->cf_priv,
(PangoCairoFont *) cffont,
get_gravity (pattern),
- pango_fc_font_key_get_context_key (key),
+ options,
pango_fc_font_key_get_matrix (key),
&font_matrix);
+ if (variations)
+ cairo_font_options_destroy (options);
+
((PangoFcFont *)(cffont))->is_hinted = _pango_cairo_font_private_is_metrics_hinted (&cffont->cf_priv);
return (PangoFcFont *) cffont;