w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.43k stars 656 forks source link

[css-fonts] font-family:monospace isn't a good fit for authors' desire #3707

Open litherum opened 5 years ago

litherum commented 5 years ago

When authors think "I want my text to be monospaced," they apply font-family:monospace. However, there's a problem when applying this to internationalized text.

For example, consider <span lang="zh-Hans" style="font-family: monospace;">我在学习程序语言Python。</span>. If you consider the lang attribute, and pick a Simplified Chinese font, that font (likely) supports Latin characters, and they (likely) aren't monospaced. If you don't consider the lang attribute, you end up with bad choices of fonts in the first place.

If you require that any font that monospace maps to have the isFixedPitch bit set in the post table, you've just disqualified many fonts that you shouldn't have, because fonts may be monospaced for their primary script but not for their other supported scripts. Also that bit can just be set incorrectly.

It seems like the choice to handle monospace at the font selection level, rather than as a distinct setting, was unfortunate. However, it's probably too late to fix this; I'm just filing this issue for posterity.

litherum commented 5 years ago

Also: I wonder if we're making the same mistake with font-family:emoji.

kojiishi commented 5 years ago

Agree this provides non-ideal experience today.

Just to add history, CJK fonts used to provide two variants, one of which has fixed ASCII and all CJK characters have double-widths of the ASCII characters. MS Mincho/Gothic on Windows, or Osaka Mono on Mac had such characteristics and authors assumed that monospace pick such fonts.

Today, neither Windows nor Mac provides such fonts, or only poor quality fonts. Renewing the definition by investigating what authors want, including i18n, might benefits authors.