[gtk/small-text-fixes: 5/7] gsk: Add font options to the glyph cache
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/small-text-fixes: 5/7] gsk: Add font options to the glyph cache
- Date: Fri, 3 Sep 2021 15:45:48 +0000 (UTC)
commit 853b03ce14ce0b9d6c1a62ae902651b82b7c3b1b
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Aug 31 23:01:43 2021 -0400
gsk: Add font options to the glyph cache
The cairo_t that we create to render glyphs for
the glyph cache needs to match the font options
that are supposedly governing how glyphs are
drawn.
Since we allow font options to be different per
widget in gtk, we need to have them at least at
the level of individual render nodes. Adding them
to the lookup key for the glyph cache has the
side effect of solving another problem: We are
not flushing the cache when font options change.
gsk/ngl/gsknglglyphlibrary.c | 13 +++++++++++--
gsk/ngl/gsknglglyphlibraryprivate.h | 5 ++++-
2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/ngl/gsknglglyphlibrary.c
index 9f269d8643..891d2ab31c 100644
--- a/gsk/ngl/gsknglglyphlibrary.c
+++ b/gsk/ngl/gsknglglyphlibrary.c
@@ -162,15 +162,24 @@ static void
render_glyph (cairo_surface_t *surface,
const cairo_scaled_font_t *scaled_font,
const GskNglGlyphKey *key,
- const GskNglGlyphValue *value)
+ const GskNglGlyphValue *value,
+ double device_scale)
{
cairo_t *cr;
cairo_glyph_t glyph;
+ cairo_font_options_t *options;
g_assert (surface != NULL);
g_assert (scaled_font != NULL);
cr = cairo_create (surface);
+ options = cairo_font_options_create ();
+ cairo_font_options_set_hint_metrics (options, key->hint_metrics ? CAIRO_HINT_METRICS_ON :
CAIRO_HINT_METRICS_OFF);
+ cairo_font_options_set_antialias (options, key->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
+ cairo_font_options_set_hint_style (options, key->hint_style);
+ cairo_set_font_options (cr, options);
+ cairo_font_options_destroy (options);
+
cairo_set_scaled_font (cr, scaled_font);
cairo_set_source_rgba (cr, 1, 1, 1, 1);
@@ -221,7 +230,7 @@ gsk_ngl_glyph_library_upload_glyph (GskNglGlyphLibrary *self,
key->glyph);
surface = gsk_ngl_glyph_library_create_surface (self, stride, width, height, device_scale);
- render_glyph (surface, scaled_font, key, value);
+ render_glyph (surface, scaled_font, key, value, device_scale);
texture_id = GSK_NGL_TEXTURE_ATLAS_ENTRY_TEXTURE (value);
diff --git a/gsk/ngl/gsknglglyphlibraryprivate.h b/gsk/ngl/gsknglglyphlibraryprivate.h
index a9f099c0b5..6d9e81060e 100644
--- a/gsk/ngl/gsknglglyphlibraryprivate.h
+++ b/gsk/ngl/gsknglglyphlibraryprivate.h
@@ -35,7 +35,10 @@ typedef struct _GskNglGlyphKey
PangoGlyph glyph;
guint xshift : 2;
guint yshift : 2;
- guint scale : 28; /* times 1024 */
+ guint hint_metrics : 1;
+ guint antialias : 1;
+ guint hint_style : 3;
+ guint scale : 23; /* times 1024 */
} GskNglGlyphKey;
typedef struct _GskNglGlyphValue
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]