[pango/kill-ft-face: 5/15] fc: Make pangofc_shape backend-neutral
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/kill-ft-face: 5/15] fc: Make pangofc_shape backend-neutral
- Date: Wed, 10 Jul 2019 11:46:00 +0000 (UTC)
commit 7ec83581103fb1754cf7ef8d5bd0bff6a12884f0
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 19 13:59:26 2018 -0500
fc: Make pangofc_shape backend-neutral
Use typechecks for the two remaining bits of
code that use PangoFcFont.
pango/pangofc-shape.c | 159 +++++++++++++++++++++++---------------------------
1 file changed, 72 insertions(+), 87 deletions(-)
---
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 8e66ed3f..9123566b 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -79,7 +79,6 @@ _pango_fc_shape (PangoFont *font,
const char *paragraph_text,
unsigned int paragraph_length)
{
- PangoFcFont *fc_font;
hb_font_t *hb_font;
hb_buffer_t *hb_buffer;
hb_direction_t hb_direction;
@@ -118,58 +117,40 @@ _pango_fc_shape (PangoFont *font,
hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
- /* Setup features from fontconfig pattern. */
- fc_font = PANGO_FC_FONT (font);
- if (fc_font->font_pattern)
- {
- char *s;
- while (num_features < G_N_ELEMENTS (features) &&
- FcResultMatch == FcPatternGetString (fc_font->font_pattern,
- PANGO_FC_FONT_FEATURES,
- num_features,
- (FcChar8 **) &s))
- {
- gboolean ret = hb_feature_from_string (s, -1, &features[num_features]);
- features[num_features].start = 0;
- features[num_features].end = (unsigned int) -1;
- if (ret)
- num_features++;
- }
- }
+ pango_font_get_features (font, features, G_N_ELEMENTS (features), &num_features);
if (analysis->extra_attrs)
{
GSList *tmp_attrs;
for (tmp_attrs = analysis->extra_attrs; tmp_attrs && num_features < G_N_ELEMENTS (features); tmp_attrs
= tmp_attrs->next)
- {
- if (((PangoAttribute *) tmp_attrs->data)->klass->type == PANGO_ATTR_FONT_FEATURES)
- {
- const PangoAttrFontFeatures *fattr = (const PangoAttrFontFeatures *) tmp_attrs->data;
- const gchar *feat;
- const gchar *end;
+ {
+ if (((PangoAttribute *) tmp_attrs->data)->klass->type == PANGO_ATTR_FONT_FEATURES)
+ {
+ const PangoAttrFontFeatures *fattr = (const PangoAttrFontFeatures *) tmp_attrs->data;
+ const char *feat;
+ const char *end;
int len;
- feat = fattr->features;
-
+ feat = fattr->features;
while (feat != NULL && num_features < G_N_ELEMENTS (features))
- {
- end = strchr (feat, ',');
- if (end)
- len = end - feat;
- else
- len = -1;
-
- if (hb_feature_from_string (feat, len, &features[num_features]))
- num_features++;
-
- if (end == NULL)
- break;
-
- feat = end + 1;
- }
- }
- }
+ {
+ end = strchr (feat, ',');
+ if (end)
+ len = end - feat;
+ else
+ len = -1;
+
+ if (hb_feature_from_string (feat, len, &features[num_features]))
+ num_features++;
+
+ if (end == NULL)
+ break;
+
+ feat = end + 1;
+ }
+ }
+ }
}
hb_shape (hb_font, hb_buffer, features, num_features);
@@ -211,57 +192,61 @@ _pango_fc_shape (PangoFont *font,
hb_position++;
}
- if (fc_font->is_hinted)
- {
- double x_scale_inv, y_scale_inv;
- double x_scale, y_scale;
- PangoFcFontKey *key;
-
- x_scale_inv = y_scale_inv = 1.0;
- key = _pango_fc_font_get_font_key (fc_font);
- if (key)
- {
- const PangoMatrix *matrix = pango_fc_font_key_get_matrix (key);
- pango_matrix_get_font_scale_factors (matrix, &x_scale_inv, &y_scale_inv);
- }
- if (PANGO_GRAVITY_IS_IMPROPER (analysis->gravity))
- {
- x_scale_inv = -x_scale_inv;
- y_scale_inv = -y_scale_inv;
- }
- x_scale = 1. / x_scale_inv;
- y_scale = 1. / y_scale_inv;
-
- if (x_scale == 1.0 && y_scale == 1.0)
- {
- for (i = 0; i < num_glyphs; i++)
- infos[i].geometry.width = PANGO_UNITS_ROUND (infos[i].geometry.width);
- }
- else
- {
+ if (PANGO_IS_FC_FONT (font))
+ {
+ PangoFcFont *fc_font = PANGO_FC_FONT (font);
+ if (fc_font->is_hinted)
+ {
+ double x_scale_inv, y_scale_inv;
+ double x_scale, y_scale;
+ PangoFcFontKey *key;
+
+ x_scale_inv = y_scale_inv = 1.0;
+ key = _pango_fc_font_get_font_key (fc_font);
+ if (key)
+ {
+ const PangoMatrix *matrix = pango_fc_font_key_get_matrix (key);
+ pango_matrix_get_font_scale_factors (matrix, &x_scale_inv, &y_scale_inv);
+ }
+ if (PANGO_GRAVITY_IS_IMPROPER (analysis->gravity))
+ {
+ x_scale_inv = -x_scale_inv;
+ y_scale_inv = -y_scale_inv;
+ }
+ x_scale = 1. / x_scale_inv;
+ y_scale = 1. / y_scale_inv;
+
+ if (x_scale == 1.0 && y_scale == 1.0)
+ {
+ for (i = 0; i < num_glyphs; i++)
+ infos[i].geometry.width = PANGO_UNITS_ROUND (infos[i].geometry.width);
+ }
+ else
+ {
#if 0
- if (PANGO_GRAVITY_IS_VERTICAL (analysis->gravity))
- {
- /* XXX */
- double tmp = x_scale;
- x_scale = y_scale;
- y_scale = -tmp;
- }
+ if (PANGO_GRAVITY_IS_VERTICAL (analysis->gravity))
+ {
+ /* XXX */
+ double tmp = x_scale;
+ x_scale = y_scale;
+ y_scale = -tmp;
+ }
#endif
#define HINT(value, scale_inv, scale) (PANGO_UNITS_ROUND ((int) ((value) * scale)) * scale_inv)
#define HINT_X(value) HINT ((value), x_scale, x_scale_inv)
#define HINT_Y(value) HINT ((value), y_scale, y_scale_inv)
- for (i = 0; i < num_glyphs; i++)
- {
- infos[i].geometry.width = HINT_X (infos[i].geometry.width);
- infos[i].geometry.x_offset = HINT_X (infos[i].geometry.x_offset);
- infos[i].geometry.y_offset = HINT_Y (infos[i].geometry.y_offset);
- }
+ for (i = 0; i < num_glyphs; i++)
+ {
+ infos[i].geometry.width = HINT_X (infos[i].geometry.width);
+ infos[i].geometry.x_offset = HINT_X (infos[i].geometry.x_offset);
+ infos[i].geometry.y_offset = HINT_Y (infos[i].geometry.y_offset);
+ }
#undef HINT_Y
#undef HINT_X
#undef HINT
- }
- }
+ }
+ }
+ }
release_buffer (hb_buffer, free_buffer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]