Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- v2: nothing changed. [2/3] patch changed. v1: The global subpixel alignment setting are:
1. fontconfig builtin 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.
dlls/gdi32/freetype.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 5b1a23bf32..7cc42b2a47 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) + { + FcPattern *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; }
Signed-off-by: Byeongsik Jeon bsjeon@hanmail.net --- v2: This is not a fontconfig bug, but an intended situation.
The pettern 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.
v1: 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 settings, but still returns incorrect results.
00d: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.
dlls/gdi32/freetype.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 7cc42b2a47..4fc4411a4a 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,15 @@ 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; + + fontset = pFcFontList( NULL, pat, NULL ); + if (!fontset) + { + pFcPatternDestroy(pat); + return; + } + for(i = 0; i < fontset->nfont; i++) { FcBool scalable; DWORD aa_flags; @@ -2875,7 +2876,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 Wed, Oct 24, 2018 at 01:07:12AM +0900, Byeongsik Jeon wrote:
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 7cc42b2a47..4fc4411a4a 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,15 @@ 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;
Please remove the various ObjectSet* functions from the (MAKE|LOAD)_FUNCPTR macros.
Huw.
The following settings must return FC_BITMAP, not FC_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 4fc4411a4a..1895bc3888 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;