gdi: resend add missing glyph code to GetGlyphIndices

Jeff L lats at yless4u.com.au
Wed Aug 23 09:49:13 CDT 2006


Changed the call from GetTextMetricsW to WineEngGetTextMetrics as 
suggest by Dimitry.

Fixed repeated calls to GetTextMetricsW and added the update of the flag
to limit the calls.

Well I'll give git a chance and have a go.


After testing this under windows, it seems that MSDN does not tell the
truth about non existent glyph code.  This patch makes the tests conform
to what windows does.


Changelog:
add missing glyph code to GetGlyphIndices and tests

Jeff Latimer








-------------- next part --------------
>From 8a35f4bfbfae9a2a23379cd17490937728ff6295 Mon Sep 17 00:00:00 2001
From: Jeff Latimer <lats at yless4u.com.au>
Date: Thu, 24 Aug 2006 00:44:36 +1000
Subject: [PATCH] add missing glyph code to GetGlyphIndices
---
 dlls/gdi/freetype.c   |   25 +++++++++++++++++++++++--
 dlls/gdi/tests/font.c |   31 +++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c
index f82112f..0cf79da 100644
--- a/dlls/gdi/freetype.c
+++ b/dlls/gdi/freetype.c
@@ -2898,11 +2898,32 @@ static FT_UInt get_glyph_index(GdiFont f
 DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,
 				LPWORD pgi, DWORD flags)
 {
-    INT i;
+    char have_default = 0;
+    int i;
+    TEXTMETRICW textm;
 
     for(i = 0; i < count; i++)
+    {
         pgi[i] = get_glyph_index(font, lpstr[i]);
-
+        if  (pgi[i] == 0)
+        {
+            if  (flags & GGI_MARK_NONEXISTING_GLYPHS)
+                pgi[i] = 0x001f;                  /* Indicate non existance */
+            else
+            {
+                /* Note that the call to GetTextMetricsW is made in the loop *
+                 * because it is less likely to have non existant glyphs     *
+                 * and hence we should have few calls to GetTextMetricsW as  *
+                 * a result                                                  */
+                if  (!have_default)
+                {
+                    WineEngGetTextMetrics(font, &textm);
+                    have_default = 1;
+                }
+                pgi[i] = textm.tmDefaultChar;
+            }
+        }
+    }
     return count;
 }
 
diff --git a/dlls/gdi/tests/font.c b/dlls/gdi/tests/font.c
index c4ac60d..af995f7 100644
--- a/dlls/gdi/tests/font.c
+++ b/dlls/gdi/tests/font.c
@@ -391,6 +391,36 @@ static void test_text_extents(void)
     ReleaseDC(NULL, hdc);
 }
 
+static void test_GetGlyphIndices()
+{
+    HDC      hdc;
+    HFONT    hfont;
+    DWORD    charcount;
+    LOGFONTA lf;
+    DWORD    flags = 0;
+    WCHAR    testtext[] = {'T','e','s','t',0xffff,0};
+    WORD     glyphs[(sizeof(testtext)/2)-1];
+    TEXTMETRIC textm;
+
+    memset(&lf, 0, sizeof(lf));
+    strcpy(lf.lfFaceName, "Symbol");
+    lf.lfHeight = 20;
+
+    hfont = CreateFontIndirectA(&lf);
+    hdc = GetDC(0);
+
+    ok(GetTextMetrics(hdc, &textm), "GetTextMetric failed\n");
+    flags |= GGI_MARK_NONEXISTING_GLYPHS;
+    charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
++    ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount);
+    ok(glyphs[4] == 0x001f, "GetGlyphIndices should have returned a non existant char not %04x\n", glyphs[4]);
+    flags = 0;
+    charcount = GetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
+    ok(charcount == 5, "GetGlyphIndices count of glyphs should = 5 not %ld\n", charcount);
+    ok(glyphs[4] == textm.tmDefaultChar, "GetGlyphIndices should have returned a %04x not %04x\n", 
+                    textm.tmDefaultChar, glyphs[4]);
+}
+
 START_TEST(font)
 {
     test_logfont();
@@ -399,4 +429,5 @@ START_TEST(font)
     test_GdiGetCharDimensions();
     test_GetCharABCWidthsW();
     test_text_extents();
+    test_GetGlyphIndices();
 }
-- 
1.4.1



More information about the wine-patches mailing list