w3c / csswg-drafts

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

[css-fonts][css-text] Proposed Variable font spacing axis and CSS letter-spacing property #2102

Open svgeesus opened 6 years ago

svgeesus commented 6 years ago

From John Hudson on www-style:

This is a proposal to register a standard OpenType design variations axis to affect glyph spacing: https://github.com/Microsoft/OpenTypeDesignVariationAxisTags/blob/master/Proposals/Spacing_Axis/ProposalSummary.md

Implementations of this 'spac' axis in a variable font would enable font makers to provide superior results in letter-spacing conditions by providing proportional interaction between letter-spacing distance and kerning (via variable GPOS adjustments in the kerning values along the 'spac' axis), and by managing the design of joining letters in Arabic, Devanagari, etc. and in connecting styles of Latin or other scripts, which currently get broken connections when letter-spacing is applied.

I'm interested to hear ideas on how support for variable fonts with a 'spac' feature might be implemented in CSS. A couple of obvious options occur to me:

  1. User agents could apply 'spac' axis adjustments by default when the letter-spacing property is used to expand or contract spacing in text set in a variable font including this axis.

  2. The letter-spacing property could have a new value defined to allow authors to opt in to using 'spac' axis adjustments when applying letter-spacing.

Other possibilities or preferred approaches?

svgeesus commented 6 years ago

https://github.com/Microsoft/OpenTypeDesignVariationAxisTags/issues/11

SergeyMalkin commented 6 years ago

Just applying axis value to the font doesn't seem to be enough. I don't see what font can do on its own, beyond simply adding space between or around glyphs (with some adjustments to glyph outlines or kerning). It doesn't cover case when multiple adjacent runs are present, including runs of different scripts, fonts, direction, on line boundary. More complex protocol between UA and font may be needed here.

litherum commented 6 years ago

If the proposal is for a font to implement letter-spacing itself, that’s not a great idea because browsers have lots of logic to answer the question of “what is a letter?” I’m pretty concerned about every font having to re-encode ICU breaking-iterator logic inside their GPOS tables.

A better solution would be for some way for a font to inform the browser with advice about how to place glyphs in the presence of letter-spacing, but the letter-spacing logic itself remains in the browser.

litherum commented 6 years ago

Any other thoughts? I see @SergeyMalkin and myself pushing against this; in the absence of anything else I'll close the issue.

svgeesus commented 6 years ago

Was just raising for awareness and possible discussion. I'm fine with closing. Maybe John Hudson has other opinions, but I suspect he was mainly musing how it would work with the rest of CSS.