WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
300620
REGRESSION (Safari 26): `@font-face` / `FontFace.family` fails when font family name contains space (e.g. "Lato 2")
https://bugs.webkit.org/show_bug.cgi?id=300620
Summary
REGRESSION (Safari 26): `@font-face` / `FontFace.family` fails when font fami...
snandhu361
Reported
2025-10-13 03:24:18 PDT
Description: After the recent Safari update, when creating a FontFace object with a family name containing a space (for example "Lato 2"), the FontFace.family property now returns a quoted value ("\"Lato 2\""). This issue did not occur in previous Safari versions — it previously returned the expected unquoted string ("Lato 2"). This regression affects applications that rely on the unquoted family name for caching or mapping logic. Steps to Reproduce: const font = new FontFace("Lato 2", "url('Lato2.woff2')"); console.log(font.family); Observed Result (Safari 18+): "\"Lato 2\"" Expected Result (previous behavior / other browsers): "Lato 2" Context: My application implements a delayed font loading mechanism. After each font is rendered, a div is dynamically created, and a key map is maintained to reuse fonts by their family names. Example: fontMap.set("Lato 2", fontFace); After Safari’s recent change, fontFace.family returns "\"Lato 2\"", which causes the key map lookup to fail, breaking the delayed loading logic. Expected Behavior: Safari should preserve the original unquoted font-family name (e.g. "Lato 2") when accessed through FontFace.family. Actual Behavior: Safari now returns a quoted value ("\"Lato 2\""), leading to incorrect string comparison and logic errors. Additional Notes: The font itself renders correctly on the page. The issue only appears in JavaScript when inspecting the FontFace.family property. Chrome and Firefox continue to return the expected unquoted string. The regression likely stems from the recent spec compliance fix (142009630), which restricted @font-face descriptors to a single value.
Attachments
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2025-10-13 14:09:44 PDT
Is the "app" mentioned here a website, or an iOS app, or something else? If it’s a website, then some things to figure out: - Is this a request for different behavior in Safari than other web browsers? - If not, is this important interoperability concern already covered by a Web Platform Test? - Is the specification wrong, or was this a mistake made in passing while implementing the specification not required by the specification? If it’s an iOS app maybe we need a compatibility hack of some sort for older apps.
snandhu361
Comment 2
2025-10-14 03:48:58 PDT
Hi, thanks for the quick response. This issue occurs in a web application (website) — not an iOS app. To answer your questions: It’s not a request for different behavior from other browsers. In fact, Chrome and Firefox both still return the unquoted family name (e.g., "Lato 2") for FontFace.family. Safari used to behave the same until the recent change (142009630). It appears to be a regression / interoperability issue — Safari now returns "\"Lato 2\"", which causes cross-browser inconsistency. As per the CSS Font Loading specification, the FontFace.family attribute should reflect the font’s family name as a simple string — not a quoted version. So this seems to be a small parsing or serialization error introduced by the spec compliance fix, rather than a spec requirement.
Radar WebKit Bug Importer
Comment 3
2025-10-14 15:57:08 PDT
<
rdar://problem/162637501
>
Darin Adler
Comment 4
2025-10-14 15:58:05 PDT
I’ll try to look at this myself when I have a chance, but I’m hoping someone else gets to it first. We should add a Web Platform Test for this!
Radar WebKit Bug Importer
Comment 5
2025-10-14 15:58:11 PDT
<
rdar://problem/162637585
>
Darin Adler
Comment 6
2025-10-14 16:08:13 PDT
While waiting for this to be fixed, or for compatibility with the versions of Safari already in use with this bug, any website running into this should have a simple workaround: assuming we don’t need compatibility with font names that happen to start with a quotation mark, we can write simple JavaScript code to strip the quotes after getting the value of the family attribute.
snandhu361
Comment 7
2025-10-14 20:38:33 PDT
Thanks for confirming and for the suggested workaround. I’ve implemented a simple normalization step to strip quotes from FontFace.family values, which resolves the issue for now. It’d be great if future Safari versions align with Chrome/Firefox behavior, so the workaround isn’t needed long-term.
Alexey Proskuryakov
Comment 8
2025-10-15 10:11:20 PDT
<
rdar://problem/162637501
>
Tim Nguyen (:ntim)
Comment 9
2025-10-15 16:32:09 PDT
Easy steps to reproduce: 1. visit wpt.live 2. run this in the console: ``` font = new FontFace("IcTestFullWidth Bold", "url('
https://wpt.live/css/css-values/resources/IcTestFullWidth.woff2
')"); font.load().then(() => { console.log(font.family); }); ```
Tim Nguyen (:ntim)
Comment 10
2025-10-15 17:17:29 PDT
Using serializeIdentifier here:
https://searchfox.org/wubkat/rev/7c3fea2e73edc7d7c5373dda8f22bf2c44b1293e/Source/WebCore/css/CSSMarkup.cpp#146-149
would probably fix the issue, but it would affect more than just descriptor (also the font-family CSS property).
Tim Nguyen (:ntim)
Comment 11
2025-10-15 17:18:30 PDT
The entry point of this code is `parseFontFaceFontFamily`
Darin Adler
Comment 12
2025-10-15 19:26:37 PDT
I suspect we want to change the result of the family method of CSSFontFace to not be quoted have the font-family CSS property continue to return a list of quoted strings. Need to check the relevant CSS specifications to see where that’s made clear. To do that we would need to change the body of the CSSFontFace::family function to not call getPropertyValue(CSSPropertyFontFamily).
Darin Adler
Comment 13
2025-10-15 19:27:31 PDT
It might mean we also want to change the behavior of setting family on CSSFontFace. That function, CSSFontFace::setFamily currently takes a list of quoted family names.
Darin Adler
Comment 14
2025-10-15 19:43:04 PDT
One note is that the font-family descriptor in a @font-face from is a <family-name> <
https://www.w3.org/TR/css-fonts-4/#descdef-font-face-font-family
>, whereas the font-family CSS property from CSS style from the CSS Fonts Module is a [ <family-name> | <generic-family> ]#. <
https://www.w3.org/TR/css-fonts-4/#propdef-font-family
>. But <family-name> is <string> | <custom-ident>+. I can’t find a place where it’s specified when <family-name> should serialized as a <string> and when it should be serialized as <custom-ident>+.
Darin Adler
Comment 15
2025-10-15 19:47:58 PDT
For authors, the CSS Fonts Module says "to avoid mistakes in escaping, it is recommended to quote font family names that contain white space, digits, or punctuation characters other than hyphens" and "if you really have a font whose name is the same as one of the <generic-family> names, or the system font names, or the CSS-wide keywords, it must be quoted". I could imagine turning these author rules into a serialization rule to determine when to serialize a family name as a string and when to serialize them as an identifier. It’s really unclear what specification rule prevents the use of a quoted string when serializing!
Tim Nguyen (:ntim)
Comment 16
2025-10-17 09:55:46 PDT
Here are some testcases:
https://jsfiddle.net/ntim/q7t81jgh/
Firefox seems to have the most sensible behavior, from Elika's words: - Adds quotes around names that are also keywords. - Doesn't add quotes for spaces. - Only adds quotes for numbers if they're at the start of a word (basically stuff would otherwise parse as a dimension). - Adds quotes for punctuation.
fantasai
Comment 17
2025-10-17 10:06:33 PDT
Nah, actually, I confused myself. Firefox is tracking whether the author specified quotes or not, and serializing to match. I think either of these approaches would work, fwiw.
Darin Adler
Comment 18
2025-10-17 10:09:05 PDT
Not to be a broken record, but I’d really like to specify this and test it in WPT rather than just choosing what WebKit will do.
fantasai
Comment 19
2025-10-17 10:27:54 PDT
So the question of how to serialize font-family values is
https://github.com/w3c/csswg-drafts/issues/5846
However that doesn't help with values like "Lato 2" which is not valid as a font-family value (whether as a property value or as a descriptor value) unless it's unquoted or unescaped. The issue here is about the FontFace.family API, which is defined here:
https://drafts.csswg.org/css-font-loading/#dom-fontface-family
We previously had interop on returning just bare strings here -- which is reasonable, because the font-family *descriptor*, unlike the font-family *property*, never has any value that isn't fundamentally just a string. (It doesn't accept generic family keywords.) Given previous interop, and this evidence that changes are likely not Web-compatible, and the fact that it's a pretty reasonable behavior to have in the first place for this API, I think we should revert WebKit's behavior and ask the spec to match implementations here.
Darin Adler
Comment 20
2025-10-17 10:31:17 PDT
(In reply to fantasai from
comment #19
)
> The issue here is about the FontFace.family API, which is defined here: >
https://drafts.csswg.org/css-font-loading/#dom-fontface-family
> We previously had interop on returning just bare strings here -- which is > reasonable, because the font-family *descriptor*, unlike the font-family > *property*, never has any value that isn't fundamentally just a string. (It > doesn't accept generic family keywords.) Given previous interop, and this > evidence that changes are likely not Web-compatible, and the fact that it's > a pretty reasonable behavior to have in the first place for this API, I > think we should revert WebKit's behavior and ask the spec to match > implementations here.
One confusing thing about FontFace.family and the CSS specifications is that the specification says "parsed the same as the corresponding @font-face descriptors". I don’t fully understand the implications of that, but it doesn’t seem entirely consistent with “just a string”.
Darin Adler
Comment 21
2025-10-17 10:34:23 PDT
To implement “just a string” in WebKit without changing anything outside FontFace I would probably change the getter and setter implementation for the family property of FontFace and I’d want to add some tests for both the getter and setter in WPT. This wouldn’t change the behavior of @font-face parsing or have any effect on serialization of the font-family property or of the font-family descriptor if serialized as part of @font-face.
fantasai
Comment 22
2025-10-17 10:51:07 PDT
> I don’t fully understand the implications of that, but it doesn’t seem entirely consistent with “just a string”.
Yeah, that's why I was saying we should ask the spec to change to match implementations here. @snandhu361 You mentioned @font-face in the title, but not in the steps to reproduce. What exactly is the problem with @font-face?
Darin Adler
Comment 23
2025-10-18 18:56:04 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/52623
EWS
Comment 24
2025-10-19 15:51:04 PDT
Committed
301793@main
(3208096991b9): <
https://commits.webkit.org/301793@main
> Reviewed commits have been landed. Closing PR #52623 and removing active labels.
EWS
Comment 25
2025-10-20 12:15:06 PDT
Committed
301765.28@safari-7623-branch
(bf7a790fd42c): <
https://commits.webkit.org/301765.28@safari-7623-branch
> Reviewed commits have been landed. Closing PR #3807 and removing active labels.
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