I have investigated `GdipGetGenericFontFamily*` functions from native gdiplus.dll.
The result of investigation * GdipGetGenericFontFamilySansSerif: is taking first `"Microsoft Sans Serif"` font, then `Arial` [(here is the comparison)](http://www.identifont.com/differences?first=Microsoft+Sans+Serif&second=...). The replacement for Arial is `"Liberation Sans"`. [(here is the comparison)](http://www.identifont.com/differences?first=Liberation+Sans&second=Arial...). If these fonts are not found then [`Tahoma` is taken.](http://www.identifont.com/differences?first=Liberation+Sans&second=Tahom...)
* GdipGetGenericFontFamilySerif: If `"Times New Roman"` is not found, then the fonts from `FamilySansSerif` is taken. * GdipGetGenericFontFamilyMonospace: If `"Courier New"` is not found, then the fonts from `FamilySansSerif` is taken.
It seems that most risky was previous implementation of `GdipGetGenericFontFamilySansSerif`, as it used only priopritary fonts. With proposed solution all `GdipGetGenericFontFamily*` functions have free replacement from Liberation fonts.
More information about Liberation Fonts: https://en.wikipedia.org/wiki/Liberation_fonts
-- v4: gdiplus: Fix GdipGetGenericFontFamily functions according to native gdiplus.dll
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/font.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index bcf36a60090..4152cf24ce9 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -969,19 +969,22 @@ GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family, /***************************************************************************** * GdipGetGenericFontFamilyMonospace [GDIPLUS.@] * - * Obtains a serif family (Courier New on Windows) + * Obtains a monospace family (Courier New on Windows) * * PARAMS - * **nativeFamily [I] Where the font will be stored + * **nativeFamily [O] Where the font will be stored * * RETURNS * InvalidParameter if nativeFamily is NULL. + * FontFamilyNotFound if unable to get font. * Ok otherwise. */ GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamily) { GpStatus stat;
+ TRACE("(%p)\n", nativeFamily); + if (nativeFamily == NULL) return InvalidParameter;
stat = GdipCreateFontFamilyFromName(L"Courier New", NULL, nativeFamily); @@ -990,7 +993,7 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamil stat = GdipCreateFontFamilyFromName(L"Liberation Mono", NULL, nativeFamily);
if (stat == FontFamilyNotFound) - ERR("Missing 'Courier New' font\n"); + stat = GdipGetGenericFontFamilySansSerif(nativeFamily);
return stat; } @@ -1001,10 +1004,11 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilyMonospace(GpFontFamily **nativeFamil * Obtains a serif family (Times New Roman on Windows) * * PARAMS - * **nativeFamily [I] Where the font will be stored + * **nativeFamily [O] Where the font will be stored * * RETURNS * InvalidParameter if nativeFamily is NULL. + * FontFamilyNotFound if unable to get font. * Ok otherwise. */ GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily) @@ -1021,7 +1025,7 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily) stat = GdipCreateFontFamilyFromName(L"Liberation Serif", NULL, nativeFamily);
if (stat == FontFamilyNotFound) - ERR("Missing 'Times New Roman' font\n"); + stat = GdipGetGenericFontFamilySansSerif(nativeFamily);
return stat; } @@ -1029,13 +1033,14 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilySerif(GpFontFamily **nativeFamily) /***************************************************************************** * GdipGetGenericFontFamilySansSerif [GDIPLUS.@] * - * Obtains a serif family (Microsoft Sans Serif on Windows) + * Obtains a sans serif family (Microsoft Sans Serif or Arial on Windows) * * PARAMS - * **nativeFamily [I] Where the font will be stored + * **nativeFamily [O] Where the font will be stored * * RETURNS * InvalidParameter if nativeFamily is NULL. + * FontFamilyNotFound if unable to get font. * Ok otherwise. */ GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamily) @@ -1049,7 +1054,12 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamil stat = GdipCreateFontFamilyFromName(L"Microsoft Sans Serif", NULL, nativeFamily);
if (stat == FontFamilyNotFound) - /* FIXME: Microsoft Sans Serif is not installed on Wine. */ + stat = GdipCreateFontFamilyFromName(L"Arial", NULL, nativeFamily); + + if (stat == FontFamilyNotFound) + stat = GdipCreateFontFamilyFromName(L"Liberation Sans", NULL, nativeFamily); + + if (stat == FontFamilyNotFound) stat = GdipCreateFontFamilyFromName(L"Tahoma", NULL, nativeFamily);
return stat;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=132843
Your paranoid android.
=== debian11 (32 bit report) ===
winhttp: winhttp.c:3611: Test failed: got 32
On Fri May 19 15:58:33 2023 +0000, Esme Povirk wrote:
Wouldn't it be better to fall back to a monospace font Wine ships with?
Generally I would like to be close to native implementation. Based on my experiments it seems, that after unable to find `Courier New` it is looking for `Sans Serif` fonts.
Letters and symbols width and height between the `Liberation Mono` font and the corresponding `Courier New` font are identical. I don't know how it is with monospace font which Wine ships.
On Fri May 19 20:35:30 2023 +0000, Bartosz Kosiorek wrote:
Generally I would like to be close to native implementation. Based on my experiments it seems, that after unable to find `Courier New` it is looking for `Sans Serif` fonts. Letters and symbols width and height between the `Liberation Mono` font and the corresponding `Courier New` font are identical. I don't know how it is with monospace font which Wine ships.
When would an application running on Windows encounter this particular native behavior?
On Fri May 19 20:51:33 2023 +0000, Esme Povirk wrote:
When would an application running on Windows encounter this particular native behavior?
My expectation is that, because Windows ships with Courier New, this would never happen on real Windows. It doesn't matter what native does when you run it on Wine or a Windows install without the font, because application developers will never encounter that situation in testing and aren't going to write applications expecting it.
It's not going to be fully accurate behavior regardless, so why not do what the function is supposed to do and give the application a monospace font?