The global subpixel orientation setting are:
1. fontconfig builtin recommendation 10-sub-pixel-rgb.conf.
<match target="pattern"> <edit name="rgba" mode="assign"><const>rgb</const></edit> </match>
2. Current Wine, or the recommendation of some web pages.
<match target="font"> <edit name="rgba" mode="assign"><const>rgb</const></edit> </match>
This patch allows both situations to return the correct value.
Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- dlls/gdi32/freetype.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 5b1a23bf32..f60bdf4990 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -2812,6 +2812,15 @@ static void init_fontconfig(void) pFcConfigSubstitute( NULL, pattern, FcMatchFont ); default_aa_flags = parse_aa_pattern( pattern ); pFcPatternDestroy( pattern ); + + if (!default_aa_flags) + { + pattern = pFcPatternCreate(); + pFcConfigSubstitute( NULL, pattern, FcMatchPattern ); + default_aa_flags = parse_aa_pattern( pattern ); + pFcPatternDestroy( pattern ); + } + TRACE( "enabled, default flags = %x\n", default_aa_flags ); fontconfig_enabled = TRUE; }
The current Wine does not operate the following settings correctly.
<match target="pattern"> <edit name="antialias" mode="assign"><bool>true</bool></edit> <edit name="rgba" mode="assign"><const>rgb</const></edit> </match>
<match target="font"> <test name="family" compare="eq"> <string>NanumGothic</string> </test>
<edit name="antialias" mode="assign"><bool>true</bool></edit> <edit name="rgba" mode="assign"><const>none</const></edit> </match>
The correct result is as follows, but the actual result(zero) is not 5. It returns different results in slightly different fontconfig settings, but still returns incorrect results.
000d:trace:font:init_fontconfig enabled, default flags = 11 000d:trace:font:load_fontconfig_fonts fontconfig: /usr/share/fonts/TTF/NanumGothic.ttf aa 5 000d:trace:font:load_fontconfig_fonts fontconfig: /usr/share/fonts/TTF/NanumGothicBold.ttf aa 5
This issue can be simply simulated with the following commands:
$ fc-list -b NanumGothic rgba Pattern has 0 elts (size 0) (null):
$ fc-match -b NanumGothic rgba Pattern has 1 elts (size 16) rgba: 5(i)(w)
$ fc-list -b NanumGothic file scalable antialias rgba Pattern has 2 elts (size 16) file: "/usr/share/fonts/TTF/NanumGothic.ttf"(s) scalable: True(s)
$ fc-match -b NanumGothic file scalable antialias rgba Pattern has 4 elts (size 16) antialias: True(w) file: "/usr/share/fonts/TTF/NanumGothic.ttf"(w) scalable: True(w) rgba: 5(i)(w)
In conclusion, FC_ANTIALIAS and FC_RGBA through FcObjectSetAdd() does not work. But strangely, FcFontList(NULL, pettern, NULL) returns the correct results. It is necessary to investigate whether this is a bug in the fontconfig or an intended situation.
I considered creating codes that do the same thing using FcFontSort(), without using suspicious FcFontList(). However, I think it is a simple and not bad way to disable problematic Wine code.
Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- dlls/gdi32/freetype.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index f60bdf4990..08d12b262a 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -2829,7 +2829,6 @@ static void init_fontconfig(void) static void load_fontconfig_fonts(void) { FcPattern *pat; - FcObjectSet *os; FcFontSet *fontset; int i, len; char *file; @@ -2838,13 +2837,27 @@ static void load_fontconfig_fonts(void) if (!fontconfig_enabled) return;
pat = pFcPatternCreate(); - os = pFcObjectSetCreate(); - pFcObjectSetAdd(os, FC_FILE); - pFcObjectSetAdd(os, FC_SCALABLE); - pFcObjectSetAdd(os, FC_ANTIALIAS); - pFcObjectSetAdd(os, FC_RGBA); - fontset = pFcFontList(NULL, pat, os); - if(!fontset) return; + if (!pat) return; +#if 0 + { + FcObjectSet *os; + os = pFcObjectSetCreate(); + pFcObjectSetAdd(os, FC_FILE); + pFcObjectSetAdd(os, FC_SCALABLE); + pFcObjectSetAdd(os, FC_ANTIALIAS); + pFcObjectSetAdd(os, FC_RGBA); + fontset = pFcFontList(NULL, pat, os); + pFcObjectSetDestroy(os); + } +#else + fontset = pFcFontList( NULL, pat, NULL ); +#endif + if (!fontset) + { + pFcPatternDestroy(pat); + return; + } + for(i = 0; i < fontset->nfont; i++) { FcBool scalable; DWORD aa_flags; @@ -2875,7 +2888,6 @@ static void load_fontconfig_fonts(void) ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE | ADDFONT_AA_FLAGS(aa_flags) ); } pFcFontSetDestroy(fontset); - pFcObjectSetDestroy(os); pFcPatternDestroy(pat); }
On Mon, 22 Oct 2018 21:52:20 +0900, Byeongsik Jeon bsjeon@hanmail.net wrote:
In conclusion, FC_ANTIALIAS and FC_RGBA through FcObjectSetAdd() does not work. But strangely, FcFontList(NULL, pettern, NULL) returns the correct results. It is necessary to investigate whether this is a bug in the fontconfig or an intended situation.
The results of a review of the fontconfig:
This is not a fontconfig bug, but an intended situation.
The pattern returned by FcFontList() does not contain FC_RGBA. The reason why the FcFontList(NULL, pat, NULL) works correctly is because FcConfigSubstitute() matches the fontconfig config file and fills it in the pattern.
Because the fontconfig config file is very flexible, for FcConfigSubstitute() to match the user's intentions, Wine should not limit the request pattern object using FcObjectSet.
The following settings must return GGO_BITMAP, not GGO_GRAY4_BITMAP.
<edit name="antialias" mode="assign"><bool>false</bool></edit> <edit name="rgba" mode="assign"><const>none</const></edit>
Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- dlls/gdi32/freetype.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 08d12b262a..cabab0499b 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -2775,7 +2775,7 @@ static UINT parse_aa_pattern( FcPattern *pattern ) case FC_RGBA_BGR: aa_flags = WINE_GGO_HBGR_BITMAP; break; case FC_RGBA_VRGB: aa_flags = WINE_GGO_VRGB_BITMAP; break; case FC_RGBA_VBGR: aa_flags = WINE_GGO_VBGR_BITMAP; break; - case FC_RGBA_NONE: aa_flags = GGO_GRAY4_BITMAP; break; + case FC_RGBA_NONE: aa_flags = aa_flags ? aa_flags : GGO_GRAY4_BITMAP; break; } } return aa_flags;