Closed Bug 1856035 Opened 7 months ago Closed 7 months ago

Variable fonts render in maximum optical size regardless of opsz axis value

Categories

(Core :: Graphics: Text, defect)

Firefox 118
defect

Tracking

()

VERIFIED FIXED
120 Branch
Tracking Status
firefox-esr115 119+ verified
firefox118 + wontfix
firefox119 + verified
firefox120 --- verified

People

(Reporter: danburzo, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(6 files, 2 obsolete files)

7.81 MB, video/quicktime
Details
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/118.0

Steps to reproduce:

Here’s a sample variable font featuring an optical size axis: https://ateliertriay.github.io/bricolage/

Actual results:

Using the Fonts panel in the FF Dev Tools you are able to change the opsz axis value in the [12-96] range. Observe that changing the optical size only alters the spacing, but the glyphs outlines correspond to the opsz: 96 design space coordinates.

I believe this is a regression in Firefox 118.

Expected results:

Altering the opsz axis value should change the glyph outlines.

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Text' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: Text
Product: Firefox → Core
Severity: -- → S3
Flags: needinfo?(jfkthame)

Dan, what version of macOS are you on? This works as expected for me (the glyph outlines change as well as the spacing) in both FF 118.0.1 and Nightly (120.0a1), on macOS 13.4. But I'm suspicious something may have changed in Sonoma...

Flags: needinfo?(jfkthame) → needinfo?(danburzo)

Jonathan, I am indeed on macOS Sonoma (M1 processor).

Flags: needinfo?(danburzo)

Thanks for confirming this. I suspect this may be the same underlying issue as bug 1851033, where the rendering of the system font (which I believe uses optical sizing) is slightly "off" -- if we're failing to set the proper 'opsz' value, that could explain the system font issue too.

See Also: → 1851033

Yes, I was going to suggest the connection as well. It does make sense — the larger opsz would mean more slender glyphs set much wider. However, I had experienced (and logged) an "excessive spacing" issue (bug 1721612) with the default macOS font prior to Sonoma, which occurred even as opsz was working properly in Firefox.

OK, I just updated my (Intel) MacBook to Sonoma, and this issue now reproduces for me as well. I'll try to investigate what's going on....

Just confirming that not a regression in 118, even ESR affected on MacOS Sonoma.

(Marking this bug as confirmed until Jonathan decides which way he wants to do the dup'ing)

Blocks: 1837285
Status: UNCONFIRMED → NEW
Ever confirmed: true

We have the same issues with firefox 118 and fonts we produced (including a opsz axis). It worked before firefox 118 and it still works with Chrome and Safari. So, something has changed with 118 and it seems not to be the right approach. Happy to help if needed/possible. I am sure, we (Fontwerk) can give you some variable fonts with opsz axis for testing. Or simply download the trial fonts here:
Font family Case: https://fontwerk.com/fonts/case#buying-options
Font family Nice: https://fontwerk.com/fonts/nice-superfamily#buying-options

Click 'Trial' and you can download them for free. It's a subset of the original fonts, but should be enough for testing.

Yeah, this is not a recent Firefox regression, or at least that's not the whole story.... having updated to Sonoma (on an Intel-based Mac) I can reproduce the same problem with much earlier versions than 118 -- at least as far back as 96.0a1 from ~2 years ago.

It may well be (I suspect from various reports) that whether the failure happens is related to more than one factor: the macOS version, the Firefox version, the CPU architecture (because macOS APIs may behave differently even for nominally the same OS version), and the SDK version targeted by the Firefox build (which can also alter how a given API behaves).

So.... not simply a new regression, but it's definitely becoming much more widely noticed with the release of Sonoma, so we really need to get to the bottom of this.

Initial testing indicates that variation axes seem to work fine except for opsz, where we appear to be ending up with a fixed opsz that is derived from the device pixel size of the font (not the CSS px or pt size), which -- especially on a Retina screen, where device-pixel size is twice the CSS px value -- will tend to be the maximum. Moreover, once we've instantiated the font with a given opsz setting, that "sticks" even if the font size is reduced such that even the device-pixel size is within or below the opsz range.

Not yet sure where in the process the "real" opsz that we want to apply is getting lost....

(In reply to Olli Meier from comment #9)

We have the same issues with firefox 118 and fonts we produced (including a opsz axis). It worked before firefox 118 and it still works with Chrome and Safari. So, something has changed with 118 and it seems not to be the right approach.

Worth to mention that this is not a recent issue. Firefox had problems with font rendering on Apple Silicon M1/M2 Macs (bug 1721612) since 2 years ago (Firefox 90), and these bugs are still open — the macOS Sonoma has only made the situation worse across all platforms. Since Chromium browsers never had these issues, it seems like the way Firefox handles font rendering on macOS needs to be looked at.

Definitely not a simple regression.

Beginning to explore the example here (comment 0) with the Bricolage Grotesque font, I'm seeing some strange entries in the font's fvar table and I think these may be one source of problems. I've opened https://github.com/ateliertriay/bricolage/issues/9 to bring this to the designer's attention.

That's not the whole issue as far as Gecko is concerned; even after stripping out the bad named-instance entries, I'm still seeing the same broken behavior (although the Core Graphics font instances we create are at least less confused). Further investigation continues....

It appears that when a Core Text font is instantiated from a CGFont or from a font descriptor,
its optical-size setting now always gets assigned according to the font size being created,
overriding any 'opsz' variation that was already specified on the CGFont or the CTFontDescriptor.
(This seems to be a behavior change compared to older macOS versions.)

To get the desired 'opsz' setting on the Core Text font, it seems to be necessary to use
CTFontCreateCopyWithAttributes to get a modified copy of an already-existing CTFont.

This seems to work well for me in local testing. Let's see how it fares on tryserver, before asking for review.... https://treeherder.mozilla.org/jobs?repo=try&revision=0bc6ea6561c91d8e9fcfa45bc191d4dbd00b6c37

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/57fec34232bd
Rework the management of font variation settings across CoreGraphics and CoreText font instances. r=gfx-reviewers,lsalzman
Duplicate of this bug: 1851033

[Tracking Requested - why for this release]:
Now that macOS Sonoma is released, a rapidly-increasing number of users will be experiencing this, and the resulting text rendering can be quite bad (see also the dup'd bug 1851033). So I think once the fix is verified we should get it into the hands of users without waiting to ride the full train.

This needs to land now on mozilla-central, be verified by QA tomorrow morning so as that I can uplift this to the planned dot release that we build tomorrow and ship on Tuesday.

Requesting QA verification -- only required on macOS, as the files touched by the patch are Mac-specific, and not even compiled on other platforms.

We should test (a) that the rendering on Sonoma is fixed (e.g. with the example from comment 0);
and (b) that variable fonts still work as expected on earlier versions of macOS.

Flags: qe-verify+

We probably want to uplift this to Beta ahead of tomorrow's b7 build also?

Flags: needinfo?(jfkthame)

That'd be awesome, yeah. The patch is currently on autoland; I'll go ahead and nominate it for both beta and release, in hopes that QA can verify it on Nightly ASAP tomorrow.

(mozilla-release will need a rebased patch, as the CoreTextFontList refactoring that landed in bug 1170986 makes it not apply cleanly; it's functionally unchanged, just enough changes in the context to prevent a clean transplant.)

Flags: needinfo?(jfkthame)

Comment on attachment 9357254 [details]
Bug 1856035 - Rework the management of font variation settings across CoreGraphics and CoreText font instances.

Beta/Release Uplift Approval Request

  • User impact if declined: Bad rendering of variable fonts (incl. macOS system font) on Sonoma, esp. on Retina screens.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Load example page from comment 0; use Inspector to vary the Optical Size axis, and confirm that glyph shapes vary appropriately.
    (Also see dup'd bug 1851033.)
  • List of other uplifts needed: None
  • Risk to taking this patch: Medium
  • Why is the change risky/not risky? (and alternatives if risky): This changes the APIs we're using to manage font variations across the macOS frameworks; I believe the new approach uses better-supported, more reliable APIs, but it does need to be tested across all currently-supported OS versions.
    Once QA has verified that variable fonts still work across all supported versions, I would consider the risk "low", as overall this is a cleanup/simplification of the code.
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9357254 - Flags: approval-mozilla-release?
Attachment #9357254 - Flags: approval-mozilla-beta?

Comment on attachment 9357305 [details]
Bug 1856035 - [rebased to mozilla-release] Rework the management of font variation settings across CoreGraphics and CoreText font instances. r=lsalzman

Just moving the approval-mozilla-release flag to the rebased version of the patch.

Attachment #9357305 - Flags: approval-mozilla-release?
Attachment #9357254 - Flags: approval-mozilla-release?
Duplicate of this bug: 1721612
Status: ASSIGNED → RESOLVED
Closed: 7 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

Comment on attachment 9357254 [details]
Bug 1856035 - Rework the management of font variation settings across CoreGraphics and CoreText font instances.

Approved for 119.0b7

Attachment #9357254 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

It looks like this may have broken the behavior for macOS 12 on an M1 machine, according to QA testing. So we can't go ahead with uplift right now, further testing/fixing will be needed.

Verified on macOS 12 M1 with the latest Nightly 120 - build Id 20231009093538, and it seems that the fix affects the fonts. Please seen the screen record attached.

Flags: needinfo?(jfkthame)

Comment on attachment 9357305 [details]
Bug 1856035 - [rebased to mozilla-release] Rework the management of font variation settings across CoreGraphics and CoreText font instances. r=lsalzman

Not taking the uplift in our dot release as it caused regressions, thanks!

Attachment #9357305 - Flags: approval-mozilla-release? → approval-mozilla-release-

Hello.
Our investigation shows that despite the fix works for macOS 14 and macOS14 ARM, there is a regression present on macOS11, macOS12 and MacOS12 ARM.

It must be noted that macOS 10.15 , macOS13 and macOS13 ARM are not affected by this regression.

Thank you!

Donal, you might want to back this out of beta for now, given that it appears to cause a regression on macOS 11 and 12.

I'm intending to back out the patch from central, and then plan to re-land in a modified form after (hopefully) getting QA to test a try build across multiple versions.

Status: RESOLVED → REOPENED
Flags: needinfo?(jfkthame) → needinfo?(dmeehan)
Resolution: FIXED → ---

I'll back this out in the next beta push.
Keeping the ni until then.

Flags: needinfo?(dmeehan)

Not sure why the new implementation doesn't work on older OS versions,
but these APIs are inadequately documented and liable to change behavior
between releases. So just go with what works, as shown by testing.

This should not change behavior, it just merges the two versions of
CreateCTFontFromCGFontWithVariations to simplify maintenance.

Depends on D190500

The new approach works on Ventura and Sonoma, but appears to regress behavior on some
earlier releases, so put it behind a runtime version check.

Once we no longer support pre-macOS 13 versions, we can simplify this.

Depends on D190501

I have Lando'd the backout here, to fix the macOS 11/12 regression on Nightly; we can try again with the new patches once they have been reviewed & tested.

Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/fa96537be56b
Backed out changeset 57fec34232bd for regression behavior on macOS 11 and 12.
Attachment #9357305 - Attachment is obsolete: true

Just wanted to mention that my newspaper issue (in bug 1851033) disappeared with the release of Nightly 120.0a1 (2023-10-09). Many thanks.

(In reply to Martin Blom from comment #43)

Just wanted to mention that my newspaper issue (in bug 1851033) disappeared with the release of Nightly 120.0a1 (2023-10-09). Many thanks.

Unfortunately, your issue will be back in today's Nightly, as that fix had to be reverted. I'll be trying again shortly, and hope the fix "sticks" this time!

Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/31c8123d186c
Merge implementations of CreateCTFontFromCGFontWithVariations from gfxMacFont.cpp and 2d/ScaledFontMac.cpp (no change in behavior). r=gfx-reviewers,lsalzman
https://hg.mozilla.org/integration/autoland/rev/46b3ed462290
Rework the management of font variation settings across CoreGraphics and CoreText font instances, on macOS 13 and later only. r=gfx-reviewers,lsalzman

Not sure if the patch is active in the latest Nightly as Martin's comment would suggest, but I'm seeing no change in -apple-system font spacing on an M1 running macOS 13.6. Still appears with excessive letter spacing as demonstrated in bug 1721612

(In reply to Jack Roberts from comment #46)

Not sure if the patch is active in the latest Nightly as Martin's comment would suggest, but I'm seeing no change in -apple-system font spacing on an M1 running macOS 13.6. Still appears with excessive letter spacing as demonstrated in bug 1721612

Hmm, curious; bug 1721612 comment 23 seemed to indicate it was fixed. But there may be more factors in play.

To confirm, what does about:buildconfig show as "Built from https://hg.mozilla.org/mozilla-central/rev/.....`?

Assuming the (new) fix here sticks, and resolves the general optical-size failure this bug describes, we should follow up any remaining issues with the Sonoma system font in a separate bug, to better keep track of each issue.

Brindusa, Virgil, & team: thank you so much for the QA efforts yesterday, that was really valuable.

Once the revised patches (just pushed to autoland) appear in Nightly, can we please repeat the testing across all supported macOS versions (for both x64 and M1 machines), to check for any breakage with the new fix. Thanks!

Donal, FYI: as soon the revised fix is in Nightly and QA has taken a look, I'll plan to nominate for uplift; hoping we can get this fixed in time for your next beta.

Flags: needinfo?(virgil.sangerean)
Flags: needinfo?(dmeehan)
Flags: needinfo?(btot)

(In reply to Jonathan Kew [:jfkthame] from comment #47)

(In reply to Jack Roberts from comment #46)

Not sure if the patch is active in the latest Nightly as Martin's comment would suggest, but I'm seeing no change in -apple-system font spacing on an M1 running macOS 13.6. Still appears with excessive letter spacing as demonstrated in bug 1721612

Hmm, curious; bug 1721612 comment 23 seemed to indicate it was fixed. But there may be more factors in play.

To confirm, what does about:buildconfig show as "Built from https://hg.mozilla.org/mozilla-central/rev/.....`?

Assuming the (new) fix here sticks, and resolves the general optical-size failure this bug describes, we should follow up any remaining issues with the Sonoma system font in a separate bug, to better keep track of each issue.

about:buildconfig is showing Built from https://hg.mozilla.org/mozilla-central/rev/6404412771ea15ef1c719a515dd1369360fb8d4d

I think this bug may be specifically affecting the system font, because I haven't seen any other fonts affected like this. It's been this way on my machine for about two years now. It also disappears when running under Rosetta.

It seems to be exactly 0.3px wider than Safari and Chrome, from what I can tell

Status: REOPENED → RESOLVED
Closed: 7 months ago7 months ago
Resolution: --- → FIXED

Oops, I should have tagged this as leave-open; that wasn't the fix, just the backout. Re-opening, until the new fix (comment 45) merges to central.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

(In reply to Jack Roberts from comment #46)

Not sure if the patch is active in the latest Nightly as Martin's comment would suggest, but I'm seeing no change in -apple-system font spacing on an M1 running macOS 13.6. Still appears with excessive letter spacing as demonstrated in bug 1721612

Confirming this (on M1 Pro macOS 14).

The latest patch may have resolved the extremely grotesque appearance of the fonts on macOS Sonoma, but I still notice excessive letter spacing when compared to Safari and Chromium browsers, exactly as described in bug 1721612. So, this bug is still not closed.

No longer duplicate of this bug: 1721612

OK, thanks for the reports. I've re-opened bug 1721612 to follow up on the Sonoma system font spacing issue; let's wait for the patch here to be safely landed, and then follow up there with the remaining concern.

Flags: needinfo?(dmeehan)

The bug is marked as tracked for firefox118 (release). However, the bug still has low severity.

:bhood, could you please increase the severity for this tracked bug? If you disagree with the tracking decision, please talk with the release managers.

For more information, please visit BugBot documentation.

Flags: needinfo?(bhood)
Flags: needinfo?(bhood)
Status: REOPENED → RESOLVED
Closed: 7 months ago7 months ago
Resolution: --- → FIXED
See Also: → 1721612

Hello.
We have successfully verified the fix on the latest version of FF Nightly from the 11th of October.
We understand that there are some related issues regarding fonts and spacing for MacOS Sonoma and other versions, so for this we have created a document with the OS versions we tested on along with the 3 scenarios we covered. Document can be found here: "https://docs.google.com/spreadsheets/d/1QjLmYFicAHj9FX4VmgzWkxDWVdW88mZK6ObVu9s8Glg/edit#gid=0"

Please let us know if there is any other investigation or validation that we can help with.
Thank you!

Status: RESOLVED → VERIFIED
Flags: needinfo?(virgil.sangerean)
Flags: needinfo?(btot)

:jfkthame based on comment 57, is this safe for an uplift request consideration?
Fx119 goes to RC next week, the last beta 119.0b9 builds on Friday

Flags: needinfo?(jfkthame)

Comment on attachment 9357493 [details]
Bug 1856035 - Rework the management of font variation settings across CoreGraphics and CoreText font instances, on macOS 13 and later only. r=#gfx-reviewers

Beta/Release Uplift Approval Request

  • User impact if declined: Bad rendering of variable fonts with optical sizing on recent macOS versions
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Runtime version check limits the new implementation to macOS 13 and later, to minimize the risk of regressions on older OS versions.
  • String changes made/needed:
  • Is Android affected?: No
Flags: needinfo?(jfkthame)
Attachment #9357493 - Flags: approval-mozilla-beta?
Attachment #9357492 - Flags: approval-mozilla-beta?

Comment on attachment 9357492 [details]
Bug 1856035 - Merge implementations of CreateCTFontFromCGFontWithVariations from gfxMacFont.cpp and 2d/ScaledFontMac.cpp (no change in behavior). r=#gfx-reviewers

Approved for 119.0b9

Attachment #9357492 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment on attachment 9357493 [details]
Bug 1856035 - Rework the management of font variation settings across CoreGraphics and CoreText font instances, on macOS 13 and later only. r=#gfx-reviewers

Approved for 119.0b9

Attachment #9357493 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Duplicate of this bug: 1858585

Do we need to get this to ESR115 also?

Flags: needinfo?(jfkthame)

Issue has been verified on 119.0b9 version of Firefox.

Details about the OS version this has been tested in can be found here: https://docs.google.com/spreadsheets/d/1QjLmYFicAHj9FX4VmgzWkxDWVdW88mZK6ObVu9s8Glg/edit#gid=0

Comment on attachment 9357492 [details]
Bug 1856035 - Merge implementations of CreateCTFontFromCGFontWithVariations from gfxMacFont.cpp and 2d/ScaledFontMac.cpp (no change in behavior). r=#gfx-reviewers

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: With macOS Sonoma in public release, an increasing number of users will be running into this as they upgrade older OS versions
  • User impact if declined: macOS changes in recent release cause variable fonts to render incorrectly; effect can vary from slightly-wrong spacing to badly misrendered (e.g. overlapping glyphs), depending on the font involved
  • Fix Landed on Version: 119
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Change in behavior is only applied on recent macOS versions (runtime check), to avoid regressing behavior for older releases. Verified in Nightly & Beta by QA across multiple OS versions/both architectures.
Flags: needinfo?(jfkthame)
Attachment #9357492 - Flags: approval-mozilla-esr115?
Attachment #9357493 - Flags: approval-mozilla-esr115?

:jfkthame there are merge conflicts in the following:
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxMacFont.h
Could you attach a patch rebased onto esr115?

Flags: needinfo?(jfkthame)

Comment on attachment 9357492 [details]
Bug 1856035 - Merge implementations of CreateCTFontFromCGFontWithVariations from gfxMacFont.cpp and 2d/ScaledFontMac.cpp (no change in behavior). r=#gfx-reviewers

Approved for 115.4esr.

Attachment #9357492 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+

Comment on attachment 9357493 [details]
Bug 1856035 - Rework the management of font variation settings across CoreGraphics and CoreText font instances, on macOS 13 and later only. r=#gfx-reviewers

Approved for 115.4esr.

Attachment #9357493 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+

Verified also on RC1 115.4.0esr-build1.
Please check the following table for more details: https://docs.google.com/spreadsheets/d/1QjLmYFicAHj9FX4VmgzWkxDWVdW88mZK6ObVu9s8Glg/edit#gid=0.

QA Whiteboard: [qa-triaged]
Flags: qe-verify+
Attachment #9357254 - Attachment is obsolete: true
Flags: needinfo?(jfkthame)
Regressions: 1882945
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: