[PATCH] gdi32: Use the default fallback list before trying Fontconfig.

Huw Davies huw at codeweavers.com
Tue Dec 18 02:47:54 CST 2018


On Fri, Dec 14, 2018 at 10:44:56PM +0900, Akihiro Sagawa wrote:
> 
> This fixes a regression introduced by 11ab9ff7b3c43bb41c0325fe9417b1d7f44ad516.
> It overrides default fallback font fix for Latin scripts as seen in
> 3b9669017bc8425f04860f331d8a1f689c8d63e0.
> 
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46285
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46244
> Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
> ---
>  dlls/gdi32/freetype.c | 44 +++++++++++++++++++++++++++++---------------
>  1 file changed, 29 insertions(+), 15 deletions(-)
> 

> diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
> index e07aada..f5b53ad 100644
> --- a/dlls/gdi32/freetype.c
> +++ b/dlls/gdi32/freetype.c
> @@ -5452,6 +5452,7 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
>      FontSubst *psub = NULL;
>      DC *dc = get_physdev_dc( dev );
>      const SYSTEM_LINKS *font_link;
> +    const WCHAR **fallback_list;
>  
>      if (!hfont)  /* notification that the font has been changed by another driver */
>      {
> @@ -5642,25 +5643,38 @@ static HFONT freetype_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
>         so mask with 0xF0 before testing */
>  
>      if((lf.lfPitchAndFamily & FIXED_PITCH) ||
> -       (lf.lfPitchAndFamily & 0xF0) == FF_MODERN)
> +       (lf.lfPitchAndFamily & 0xF0) == FF_MODERN) {
>          strcpyW(lf.lfFaceName, defFixed);
> -    else if((lf.lfPitchAndFamily & 0xF0) == FF_ROMAN)
> +        fallback_list = default_fixed_list;
> +    }
> +    else if((lf.lfPitchAndFamily & 0xF0) == FF_ROMAN) {
>          strcpyW(lf.lfFaceName, defSerif);
> -    else if((lf.lfPitchAndFamily & 0xF0) == FF_SWISS)
> +        fallback_list = default_serif_list;
> +    }
> +    else if((lf.lfPitchAndFamily & 0xF0) == FF_SWISS) {
>          strcpyW(lf.lfFaceName, defSans);
> -    else
> +        fallback_list = default_sans_list;
> +    }
> +    else {
>          strcpyW(lf.lfFaceName, defSans);
> -    LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
> -        if(!strncmpiW(family->FamilyName, lf.lfFaceName, LF_FACESIZE - 1)) {
> -            font_link = find_font_link(family->FamilyName);
> -            face_list = get_face_list_from_family(family);
> -            LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
> -                if (!(face->scalable || can_use_bitmap))
> -                    continue;
> -                if (csi.fs.fsCsb[0] & face->fs.fsCsb[0])
> -                    goto found;
> -                if (font_link != NULL && csi.fs.fsCsb[0] & font_link->fs.fsCsb[0])
> -                    goto found;
> +        fallback_list = default_sans_list;
> +    }
> +
> +    for (; *fallback_list; fallback_list++) {

Can you explain why you need to loop through the list.  It should be
sorted so that either the first entry exists or no entries exist.

> +        WCHAR face_name[LF_FACESIZE];
> +        strcpyW(face_name, *fallback_list);

Why do you need the strcpy here?

> +        LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) {
> +            if(!strncmpiW(family->FamilyName, face_name, LF_FACESIZE - 1)) {
> +                font_link = find_font_link(family->FamilyName);
> +                face_list = get_face_list_from_family(family);
> +                LIST_FOR_EACH_ENTRY( face, face_list, Face, entry ) {
> +                    if (!(face->scalable || can_use_bitmap))
> +                        continue;
> +                    if (csi.fs.fsCsb[0] & face->fs.fsCsb[0])
> +                        goto found;
> +                    if (font_link != NULL && csi.fs.fsCsb[0] & font_link->fs.fsCsb[0])
> +                        goto found;
> +                }
>              }
>          }
>      }

> 




More information about the wine-devel mailing list