gdi: resend add missing glyph code to GetGlyphIndices
Jeff L
lats at yless4u.com.au
Wed Aug 23 07:08:34 CDT 2006
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 53714742369c2d4ce78c6540dd9b2eb2eac6813a Mon Sep 17 00:00:00 2001
From: Jeff Latimer <lats at yless4u.com.au>
Date: Wed, 23 Aug 2006 22:06:45 +1000
Subject: [PATCH] add missing glyph code to GetGlyphIndices
---
dlls/gdi/font.c | 2 +-
dlls/gdi/freetype.c | 29 ++++++++++++++++++++++++-----
dlls/gdi/gdi_private.h | 2 +-
dlls/gdi/tests/font.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 57 insertions(+), 7 deletions(-)
diff --git a/dlls/gdi/font.c b/dlls/gdi/font.c
index ec9074d..b044282 100644
--- a/dlls/gdi/font.c
+++ b/dlls/gdi/font.c
@@ -2681,7 +2681,7 @@ DWORD WINAPI GetGlyphIndicesW(HDC hdc, L
if(!dc) return GDI_ERROR;
if(dc->gdiFont)
- ret = WineEngGetGlyphIndices(dc->gdiFont, lpstr, count, pgi, flags);
+ ret = WineEngGetGlyphIndices(hdc, dc->gdiFont, lpstr, count, pgi, flags);
GDI_ReleaseObj(hdc);
return ret;
diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c
index f82112f..00e8744 100644
--- a/dlls/gdi/freetype.c
+++ b/dlls/gdi/freetype.c
@@ -2893,16 +2893,35 @@ static FT_UInt get_glyph_index(GdiFont f
/*************************************************************
* WineEngGetGlyphIndices
*
- * FIXME: add support for GGI_MARK_NONEXISTING_GLYPHS
*/
-DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,
+DWORD WineEngGetGlyphIndices(HDC hdc, 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)
+ {
+ GetTextMetricsW(hdc, &textm);
+ have_default = 1;
+ }
+ pgi[i] = textm.tmDefaultChar;
+ }
+ }
+ }
return count;
}
diff --git a/dlls/gdi/gdi_private.h b/dlls/gdi/gdi_private.h
index a0de444..1f25ad7 100644
--- a/dlls/gdi/gdi_private.h
+++ b/dlls/gdi/gdi_private.h
@@ -371,7 +371,7 @@ extern BOOL WineEngGetCharABCWidthsI(Gdi
UINT count, LPWORD pgi, LPABC buffer);
extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT);
extern DWORD WineEngGetFontData(GdiFont, DWORD, DWORD, LPVOID, DWORD);
-extern DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,
+extern DWORD WineEngGetGlyphIndices(HDC hdc, GdiFont font, LPCWSTR lpstr, INT count,
LPWORD pgi, DWORD flags);
extern DWORD WineEngGetGlyphOutline(GdiFont, UINT glyph, UINT format,
LPGLYPHMETRICS, DWORD buflen, LPVOID buf,
diff --git a/dlls/gdi/tests/font.c b/dlls/gdi/tests/font.c
index c4ac60d..bfda353 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