summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-12-19 00:01:40 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-12-19 00:01:40 +0000
commit4620d50d7bfab138e230db7df38451473d8633b6 (patch)
tree4bd309696b9de135cb1998203532368c123cf06e
parent4eb4b83af55ed3a2b4f957d776885b5f543a435e (diff)
parent0fe60735873542a82974f271f44e8616220120fe (diff)
downloadpango-4620d50d7bfab138e230db7df38451473d8633b6.tar.gz
Merge branch 'misc-cleanups' into 'main'
pango-view: Support transforms with --serialized See merge request GNOME/pango!558
-rw-r--r--pango/fonts.c25
-rw-r--r--pango/pangofc-font.c3
-rw-r--r--pango/pangofc-font.h2
-rw-r--r--pango/pangofc-fontmap.c1
-rw-r--r--utils/viewer-render.c5
5 files changed, 33 insertions, 3 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index fd4dba21..35527e7a 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -2738,6 +2738,12 @@ pango_font_get_languages (PangoFont *font)
return pclass->get_languages (font);
}
+/*< private >
+ * pango_font_get_matrix:
+ * @font: a `PangoFont`
+ *
+ * Gets the matrix for the transformation from 'font space' to 'user space'.
+ */
void
pango_font_get_matrix (PangoFont *font,
PangoMatrix *matrix)
@@ -2747,12 +2753,31 @@ pango_font_get_matrix (PangoFont *font,
pclass->get_matrix (font, matrix);
}
+/*< private >
+ * pango_font_is_hinted:
+ * @font: a `PangoFont`
+ *
+ * Gets whether this font is hinted.
+ *
+ * Returns: %TRUE if @font is hinted
+ */
gboolean
pango_font_is_hinted (PangoFont *font)
{
return PANGO_FONT_GET_CLASS_PRIVATE (font)->is_hinted (font);
}
+/*< private >
+ * pango_font_get_scale_factors:
+ * @font: a `PangoFont`
+ * @x_scale: return location for X scale
+ * @y_scale: return location for Y scale
+ *
+ * Gets the font scale factors of the ctm for this font.
+ *
+ * The ctm is the matrix set on the context that this font was
+ * loaded for.
+ */
void
pango_font_get_scale_factors (PangoFont *font,
double *x_scale,
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index f29580c3..37400664 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -1117,8 +1117,9 @@ _pango_fc_font_get_scale_factors (PangoFont *font,
double *y_scale)
{
PangoFcFont *fcfont = PANGO_FC_FONT (font);
+ PangoFcFontPrivate *priv = fcfont->priv;
- pango_matrix_get_font_scale_factors (&fcfont->matrix, x_scale, y_scale);
+ pango_matrix_get_font_scale_factors (pango_fc_font_key_get_matrix (priv->key), x_scale, y_scale);
}
static void
diff --git a/pango/pangofc-font.h b/pango/pangofc-font.h
index 89b0cc79..25361fa0 100644
--- a/pango/pangofc-font.h
+++ b/pango/pangofc-font.h
@@ -75,7 +75,7 @@ struct _PangoFcFont
FcPattern *font_pattern; /* fully resolved pattern */
PangoFontMap *fontmap; /* associated map */
gpointer priv; /* used internally */
- PangoMatrix matrix; /* used internally */
+ PangoMatrix matrix; /* unused */
PangoFontDescription *description;
GSList *metrics_by_lang;
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 0cfe5de8..d198df45 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -2013,7 +2013,6 @@ pango_fc_font_map_new_font (PangoFcFontMap *fcfontmap,
if (!fcfont)
return NULL;
- fcfont->matrix = key.matrix;
/* In case the backend didn't set the fontmap */
if (!fcfont->fontmap)
g_object_set (fcfont,
diff --git a/utils/viewer-render.c b/utils/viewer-render.c
index 87b27829..8816f06f 100644
--- a/utils/viewer-render.c
+++ b/utils/viewer-render.c
@@ -373,6 +373,11 @@ do_output (PangoContext *context,
pango_context_set_gravity_hint (context, opt_gravity_hint);
layout = make_layout (context, text, -1);
+ if (opt_serialized && supports_matrix)
+ {
+ const PangoMatrix *context_matrix = pango_context_get_matrix (pango_layout_get_context (layout));
+ matrix = context_matrix ? *context_matrix : (PangoMatrix) PANGO_MATRIX_INIT;
+ }
set_transform (context, transform_cb, cb_context, cb_data, &matrix);