[PATCH] gdi32: rebuild font hash after changing the matrix

Marcus Meissner marcus at jet.franken.de
Mon Jul 19 17:17:10 CDT 2010


Hi,

http://bugs.winehq.org/show_bug.cgi?id=22021
saw a slow down due to font handling.

The issue is that the "hash" is not correctly updated
in the non scalable case to match the updated matrix
and that afterwards the cache should be checked again.

If we would not check the cache, it would increment itself
endlessly.

(Perhaps this is also a case of where "System" is expected to be
 a truetype font. But the fixx is sensible in any case.)

Ciao, Marcus
---
 dlls/gdi32/freetype.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index ddb3d24..026fa37 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -3780,12 +3780,23 @@ found:
     if(!face->scalable) {
         /* Windows uses integer scaling factors for bitmap fonts */
         INT scale, scaled_height;
+        GdiFont *cachedfont;
 
         /* FIXME: rotation of bitmap fonts is ignored */
         height = abs(GDI_ROUND( (double)height * ret->font_desc.matrix.eM22 ));
         if (ret->aveWidth)
             ret->aveWidth = (double)ret->aveWidth * ret->font_desc.matrix.eM11;
         ret->font_desc.matrix.eM11 = ret->font_desc.matrix.eM22 = 1.0;
+        dcmat.eM11 = dcmat.eM22 = 1.0;
+        /* As we changed the matrix, we need to search the cache for the font again, 
+         * otherwise we might explode the cache. */
+        if((cachedfont = find_in_cache(hfont, &lf, &dcmat, can_use_bitmap)) != NULL) {
+            TRACE("Found cached font after non-scalable matrix rescale!\n");
+            free_font( ret );
+            LeaveCriticalSection( &freetype_cs );
+            return cachedfont;
+        }
+        calc_hash(&ret->font_desc);
 
         if (height != 0) height = diff;
         height += face->size.height;
-- 
1.5.6



More information about the wine-patches mailing list