summaryrefslogtreecommitdiff
path: root/pango/pangocairo-fcfont.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-09-30 17:08:29 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-10-19 15:14:53 -0400
commitf178bb42d3622b3144bc30d5c5d99c884eee0455 (patch)
tree1b26218e65b368d71f74b05dc3fd943be97b696f /pango/pangocairo-fcfont.c
parent20967565edabb728b3826ff1501a8081d6e322ad (diff)
downloadpango-f178bb42d3622b3144bc30d5c5d99c884eee0455.tar.gz
pangocairo: Round font metrics when appropriate
When metrics hinting is on, we used to provide rounded font metrics. We should keep doing that since otherwise we end up with logical rects sometimes being rounded and sometimes not, leading to jumping empty lines. Test included. Fixes: #421
Diffstat (limited to 'pango/pangocairo-fcfont.c')
-rw-r--r--pango/pangocairo-fcfont.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 0019f83a..85cc45c8 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -76,8 +76,20 @@ pango_cairo_fc_font_create_base_metrics_for_context (PangoCairoFont *cfont,
PangoContext *context)
{
PangoFcFont *fcfont = (PangoFcFont *) (cfont);
+ PangoFontMetrics *metrics;
+ const cairo_font_options_t *options;
- return pango_fc_font_create_base_metrics_for_context (fcfont, context);
+ metrics = pango_fc_font_create_base_metrics_for_context (fcfont, context);
+
+ options = pango_cairo_context_get_font_options (context);
+ if (cairo_font_options_get_hint_metrics (options) == CAIRO_HINT_METRICS_ON)
+ {
+ metrics->ascent = PANGO_PIXELS_CEIL (metrics->ascent) * PANGO_SCALE;
+ metrics->descent = PANGO_PIXELS_CEIL (metrics->descent) * PANGO_SCALE;
+ metrics->height = PANGO_PIXELS_CEIL (metrics->height) * PANGO_SCALE;
+ }
+
+ return metrics;
}
static void