summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-26 14:34:21 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-11-26 14:34:21 +0000
commit84ff272ea04a3f2a142d89e583bda066428ac6f7 (patch)
treee021a13baac075c3685b39a41db1f25a762b8464 /pango
parentf37d293b9cfcc43def6fe4be0483b898774e5a2f (diff)
parent8c51a367c7bcaf8c84f04ddee7651aedbfd8909b (diff)
downloadpango-84ff272ea04a3f2a142d89e583bda066428ac6f7.tar.gz
Merge branch 'hinted-metrics-fixes' into 'main'
Hinted metrics fixes Closes #626 See merge request GNOME/pango!518
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-types.h26
-rw-r--r--pango/pangocairo-font.c8
2 files changed, 30 insertions, 4 deletions
diff --git a/pango/pango-types.h b/pango/pango-types.h
index f18225ba..ed86f699 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -107,6 +107,32 @@ typedef guint32 PangoGlyph;
*/
/**
+ * PANGO_UNITS_FLOOR:
+ * @d: a dimension in Pango units.
+ *
+ * Rounds a dimension down to whole device units, but does not
+ * convert it to device units.
+ *
+ * Return value: rounded down dimension in Pango units.
+ * Since: 1.50
+ */
+#define PANGO_UNITS_FLOOR(d) \
+ ((d) & ~(PANGO_SCALE - 1))
+
+/**
+ * PANGO_UNITS_CEIL:
+ * @d: a dimension in Pango units.
+ *
+ * Rounds a dimension up to whole device units, but does not
+ * convert it to device units.
+ *
+ * Return value: rounded up dimension in Pango units.
+ * Since: 1.50
+ */
+#define PANGO_UNITS_CEIL(d) \
+ (((d) + (PANGO_SCALE - 1)) & ~(PANGO_SCALE - 1))
+
+/**
* PANGO_UNITS_ROUND:
* @d: a dimension in Pango units.
*
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 597a320d..c2bcc51b 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -817,13 +817,13 @@ _pango_cairo_font_private_glyph_extents_cache_init (PangoCairoFontPrivate *cf_pr
if (cf_priv->is_hinted)
{
if (cf_priv->font_extents.y < 0)
- cf_priv->font_extents.y = PANGO_UNITS_ROUND (cf_priv->font_extents.y - PANGO_SCALE/2);
+ cf_priv->font_extents.y = PANGO_UNITS_FLOOR (cf_priv->font_extents.y);
else
- cf_priv->font_extents.y = PANGO_UNITS_ROUND (cf_priv->font_extents.y + PANGO_SCALE/2);
+ cf_priv->font_extents.y = PANGO_UNITS_CEIL (cf_priv->font_extents.y);
if (cf_priv->font_extents.height < 0)
- cf_priv->font_extents.height = PANGO_UNITS_ROUND (cf_priv->font_extents.height - PANGO_SCALE/2);
+ cf_priv->font_extents.height = PANGO_UNITS_FLOOR (extents.ascender) - PANGO_UNITS_CEIL (extents.descender);
else
- cf_priv->font_extents.height = PANGO_UNITS_ROUND (cf_priv->font_extents.height + PANGO_SCALE/2);
+ cf_priv->font_extents.height = PANGO_UNITS_CEIL (extents.ascender) - PANGO_UNITS_FLOOR (extents.descender);
}
if (PANGO_GRAVITY_IS_IMPROPER (cf_priv->gravity))