Firefox is not falling back to weight 500 webfont when non-exisitant 700 is specified, apparently bolding artificially instead
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox67 | --- | affected |
People
(Reporter: twisniewski, Unassigned)
References
Details
(Whiteboard: [webcompat])
Attachments
(1 file)
|
497 bytes,
text/html
|
Details |
The attached test-case seems to render in Firefox with an artificial 700 font-weight for a webfont which does not have that weight, but which has a 500 weight available instead.
In fairness that's what the stylesheet is asking for (font-weight:700), but according to MDN for fallback font-weights:
If the exact weight given is unavailable,
If a weight greater than 500 is given, look for available weights greater than the target, in ascending order. If no match is found, look for available weights less than the target, in descending order.
Chrome is doing just that, and selecting the 500 weight.
This is causing a noticeable layout difference on CapitalOne's site, as reported in https://webcompat.com/issues/25231
Comment 1•7 years ago
|
||
Looks to me like Firefox is correct here, or at least "not wrong". The @font-face rule in the testcase declares the resource as representing font-weight:400. The style calls for font-weight:700; the nearest (only) available face in the family is the 400 one, and so -- because the requested weight is bold, and the available one isn't -- we apply a synthetic-bold effect to it.
Safari does something similar, FWIW.
To prevent this, the @font-face rule should declare the appropriate (bold) weight. Or the synthetic-bold effect can be suppressed by adding font-synthesis:none to the stylesheet.
| Reporter | ||
Comment 2•7 years ago
|
||
Hmm, I see. Sounds to me like I should file a bug against Blink. Or does the spec perhaps provide too much wiggle-room here, and a bug should filed against it?
Comment 3•7 years ago
|
||
The spec allows (but does not require) UAs to implement a synthetic-bold effect when a bold font-weight is requested, but no actual bold weight is available in the family. Note, though, that even if synthetic-bold were required, the result may still vary between UAs (and between platforms) as the exact implementation of such an effect is not specified.
However, it's interesting to note that Blink does apply synthetic-bold in some cases; e.g. try font-weight:bold with the Zapfino family (which just has a single weight) on macOS, or add font-weight:bold to a testcase like layout/reftests/font-face/woff2-1.html).
What I think is happening is that Blink is deciding whether or not synthetic-bold is needed based on the weight declared by the font itself (e.g. in the OS/2 table), and so in the CapitalOne example where the resource is Optimist_W_SBd, it sees that the face is already bold and does not apply an additional effect. Firefox (and Safari), OTOH, base this decision on the font-weight descriptor from the @font-face rule, which declares this face as having a regular weight, and so they do apply synthetic bold.
This issue is specifically addressed by the spec, which says:
The value for these font face style attributes is used in place of the style implied by the underlying font data. This allows authors to combine faces in flexible combinations, even in situations where the original font data was arranged differently. User agents that implement synthetic bolding and obliquing must only apply synthetic styling in cases where the font descriptors imply this is needed, rather than based on the style attributes implied by the font data.
So it is clear that the attributes found in the font data are to be overridden by the @font-face declaration.
Conclusion: yes, it's a Blink bug: it's basing the synthetic-bold decision on the font data and not on the @font-face descriptor.
Comment 4•7 years ago
|
||
Closing this as invalid, per comment 3: we're handling this as the spec requires.
Description
•