[gtk] glyph cache: check glyphs for scaled size



commit 1c93bef0d5ba08012a275815ae3549911d1ef459
Author: Timm Bäder <mail baedert org>
Date:   Sun Jul 28 10:58:10 2019 +0200

    glyph cache: check glyphs for scaled size
    
    We can't rely on just the ink_rect, since that might be without the
    scaled applied, which is what ends up on the texture.
    
    Fixes #2046

 gsk/gl/gskglglyphcache.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gl/gskglglyphcache.c b/gsk/gl/gskglglyphcache.c
index 14ff40e453..341d1032ef 100644
--- a/gsk/gl/gskglglyphcache.c
+++ b/gsk/gl/gskglglyphcache.c
@@ -311,6 +311,7 @@ gsk_gl_glyph_cache_lookup (GskGLGlyphCache  *cache,
   if (value == NULL)
     {
       PangoRectangle ink_rect;
+      const guint key_scale = (guint)(scale * 1024);
 
       pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
       pango_extents_to_pixels (&ink_rect, NULL);
@@ -324,7 +325,8 @@ gsk_gl_glyph_cache_lookup (GskGLGlyphCache  *cache,
       value->timestamp = cache->timestamp;
       value->atlas = NULL; /* For now */
 
-      if (ink_rect.width < 128 && ink_rect.height < 128)
+      if ((ink_rect.width * key_scale) < 128 &&
+          (ink_rect.height * key_scale) < 128)
         {
           GlyphCacheKey *key;
 
@@ -332,9 +334,11 @@ gsk_gl_glyph_cache_lookup (GskGLGlyphCache  *cache,
 
           key->font = g_object_ref (font);
           key->glyph = glyph;
-          key->scale = (guint)(scale * 1024);
+          key->scale =  key_scale;
 
-          if (ink_rect.width > 0 && ink_rect.height > 0 && key->scale > 0)
+          if (key->scale > 0 &&
+              ink_rect.width * key->scale > 0 &&
+              ink_rect.height * key->scale > 0)
             add_to_cache (cache, key, value);
 
           *cached_glyph_out = *value;


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