Rémi Bernon : gdi32/tests: Test GetGlyphIndices with '\0' default and a glyph.
Alexandre Julliard
julliard at winehq.org
Tue Dec 8 15:38:14 CST 2020
Module: wine
Branch: master
Commit: 6245f07201fd2c9ec9bc60b3de7757cb6d20bd76
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6245f07201fd2c9ec9bc60b3de7757cb6d20bd76
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Tue Dec 8 13:09:21 2020 +0100
gdi32/tests: Test GetGlyphIndices with '\0' default and a glyph.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50175
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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(-)
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 00000000000..89e5648fd92
Binary files /dev/null and b/dlls/gdi32/tests/wine_nul.ttf differ
More information about the wine-cvs
mailing list