On 11/18/2017 06:06 PM, Fabian Maurer wrote:
+static BOOL found_font; +static INT CALLBACK long_enum_proc(const LOGFONTA *lf, const TEXTMETRICA *tm, DWORD type, LPARAM lparam) +{ + found_font = TRUE; + return 1; +} You don't need global variable for that.
+static void test_long_names(void) +{ + char ttf_name[MAX_PATH]; + LOGFONTA font = {0}; + HFONT handle_font; + int ret; + + if (!pAddFontResourceExA || !pRemoveFontResourceExA) + { + win_skip("AddFontResourceExA is not available on this platform\n"); + return; + } I don't think this is necessary any more, we should use them directly now, and assume they are always available. + + if (!write_ttf_file("wine_longname.ttf", ttf_name)) + { + skip("Failed to create ttf file for testing\n"); + return; + } + + ret = pAddFontResourceExA(ttf_name, FR_PRIVATE, 0); + ok(ret, "AddFontResourceEx() failed\n"); + + strcpy(font.lfFaceName, "wine_3_this_is_a_very_long_name"); + found_font = FALSE; + EnumFontFamiliesExA(GetDC(0), &font, long_enum_proc, 0, 0); + ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n"); + + strcpy(font.lfFaceName, "wine_2_this_is_a_very_long_name"); + found_font = FALSE; + EnumFontFamiliesExA(GetDC(0), &font, long_enum_proc, 0, 0); + ok(found_font == TRUE, "EnumFontFamiliesExA didn't find font.\n"); I think it's better to release dc properly. + + handle_font = CreateFontIndirectA(&font); + ok(handle_font != NULL, "CreateFontIndirectA failed\n"); + DeleteObject(handle_font); + + + ret = pRemoveFontResourceExA(ttf_name, 0, 0); + ok(!ret, "RemoveFontResourceEx() should fail\n"); + + DeleteFileA(ttf_name); +} Also note that this test does cause additional test failures in existing tests.