[PATCH 1/2] gdi32/tests: Test GetGlyphIndices with '\0' default and a glyph.
Rémi Bernon
rbernon at codeweavers.com
Tue Dec 8 06:09:21 CST 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50175
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/gdi32/tests/Makefile.in | 1 +
dlls/gdi32/tests/font.c | 112 +++++++++++++++++++++------------
dlls/gdi32/tests/resource.rc | 3 +
dlls/gdi32/tests/wine_nul.sfd | 113 ++++++++++++++++++++++++++++++++++
dlls/gdi32/tests/wine_nul.ttf | Bin 0 -> 1600 bytes
5 files changed, 190 insertions(+), 39 deletions(-)
create mode 100644 dlls/gdi32/tests/wine_nul.sfd
create mode 100644 dlls/gdi32/tests/wine_nul.ttf
diff --git a/dlls/gdi32/tests/Makefile.in b/dlls/gdi32/tests/Makefile.in
index 1eba8d13cef..876f6a376a2 100644
--- a/dlls/gdi32/tests/Makefile.in
+++ b/dlls/gdi32/tests/Makefile.in
@@ -24,6 +24,7 @@ FONT_SRCS = \
wine_langnames2.sfd \
wine_langnames3.sfd \
wine_longname.sfd \
+ wine_nul.sfd \
wine_test.sfd \
wine_ttfnames.sfd \
wine_ttfnames_bold.sfd \
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index 8b0c7b3dbcc..cde83757c16 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -1587,6 +1587,45 @@ static void test_text_extents(void)
ReleaseDC(NULL, hdc);
}
+static void free_font(void *font)
+{
+ UnmapViewOfFile(font);
+}
+
+static void *load_font(const char *font_name, DWORD *font_size)
+{
+ char file_name[MAX_PATH];
+ HANDLE file, mapping;
+ void *font;
+
+ if (font_name[1] == ':')
+ strcpy(file_name, font_name);
+ else
+ {
+ if (!GetWindowsDirectoryA(file_name, sizeof(file_name))) return NULL;
+ strcat(file_name, "\\fonts\\");
+ strcat(file_name, font_name);
+ }
+
+ file = CreateFileA(file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
+ if (file == INVALID_HANDLE_VALUE) return NULL;
+
+ *font_size = GetFileSize(file, NULL);
+
+ mapping = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (!mapping)
+ {
+ CloseHandle(file);
+ return NULL;
+ }
+
+ font = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
+
+ CloseHandle(file);
+ CloseHandle(mapping);
+ return font;
+}
+
static void test_GetGlyphIndices(void)
{
HDC hdc;
@@ -1598,6 +1637,10 @@ static void test_GetGlyphIndices(void)
WORD glyphs[(sizeof(testtext)/2)-1];
TEXTMETRICA textm;
HFONT hOldFont;
+ HANDLE rsrc;
+ DWORD ret, font_size, num_fonts;
+ void *font;
+ char ttf_name[MAX_PATH];
if (!pGetGlyphIndicesW) {
win_skip("GetGlyphIndicesW not available on platform\n");
@@ -1653,6 +1696,36 @@ static void test_GetGlyphIndices(void)
ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
DeleteObject(SelectObject(hdc, hOldFont));
+
+ ret = write_ttf_file("wine_nul.ttf", ttf_name);
+ ok(ret, "Failed to create test font file.\n");
+ font = load_font(ttf_name, &font_size);
+ ok(font != NULL, "Failed to map font file.\n");
+ num_fonts = 0;
+ rsrc = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
+ ok(ret != 0, "Failed to add resource, %d.\n", GetLastError());
+ ok(num_fonts == 1, "Unexpected number of fonts %u.\n", num_fonts);
+
+ memset(&lf, 0, sizeof(lf));
+ strcpy(lf.lfFaceName, "wine_nul");
+ lf.lfHeight = 20;
+ flags = 0;
+ hfont = CreateFontIndirectA(&lf);
+ hOldFont = SelectObject(hdc, hfont);
+ ok(GetTextMetricsA(hdc, &textm), "GetTextMetric failed\n");
+ testtext[0] = 'T';
+ charcount = pGetGlyphIndicesW(hdc, testtext, (sizeof(testtext)/2)-1, glyphs, flags);
+ ok(charcount == 5, "GetGlyphIndicesW count of glyphs should = 5 not %d\n", charcount);
+ todo_wine ok(glyphs[0] == 0, "GetGlyphIndicesW for tmDefaultChar should be 0 not %04x\n", glyphs[0]);
+ todo_wine ok(glyphs[4] == 0, "GetGlyphIndicesW should have returned 0 not %04x\n", glyphs[4]);
+ DeleteObject(SelectObject(hdc, hOldFont));
+
+ ret = pRemoveFontMemResourceEx(rsrc);
+ ok(ret, "RemoveFontMemResourceEx error %d\n", GetLastError());
+ free_font(font);
+ ret = DeleteFileA(ttf_name);
+ ok(ret, "Failed to delete font file, %d.\n", GetLastError());
+
}
static void test_GetKerningPairs(void)
@@ -5000,45 +5073,6 @@ static void test_CreateFontIndirectEx(void)
DeleteObject(hfont);
}
-static void free_font(void *font)
-{
- UnmapViewOfFile(font);
-}
-
-static void *load_font(const char *font_name, DWORD *font_size)
-{
- char file_name[MAX_PATH];
- HANDLE file, mapping;
- void *font;
-
- if (font_name[1] == ':')
- strcpy(file_name, font_name);
- else
- {
- if (!GetWindowsDirectoryA(file_name, sizeof(file_name))) return NULL;
- strcat(file_name, "\\fonts\\");
- strcat(file_name, font_name);
- }
-
- file = CreateFileA(file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0);
- if (file == INVALID_HANDLE_VALUE) return NULL;
-
- *font_size = GetFileSize(file, NULL);
-
- mapping = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
- if (!mapping)
- {
- CloseHandle(file);
- return NULL;
- }
-
- font = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
-
- CloseHandle(file);
- CloseHandle(mapping);
- return font;
-}
-
static void test_realization_info(const char *name, DWORD size, BOOL is_memory_resource)
{
struct font_realization_info info;
diff --git a/dlls/gdi32/tests/resource.rc b/dlls/gdi32/tests/resource.rc
index 6cbe789880b..784d8602a9a 100644
--- a/dlls/gdi32/tests/resource.rc
+++ b/dlls/gdi32/tests/resource.rc
@@ -46,3 +46,6 @@ wine_langnames2.ttf RCDATA wine_langnames2.ttf
/* @makedep: wine_langnames3.ttf */
wine_langnames3.ttf RCDATA wine_langnames3.ttf
+
+/* @makedep: wine_nul.ttf */
+wine_nul.ttf RCDATA wine_nul.ttf
diff --git a/dlls/gdi32/tests/wine_nul.sfd b/dlls/gdi32/tests/wine_nul.sfd
new file mode 100644
index 00000000000..c82180f1007
--- /dev/null
+++ b/dlls/gdi32/tests/wine_nul.sfd
@@ -0,0 +1,113 @@
+SplineFontDB: 3.2
+FontName: wine_nul
+FullName: wine_nul
+FamilyName: wine_nul
+Weight: Medium
+Copyright: Copyright (c) 2020 Remi Bernon for CodeWeavers
+Version: 001.000
+ItalicAngle: 0
+UnderlinePosition: -205
+UnderlineWidth: 102
+Ascent: 1638
+Descent: 410
+InvalidEm: 0
+sfntRevision: 0x00010000
+LayerCount: 2
+Layer: 0 1 "Back" 1
+Layer: 1 1 "Fore" 0
+XUID: [1021 905 592216984 1247726]
+FSType: 32767
+OS2Version: 2
+OS2_WeightWidthSlopeOnly: 0
+OS2_UseTypoMetrics: 1
+CreationTime: 1607427474
+ModificationTime: 1607428497
+PfmFamily: 17
+TTFWeight: 500
+TTFWidth: 5
+LineGap: 184
+VLineGap: 0
+Panose: 2 0 6 3 0 0 0 0 0 0
+OS2TypoAscent: 0
+OS2TypoAOffset: 1
+OS2TypoDescent: 0
+OS2TypoDOffset: 1
+OS2TypoLinegap: 184
+OS2WinAscent: 1638
+OS2WinAOffset: 0
+OS2WinDescent: 410
+OS2WinDOffset: 0
+HheadAscent: 0
+HheadAOffset: 1
+HheadDescent: 0
+HheadDOffset: 1
+OS2SubXSize: 1331
+OS2SubYSize: 1433
+OS2SubXOff: 0
+OS2SubYOff: 286
+OS2SupXSize: 1331
+OS2SupYSize: 1433
+OS2SupXOff: 0
+OS2SupYOff: 983
+OS2StrikeYSize: 102
+OS2StrikeYPos: 530
+OS2Vendor: 'Wine'
+OS2CodePages: 00000001.00000000
+OS2UnicodeRanges: 00000001.00000000.00000000.00000000
+MarkAttachClasses: 1
+DEI: 91125
+ShortTable: cvt 2
+ 68
+ 1297
+EndShort
+ShortTable: maxp 16
+ 1
+ 0
+ 4
+ 8
+ 2
+ 0
+ 0
+ 2
+ 0
+ 1
+ 1
+ 0
+ 64
+ 46
+ 0
+ 0
+EndShort
+LangName: 1033 "" "" "" "Wine : wine_nul : 4-11-2010"
+GaspTable: 1 65535 2 0
+Encoding: ISO8859-1
+UnicodeInterp: none
+NameList: Adobe Glyph List
+DisplaySize: -24
+AntiAlias: 1
+FitToEm: 1
+WinInfo: 0 76 22
+BeginPrivate: 0
+EndPrivate
+BeginChars: 256 1
+
+StartChar: uni0000
+Encoding: 0 0 0
+Width: 2048
+LayerCount: 2
+Fore
+SplineSet
+667 1485 m 5,0,-1
+ 1327 1485 l 1,1,-1
+ 1327 0 l 1,2,-1
+ 667 0 l 1,3,-1
+ 667 1485 l 5,0,-1
+601 1575 m 1,0,-1
+ 1405 1575 l 1,1,-1
+ 1405 -63 l 1,2,-1
+ 601 -63 l 1,3,-1
+ 601 1575 l 1,0,-1
+EndSplineSet
+EndChar
+EndChars
+EndSplineFont
diff --git a/dlls/gdi32/tests/wine_nul.ttf b/dlls/gdi32/tests/wine_nul.ttf
new file mode 100644
index 0000000000000000000000000000000000000000..89e5648fd92c15da6df08bb65cbf1f52add68638
GIT binary patch
literal 1600
zcmds1OKVd>6#nME60vF{Rz!nLwbBZ<y-7t>vXC at Z7goVn5yTpkn<miQ#5AcE5nZ?v
z+^7p5h+9Dr+J(4r;lc+(!G++$?%av)Eck5v=H6+kMf?HI<;<MtH|Lx?GY|k);xbH}
z9vC<}cw_qdF2L!aHoh;jcK~fzLpiGCLq~d(E2 at pFfGAQvohxUnSYbY-{Fao?jn^eI
zb__7r(Qb`o$EwXHk>OB8bYyg*aNy;~JnahqO3};a<F79$>`$Z}MJifOMV=E&**l8m
z`uTM*?oob4xn;DH%OVY*@o~!0a`t=``@np~e#+9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