summaryrefslogtreecommitdiff
path: root/pango/pangocairo-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-12-22 02:43:58 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-12-22 02:43:58 +0000
commitde06bb288fb23a833e6813993f31248eee0680dd (patch)
tree14cf437b74f69c172ecf8bf90e274639391e3e26 /pango/pangocairo-font.c
parent254a11aefbd00a95e7a7e938b3044d171afe98df (diff)
parent9fe2853692bb64ded58a507d87508dc8536cd386 (diff)
downloadpango-de06bb288fb23a833e6813993f31248eee0680dd.tar.gz
Merge branch 'better-space-size' into 'main'
Add a private api to get the font size Closes #647 See merge request GNOME/pango!561
Diffstat (limited to 'pango/pangocairo-font.c')
-rw-r--r--pango/pangocairo-font.c43
1 files changed, 4 insertions, 39 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 02a976d8..5eb385d9 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -671,50 +671,15 @@ _pango_cairo_font_private_is_metrics_hinted (PangoCairoFontPrivate *cf_priv)
return cf_priv->is_hinted;
}
+
static void
get_space_extents (PangoCairoFontPrivate *cf_priv,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect)
{
- cairo_scaled_font_t *scaled_font;
- const char hexdigits[] = "0123456789ABCDEF";
- char c[2] = {0, 0};
- int i;
- double hex_width;
- int width;
- int n_chars;
-
- /* we don't render missing spaces as hex boxes,
- * so come up with some width to use. For lack
- * of anything better, use average hex digit width.
- */
-
- scaled_font = _pango_cairo_font_private_get_scaled_font (cf_priv);
- hex_width = 0;
- n_chars = 0;
- for (i = 0 ; i < 16 ; i++)
- {
- cairo_text_extents_t extents;
-
- c[0] = hexdigits[i];
- cairo_scaled_font_text_extents (scaled_font, c, &extents);
- if (extents.width > 0)
- {
- hex_width += extents.width;
- n_chars++;
- }
- }
-
- if (n_chars == 0)
- {
- cairo_font_extents_t extents;
-
- cairo_scaled_font_extents (scaled_font, &extents);
- hex_width += extents.max_x_advance;
- n_chars++;
- }
+ /* See https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace */
- width = pango_units_from_double (hex_width / n_chars);
+ int width = pango_font_get_absolute_size (PANGO_FONT (cf_priv->cfont)) / 2;
if (ink_rect)
{
@@ -934,7 +899,7 @@ _pango_cairo_font_private_get_glyph_extents (PangoCairoFontPrivate *cf_priv,
}
else if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
{
- _pango_cairo_font_private_get_glyph_extents_missing(cf_priv, glyph, ink_rect, logical_rect);
+ _pango_cairo_font_private_get_glyph_extents_missing (cf_priv, glyph, ink_rect, logical_rect);
return;
}