Author: mjansen
Date: Tue Feb  7 11:37:36 2017
New Revision: 73746

URL: http://svn.reactos.org/svn/reactos?rev=73746&view=rev
Log:
[GDI32_APITEST] Add tests for font creation. Patch by Katayama Hirofumi MZ. 
CORE-6621

Modified:
    trunk/rostests/apitests/gdi32/CreateFontIndirect.c

Modified: trunk/rostests/apitests/gdi32/CreateFontIndirect.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CreateFontIndirect.c?rev=73746&r1=73745&r2=73746&view=diff
==============================================================================
--- trunk/rostests/apitests/gdi32/CreateFontIndirect.c  [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CreateFontIndirect.c  [iso-8859-1] Tue Feb  7 
11:37:36 2017
@@ -3,11 +3,13 @@
  * LICENSE:         GPL - See COPYING in the top level directory
  * PURPOSE:         Test for CreateFontIndirect
  * PROGRAMMERS:     Timo Kreuzer
+ *                  Katayama Hirofumi MZ
  */
 
 #include <apitest.h>
-
 #include <wingdi.h>
+
+#define trace_if(val, msg) do { if (!(val)) trace(msg); } while (0)
 
 void
 Test_CreateFontIndirectA(void)
@@ -167,6 +169,588 @@
     ok(elfedva.elfEnumLogfontEx.elfFullName[LF_FULLFACESIZE-1] == 0, "\n");
 }
 
+static INT CALLBACK
+is_truetype_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm,
+                      DWORD type, LPARAM lParam)
+{
+    if (type != TRUETYPE_FONTTYPE) return 1;
+
+    return 0;
+}
+
+static BOOL is_truetype_font_installed(HDC hDC, const char *name)
+{
+    if (!EnumFontFamiliesA(hDC, name, is_truetype_font_proc, 0))
+        return TRUE;
+    return FALSE;
+}
+
+static INT CALLBACK
+is_charset_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm,
+                               DWORD type, LPARAM lParam)
+{
+    if (ntm->tmCharSet == (BYTE)lParam)
+        return 0;
+    return 1;
+}
+
+static BOOL is_charset_font_installed(HDC hDC, BYTE CharSet)
+{
+    if (!EnumFontFamiliesA(hDC, NULL, is_charset_font_proc, CharSet))
+        return TRUE;
+    return FALSE;
+}
+
+/* TMPF_FIXED_PITCH is confusing. brain-damaged api */
+#define _TMPF_VAR_PITCH     TMPF_FIXED_PITCH
+
+static INT CALLBACK
+is_fixed_charset_font_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm,
+                                     DWORD type, LPARAM lParam)
+{
+    if (ntm->tmCharSet == (BYTE)lParam && !(ntm->tmPitchAndFamily & 
_TMPF_VAR_PITCH))
+        return 0;
+    return 1;
+}
+
+static BOOL
+is_fixed_charset_font_installed(HDC hDC, BYTE CharSet)
+{
+    if (!EnumFontFamiliesA(hDC, NULL, is_fixed_charset_font_proc, CharSet))
+        return TRUE;
+    return FALSE;
+}
+
+static void
+Test_FontPresence(void)
+{
+    HDC hDC;
+
+    hDC = CreateCompatibleDC(NULL);
+
+    ok(is_truetype_font_installed(hDC, "Arial"), "'Arial' is not found\n");
+    ok(is_truetype_font_installed(hDC, "Courier New"), "'Courier New' is not 
found\n");
+    ok(is_truetype_font_installed(hDC, "Marlett"), "'Marlett' is not found\n");
+    ok(is_truetype_font_installed(hDC, "MS Shell Dlg"), "'MS Shell Dlg' is not 
found\n");
+    ok(is_truetype_font_installed(hDC, "Tahoma"), "'Tahoma' is not found\n");
+    ok(is_truetype_font_installed(hDC, "Times New Roman"), "'Times New Roman' 
is not found\n");
+
+    ok(is_charset_font_installed(hDC, ANSI_CHARSET), "ANSI_CHARSET fonts are 
not found\n");
+    ok(is_charset_font_installed(hDC, SYMBOL_CHARSET), "SYMBOL_CHARSET fonts 
are not found\n");
+    trace_if(is_charset_font_installed(hDC, SHIFTJIS_CHARSET), 
"SHIFTJIS_CHARSET fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, HANGUL_CHARSET), "HANGUL_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, GB2312_CHARSET), "GB2312_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, CHINESEBIG5_CHARSET), 
"CHINESEBIG5_CHARSET fonts are not found\n");
+    ok(is_charset_font_installed(hDC, OEM_CHARSET), "OEM_CHARSET fonts are not 
found\n");
+    trace_if(is_charset_font_installed(hDC, JOHAB_CHARSET), "JOHAB_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, HEBREW_CHARSET), "HEBREW_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, ARABIC_CHARSET), "ARABIC_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, GREEK_CHARSET), "GREEK_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, TURKISH_CHARSET), "TURKISH_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, VIETNAMESE_CHARSET), 
"VIETNAMESE_CHARSET fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, THAI_CHARSET), "THAI_CHARSET fonts 
are not found\n");
+    trace_if(is_charset_font_installed(hDC, EASTEUROPE_CHARSET), 
"EASTEUROPE_CHARSET fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, RUSSIAN_CHARSET), "RUSSIAN_CHARSET 
fonts are not found\n");
+    trace_if(is_charset_font_installed(hDC, MAC_CHARSET), "MAC_CHARSET fonts 
are not found\n");
+    trace_if(is_charset_font_installed(hDC, BALTIC_CHARSET), "BALTIC_CHARSET 
fonts are not found\n");
+
+    ok(is_fixed_charset_font_installed(hDC, ANSI_CHARSET), "fixed ANSI_CHARSET 
fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, SHIFTJIS_CHARSET), "fixed 
SHIFTJIS_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, HANGUL_CHARSET), "fixed 
HANGUL_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, GB2312_CHARSET), "fixed 
GB2312_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, CHINESEBIG5_CHARSET), "fixed 
CHINESEBIG5_CHARSET fonts are not found\n");
+    ok(is_fixed_charset_font_installed(hDC, OEM_CHARSET), "fixed OEM_CHARSET 
fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, JOHAB_CHARSET), "fixed 
JOHAB_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, HEBREW_CHARSET), "fixed 
HEBREW_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, ARABIC_CHARSET), "fixed 
ARABIC_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, GREEK_CHARSET), "fixed 
GREEK_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, TURKISH_CHARSET), "fixed 
TURKISH_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, VIETNAMESE_CHARSET), "fixed 
VIETNAMESE_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, THAI_CHARSET), "fixed 
THAI_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, EASTEUROPE_CHARSET), "fixed 
EASTEUROPE_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, RUSSIAN_CHARSET), "fixed 
RUSSIAN_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, MAC_CHARSET), "fixed 
MAC_CHARSET fonts are not found\n");
+    trace_if(is_fixed_charset_font_installed(hDC, BALTIC_CHARSET), "fixed 
BALTIC_CHARSET fonts are not found\n");
+
+    DeleteDC(hDC);
+}
+
+/* NOTE: TMPF_FIXED_PITCH is confusing and brain-dead. */
+#define _TMPF_VAR_PITCH TMPF_FIXED_PITCH
+
+typedef enum TRISTATE {
+    TS_UNKNOWN,
+    TS_TRUE,
+    TS_FALSE
+} TRISTATE;
+
+typedef struct FONT_SEL_TEST {
+    CHAR        FaceNameBefore[LF_FACESIZE];
+
+    BYTE        CharSetBefore;
+    BYTE        CharSetAfter;
+
+    TRISTATE    BoldBefore;
+    TRISTATE    BoldAfter;
+
+    BYTE        ItalicBefore;
+    TRISTATE    ItalicAfter;
+
+    BYTE        UnderlineBefore;
+    TRISTATE    UnderlineAfter;
+
+    BYTE        StruckOutBefore;
+    TRISTATE    StruckOutAfter;
+
+    TRISTATE    FixedPitchBefore;
+    TRISTATE    FixedPitchAfter;
+} FONT_SEL_TEST;
+
+static FONT_SEL_TEST g_Entries[] =
+{
+    /* Entry #0: default */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        TS_UNKNOWN, TS_FALSE,
+        TS_UNKNOWN, TS_FALSE,
+        TS_UNKNOWN, TS_FALSE,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #1: symbol font*/
+    {
+        "",
+        SYMBOL_CHARSET, SYMBOL_CHARSET
+    },
+    /* Entry #2: non-bold */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_FALSE, TS_FALSE
+    },
+    /* Entry #3: bold */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #4: non-italic (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_FALSE
+    },
+    /* Entry #5: italic (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        TRUE, TS_TRUE
+    },
+    /* Entry #6: non-underline (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_FALSE
+    },
+    /* Entry #7: underline (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        TRUE, TS_TRUE
+    },
+    /* Entry #8: struck-out (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TRUE, TS_TRUE
+    },
+    /* Entry #9: non-struck-out (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_FALSE
+    },
+    /* Entry #10: fixed-pitch (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #11: non-fixed-pitch (without specifying bold) */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_FALSE, TS_FALSE
+    },
+    /* Entry #12: fixed-pitch and bold */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_TRUE, TS_TRUE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #13: non-fixed-pitch and bold */
+    {
+        "",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_TRUE, TS_TRUE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_FALSE, TS_FALSE
+    },
+    /* Entry #14: OEM_CHARSET */
+    {
+        "",
+        OEM_CHARSET, OEM_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #15: OEM_CHARSET and bold */
+    {
+        "",
+        OEM_CHARSET, OEM_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #16: OEM_CHARSET and fixed-pitch */
+    {
+        "",
+        OEM_CHARSET, OEM_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #17: CHINESEBIG5_CHARSET (Chinese) */
+    {
+        "",
+        CHINESEBIG5_CHARSET, CHINESEBIG5_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #18: CHINESEBIG5_CHARSET and bold */
+    {
+        "",
+        CHINESEBIG5_CHARSET, CHINESEBIG5_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #19: CHINESEBIG5_CHARSET and fixed-pitch */
+    {
+        "",
+        CHINESEBIG5_CHARSET, CHINESEBIG5_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #20: GB2312_CHARSET (Chinese) */
+    {
+        "",
+        GB2312_CHARSET, GB2312_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #21: GB2312_CHARSET and bold */
+    {
+        "",
+        GB2312_CHARSET, GB2312_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #22: GB2312_CHARSET and fixed-pitch */
+    {
+        "",
+        GB2312_CHARSET, GB2312_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #23: RUSSIAN_CHARSET (Russian) */
+    {
+        "",
+        RUSSIAN_CHARSET, RUSSIAN_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #24: RUSSIAN_CHARSET and bold */
+    {
+        "",
+        RUSSIAN_CHARSET, RUSSIAN_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #25: RUSSIAN_CHARSET and italic */
+    {
+        "",
+        RUSSIAN_CHARSET, RUSSIAN_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        TRUE, TS_TRUE,
+    },
+    /* Entry #26: RUSSIAN_CHARSET and fixed-pitch */
+    {
+        "",
+        RUSSIAN_CHARSET, RUSSIAN_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #27: SHIFTJIS_CHARSET (Japanese) */
+    {
+        "",
+        SHIFTJIS_CHARSET, SHIFTJIS_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #28: SHIFTJIS_CHARSET and bold */
+    {
+        "",
+        SHIFTJIS_CHARSET, SHIFTJIS_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #29: SHIFTJIS_CHARSET and fixed-pitch */
+    {
+        "",
+        SHIFTJIS_CHARSET, SHIFTJIS_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #30: HANGUL_CHARSET (Korean) */
+    {
+        "",
+        HANGUL_CHARSET, HANGUL_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #31: HANGUL_CHARSET and bold */
+    {
+        "",
+        HANGUL_CHARSET, HANGUL_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #32: HANGUL_CHARSET and fixed-pitch */
+    {
+        "",
+        HANGUL_CHARSET, HANGUL_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #33: JOHAB_CHARSET (Korean) */
+    {
+        "",
+        JOHAB_CHARSET, JOHAB_CHARSET,
+        TS_UNKNOWN, TS_UNKNOWN
+    },
+    /* Entry #34: JOHAB_CHARSET and bold */
+    {
+        "",
+        JOHAB_CHARSET, JOHAB_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #35: JOHAB_CHARSET and fixed-pitch */
+    {
+        "",
+        JOHAB_CHARSET, JOHAB_CHARSET,
+        TS_UNKNOWN, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #36: THAI_CHARSET (Thai) */
+    {
+        "",
+        THAI_CHARSET, THAI_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #37: THAI_CHARSET and bold */
+    {
+        "",
+        THAI_CHARSET, THAI_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #38: THAI_CHARSET and fixed-pitch */
+    {
+        "",
+        THAI_CHARSET, THAI_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #39: GREEK_CHARSET (Greek) */
+    {
+        "",
+        GREEK_CHARSET, GREEK_CHARSET,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #40: GREEK_CHARSET and bold */
+    {
+        "",
+        GREEK_CHARSET, GREEK_CHARSET,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #41: GREEK_CHARSET and italic */
+    {
+        "",
+        GREEK_CHARSET, GREEK_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        TRUE, TS_TRUE
+    },
+    /* Entry #42: GREEK_CHARSET and fixed-pitch */
+    {
+        "",
+        GREEK_CHARSET, GREEK_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_TRUE, TS_TRUE
+    },
+    /* Entry #43: "Marlett" */
+    {
+        "Marlett",
+        DEFAULT_CHARSET, SYMBOL_CHARSET
+    },
+    /* Entry #43: "Arial" */
+    {
+        "Arial",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_UNKNOWN, TS_FALSE
+    },
+    /* Entry #44: "Courier" */
+    {
+        "Courier",
+        DEFAULT_CHARSET, DEFAULT_CHARSET,
+        TS_UNKNOWN, TS_FALSE,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        FALSE, TS_UNKNOWN,
+        TS_UNKNOWN, TS_TRUE
+    }
+};
+
+static void
+Test_FontSelectionEntry(HDC hDC, UINT nIndex, FONT_SEL_TEST *Entry)
+{
+    LOGFONTA        lf;
+    HFONT           hFont;
+    HGDIOBJ         hFontOld;
+    TEXTMETRICA     tm;
+
+    ZeroMemory(&lf, sizeof(lf));
+
+    if (Entry->FaceNameBefore[0])
+        lstrcpynA(lf.lfFaceName, Entry->FaceNameBefore, 
_countof(lf.lfFaceName));
+
+    lf.lfCharSet = Entry->CharSetBefore;
+
+    if (Entry->BoldBefore == TS_TRUE)
+        lf.lfWeight = FW_BOLD;
+    else if (Entry->BoldBefore == TS_FALSE)
+        lf.lfWeight = FW_NORMAL;
+    else
+        lf.lfWeight = FW_DONTCARE;
+
+    lf.lfItalic = Entry->ItalicBefore;
+    lf.lfUnderline = Entry->UnderlineBefore;
+    lf.lfStrikeOut = Entry->StruckOutBefore;
+
+    if (Entry->FixedPitchBefore == TS_TRUE)
+        lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
+    else if (Entry->FixedPitchBefore == TS_FALSE)
+        lf.lfPitchAndFamily = VARIABLE_PITCH | FF_DONTCARE;
+    else
+        lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+
+    hFont = CreateFontIndirectA(&lf);
+    ok(hFont != NULL, "Entry #%u: hFont failed\n", nIndex);
+
+    hFontOld = SelectObject(hDC, hFont);
+    {
+        ok(GetTextMetricsA(hDC, &tm), "Entry #%u: GetTextMetricsA failed\n", 
nIndex);
+
+        if (Entry->CharSetAfter != DEFAULT_CHARSET)
+            ok(tm.tmCharSet == Entry->CharSetAfter, "Entry #%u: CharSet 
mismatched, it was %u\n", nIndex, tm.tmCharSet);
+
+        if (Entry->BoldAfter == TS_TRUE)
+            ok(tm.tmWeight >= FW_BOLD, "Entry #%u: Weight was non-bold\n", 
nIndex);
+        else if (Entry->BoldAfter == TS_FALSE)
+            ok(tm.tmWeight <= FW_MEDIUM, "Entry #%u: Weight was bold\n", 
nIndex);
+
+        if (Entry->ItalicAfter == TS_TRUE)
+            ok(tm.tmItalic, "Entry #%u: Italic was non-italic\n", nIndex);
+        else if (Entry->ItalicAfter == TS_FALSE)
+            ok(!tm.tmItalic, "Entry #%u: Italic was italic\n", nIndex);
+
+        if (Entry->UnderlineAfter == TS_TRUE)
+            ok(tm.tmUnderlined, "Entry #%u: Underlined was FALSE\n", nIndex);
+        else if (Entry->UnderlineAfter == TS_FALSE)
+            ok(!tm.tmUnderlined, "Entry #%u: Underlined was TRUE\n", nIndex);
+
+        if (Entry->StruckOutAfter == TS_TRUE)
+            ok(tm.tmStruckOut, "Entry #%u: Struck-out was FALSE\n", nIndex);
+        else if (Entry->StruckOutAfter == TS_FALSE)
+            ok(!tm.tmStruckOut, "Entry #%u: Struck-out was TRUE\n", nIndex);
+
+        if (Entry->FixedPitchAfter == TS_TRUE)
+            ok(!(tm.tmPitchAndFamily & _TMPF_VAR_PITCH), "Entry #%u: Pitch 
mismatched, it was non-fixed-pitch\n", nIndex);
+        else if (Entry->FixedPitchAfter == TS_FALSE)
+            ok((tm.tmPitchAndFamily & _TMPF_VAR_PITCH), "Entry #%u: Pitch 
mismatched, it was fixed-pitch\n", nIndex);
+    }
+    SelectObject(hDC, hFontOld);
+    DeleteObject(hFont);
+}
+
+static void
+Test_FontSelection(void)
+{
+    UINT nIndex;
+    HDC hDC;
+
+    hDC = CreateCompatibleDC(NULL);
+    for (nIndex = 0; nIndex < _countof(g_Entries); ++nIndex)
+    {
+        if (!is_charset_font_installed(hDC, g_Entries[nIndex].CharSetBefore))
+            skip("charset not available: 0x%x\n", 
g_Entries[nIndex].CharSetBefore);
+        else
+            Test_FontSelectionEntry(hDC, nIndex, g_Entries + nIndex);
+    }
+    DeleteDC(hDC);
+}
+
 
 START_TEST(CreateFontIndirect)
 {
@@ -174,5 +758,7 @@
     Test_CreateFontIndirectW();
     Test_CreateFontIndirectExA();
     Test_CreateFontIndirectExW();
-}
-
+    Test_FontPresence();
+    Test_FontSelection();
+}
+


Reply via email to