WICG / canvas-formatted-text

Other
82 stars 17 forks source link

On Font preferences and handling missing external fonts #33

Open travisleithead opened 3 years ago

travisleithead commented 3 years ago

(This is internal Microsoft feedback from a review of the spec by resident expert @petercon. Re-posting here with permission.)


Looking at the set of CSS properties supported: you have the shorthand font property, but none of the basic properties (font-family, etc.). You do have font-feature-settings, which is good, but not font-variation-settings.

Speaking of basic font properties…

mike: the font id is useless if I don't know which font it was resovled ot.

In the Web world, fonts have always been vague in the sense that the declarative content can indicate preferences, but only the UA actually knows what is displayed. I would suspect for apps that might want to use these APIs that there would be scenarios in which they need to know what font is actually selected in the context. (Ok, this is where my Web knowledge gets sketchy.) IIUC, Canvas works pretty much the same as HTML wrt handling of font styling, so a (not @font-face) font might be assumed to be present on a platform but turn out not to be present, and even an @font-face font might not be available when rendering occurred. Wouldn’t developers at times want to confirm what font is actually being used to compute the format or to render?

And what happens if the font isn’t available when format() is called but then is available milliseconds later when drawFormattedText() is called? Or is that guaranteed not to happen?

mike: might need something more than just font-family (good note)

… font-family will be a unique identifier…

Font family alone probably won’t be sufficient for all scenarios, given the indeterminacy allowed in the CSS Fonts font matching logic.