Closed Bug 1342741 (Menlo) Opened 7 years ago Closed 3 years ago

Use Menlo as the default monospace font on macOS

Categories

(Core :: Layout: Text and Fonts, enhancement, P3)

All
macOS
enhancement

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox53 --- wontfix
firefox54 --- wontfix
firefox55 --- wontfix
firefox88 --- fixed

People

(Reporter: kohei, Assigned: jfkthame)

References

Details

(Keywords: dev-doc-complete)

Attachments

(2 files, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #713680 +++

So Firefox 55 will change the default monospace font on Windows. Is it a good time to change the one on macOS as well? So far Courier or Courier New is used for many locales. I'd suggest Menlo [1] which is the default monospace font on Visual Studio Code and other editors [2].

[1] https://en.wikipedia.org/wiki/Menlo_(typeface)
[2] https://spin.atomicobject.com/2016/07/11/programming-fonts/
OS: Windows → Mac OS X
Good suggestion. The Menlo font has been included in macOS since 10.6 (Snow Leopard), so it's available on all versions of macOS supported by Firefox.
Blocks: 468169
Blocks: 1344750
Whats about San Francisco, which is the system font for macOS, iOS, watchOS, and tvOS?
https://developer.apple.com/fonts/
(In reply to Nomis101 from comment #2)
> Whats about San Francisco, which is the system font for macOS, iOS, watchOS,
> and tvOS?
> https://developer.apple.com/fonts/

Which macOS versions ship the new San Francisco font (or, more specifically, the monospace variant "SF Mono")? Firefox supports macOS 10.9 and later. Wikipedia says San Francisco was made the new default system font in macOS 10.11 (El Capitan), but doesn't say if the font was available in 10.9 and 10.10 as a non-default option.
(In reply to Chris Peterson [:cpeterson] from comment #3)
> Which macOS versions ship the new San Francisco font (or, more specifically,
> the monospace variant "SF Mono")? Firefox supports macOS 10.9 and later.
> Wikipedia says San Francisco was made the new default system font in macOS
> 10.11 (El Capitan), but doesn't say if the font was available in 10.9 and
> 10.10 as a non-default option.

Thats true, SF was introduced in 10.11 to replace Helvetica Neue. It is not available in 10.9 or 10.10.
Alias: Menlo

SF Mono isn't accessible to content on current macOS (Big Sur), at least, as it's a hidden system font (actually named ".SF NS Mono") only usable via Core Text UI font APIs that we don't currently use.

Switching to Menlo as the default for CSS monospace may be an option; I've pushed a try job to see what breaks.

See Also: → Consolas

It would be nice if we could update the monospace font in Fx88 or Fx89 in time for the Proton UI refresh in Fx89.

Keywords: dev-doc-needed

Switching from Courier to Menlo does result in some test breakage, e.g. see https://treeherder.mozilla.org/jobs?repo=try&revision=369050bb706e7ee680796f36ceb50e34354b6b93. (We get a few "unexpected pass" as well as "unexpected fail", actually.)

Many of these "failures" are irrelevant changes to slightly-fuzzy tests, and we can just adjust metadata as needed. The one "real" issue I see relates to hyphenation tests: a number of these fail because Menlo happens to have visually distinct glyphs for the Unicode character U+2010 HYPHEN vs the ASCII-derived U+002D HYPHEN-MINUS. Our auto-hyphenation code renders hyphen as U+2010 if available in the font (with fallback to U+002D), but the testcases compare against reference files that use U+002D.

We can't simply update the reference files to use U+2010, because then the tests would fail in an environment where the font being used doesn't support this codepoint (or if a browser chose U+002D as its preferred auto-hyphenation character).

So to work around this, I propose to update those testcases to explicitly say font-family: Courier New, Courier, monospace in place of the bare monospace generic. That means they'll use Courier [New] if available, avoiding the Menlo quirk on macOS, but otherwise they will happily run with whatever generic monospace is provided.

Without this fix, changing the macOS monospace font causes this test to start failing.

The use of getCharacterDims() to figure out target points in terms of character size is slightly off,
because the result of getBoundingClientRect includes the border around the element. So to get the
actual advance of the individual character, we need to subtract that. This accounts for the unexpected
platform-dependent result of the "split selection" test, because across the width of 4 characters
the error accumulates by a platform-dependent factor (depending on the ratio of the true character
width to the constant extra amount due to the border).

(This patch does not address the fact that selectAtPoint is selecting two adjacent characters when
only one would be expected; that is a bug to be handled separately. This just makes the existing
test more accurate/consistent.)

Depends on D107284

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

For some additional context, Safari allows web content to use SF Mono as ui-monospace, see https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/ .

Yes, that's what I'd expect ui-monospace to map to (for Latin etc). We haven't implemented any of the new ui-* generics yet (and we really should move to the proper CTFont APIs for this, rather than just creating -- and having to maintain -- yet more prefs font lists to handle them).

Attachment #9207038 - Attachment is obsolete: true
Attachment #9207039 - Attachment description: Bug 1342741 - Use Menlo as default monospace font on macOS. r?cpeterson → Bug 1342741 - Use Menlo as default monospace font on macOS. r=mstange
Attachment #9207041 - Attachment description: Bug 1342741 - Adjust a few testcases that are sensitive to glyph/metrics differences in Menlo. r?cpeterson → Bug 1342741 - Adjust a few testcases that are sensitive to glyph/metrics differences in Menlo. r=mstange
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/02b69c938fbe
Use Menlo as default monospace font on macOS. r=mstange
https://hg.mozilla.org/integration/autoland/rev/1154df798888
Adjust a few testcases that are sensitive to glyph/metrics differences in Menlo. r=mstange
Flags: needinfo?(jfkthame)
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/28009 for changes under testing/web-platform/tests
Upstream PR was closed without merging
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/931336f048ab
Use Menlo as default monospace font on macOS. r=mstange
https://hg.mozilla.org/integration/autoland/rev/74e762c1fb14
Adjust a few testcases that are sensitive to glyph/metrics differences in Menlo. r=mstange
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
Upstream PR merged by moz-wptsync-bot

Added to the release notes.

Flags: needinfo?(jfkthame)
No longer blocks: 468169, 1344750
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: