WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
265182
[FreeType] Do not special case the "sans" font family name
https://bugs.webkit.org/show_bug.cgi?id=265182
Summary
[FreeType] Do not special case the "sans" font family name
Adrian Perez
Reported
2023-11-21 00:48:33 PST
In “Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp” the is one instance where we are special-casing the “sans” font family name, which is NOT a CSS generic font family name, in the first line of the following function: static inline bool isCommonlyUsedGenericFamily(const String& familyNameString) { return equalLettersIgnoringASCIICase(familyNameString, "sans-serif"_s) || equalLettersIgnoringASCIICase(familyNameString, "serif"_s) || equalLettersIgnoringASCIICase(familyNameString, "monospace"_s) || equalLettersIgnoringASCIICase(familyNameString, "fantasy"_s) #if PLATFORM(GTK) || equalLettersIgnoringASCIICase(familyNameString, "-webkit-system-font"_s) || equalLettersIgnoringASCIICase(familyNameString, "-webkit-system-ui"_s) #endif || equalLettersIgnoringASCIICase(familyNameString, "cursive"_s); } Matching the “sans” name here skips a part of the CSS font fallback algorithm, which results in websites which use e.g. “font-family: sans” to end up picking an apparently semi-random choice of font depending on how FontConfig is configured. Given that a number of Linux distributions include font packages which have drop-in FontConfig configuration files which may define replacements and/or aliases for a family named “sans”, each user may see a slightly different outcome due to this bug. The solution is to do like the rest of the WebKit font implementations and not handle “sans” as a generic family name -- because it is not.
Attachments
Screenshot of two browser, one of them with the “sans” matching removed
(1.42 MB, image/png)
2023-11-21 00:54 PST
,
Adrian Perez
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Adrian Perez
Comment 1
2023-11-21 00:54:55 PST
Created
attachment 468705
[details]
Screenshot of two browser, one of them with the “sans” matching removed Here's a screenshot comparing how WebKitGTK behaves today (left), and with the match for “sans” removed (right). The odd choice on the left was because this particular system does not have a FontConfig “sans” alias in the configuration, and FontConfig ends up picking a symbols font (Font Awesome), which has these oddball latin characters.
Adrian Perez
Comment 2
2023-11-21 01:19:06 PST
(In reply to Adrian Perez from
comment #1
)
> Created
attachment 468705
[details]
> Screenshot of two browser, one of them with the “sans” matching removed > > Here's a screenshot comparing how WebKitGTK behaves today (left), and > with the match for “sans” removed (right). The odd choice on the left > was because this particular system does not have a FontConfig “sans” > alias in the configuration, and FontConfig ends up picking a symbols > font (Font Awesome), which has these oddball latin characters.
Of course if I make sure that there is a “sans” alias defined in the FontConfig configuration, that ends up being picked. I think in case somebody has an oddball configuration like the one I used for testing, having a serif font picked as fallback is still better than picking a symbols font.
Adrian Perez
Comment 3
2023-11-21 01:25:10 PST
Pull request:
https://github.com/WebKit/WebKit/pull/20776
EWS
Comment 4
2023-11-21 03:15:51 PST
Committed
271007@main
(9479bf3bdea7): <
https://commits.webkit.org/271007@main
> Reviewed commits have been landed. Closing PR #20776 and removing active labels.
Radar WebKit Bug Importer
Comment 5
2023-11-21 03:16:16 PST
<
rdar://problem/118680927
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug