[gtk/glyph-cache-mystery: 16/16] ngl: Bypass pango for glyph cache rendering




commit ed41c4692609bb140cb4c1f4b458ef113fd23e7a
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 30 13:51:02 2021 -0400

    ngl: Bypass pango for glyph cache rendering
    
    We can just use cairo directly here,
    and cut out some layers of pango in the middle.

 gsk/ngl/gsknglglyphlibrary.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/gsk/ngl/gsknglglyphlibrary.c b/gsk/ngl/gsknglglyphlibrary.c
index 627f35f59e..9f269d8643 100644
--- a/gsk/ngl/gsknglglyphlibrary.c
+++ b/gsk/ngl/gsknglglyphlibrary.c
@@ -165,8 +165,7 @@ render_glyph (cairo_surface_t           *surface,
               const GskNglGlyphValue    *value)
 {
   cairo_t *cr;
-  PangoGlyphString glyph_string;
-  PangoGlyphInfo glyph_info;
+  cairo_glyph_t glyph;
 
   g_assert (surface != NULL);
   g_assert (scaled_font != NULL);
@@ -175,18 +174,11 @@ render_glyph (cairo_surface_t           *surface,
   cairo_set_scaled_font (cr, scaled_font);
   cairo_set_source_rgba (cr, 1, 1, 1, 1);
 
-  glyph_info.glyph = key->glyph;
-  glyph_info.geometry.width = value->ink_rect.width * 1024;
-  if (glyph_info.glyph & PANGO_GLYPH_UNKNOWN_FLAG)
-    glyph_info.geometry.x_offset = 256 * key->xshift;
-  else
-    glyph_info.geometry.x_offset = 256 * key->xshift - value->ink_rect.x * 1024;
-  glyph_info.geometry.y_offset = 256 * key->yshift - value->ink_rect.y * 1024;
-
-  glyph_string.num_glyphs = 1;
-  glyph_string.glyphs = &glyph_info;
+  glyph.index = key->glyph;
+  glyph.x = 0.25 * key->xshift - value->ink_rect.x;
+  glyph.y = 0.25 * key->yshift - value->ink_rect.y;
 
-  pango_cairo_show_glyph_string (cr, key->font, &glyph_string);
+  cairo_show_glyphs (cr, &glyph, 1);
   cairo_destroy (cr);
 
   cairo_surface_flush (surface);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]