Re: [css-houdini-drafts] [css-typed-om] CSSFontFace value (#899)

The Houdini Task Force just discussed `Opaque font P&V type for PaintWorklet font rendering`, and agreed to the following:

* `RESOLVED: disable svg text when in a paint worklet, possibly falling back to svg native`

<details><summary>The full IRC log of that discussion</summary>
&lt;Rossen_> Topic: Opaque font P&amp;V type for PaintWorklet font rendering<br>
&lt;Rossen_> github: https://github.com/w3c/css-houdini-drafts/issues/899<br>
&lt;emilio> flackr: So while experimenting with PaintWorklet I decided to use fonts and the general idea seems to be that we avoid everything that relies on the document data<br>
&lt;heycam> q+<br>
&lt;emilio> ... I wonder if we could expose a font type so that we could resolve the font on the main thread and pass it down to the paint worklet<br>
&lt;emilio> bkardell_: so like a transferable font?<br>
&lt;AmeliaBR> q+<br>
&lt;emilio> flackr: I'd expect it to be more like an &lt;image> type<br>
&lt;emilio> ... I don't expect to be able to do anything with it other than drawing<br>
&lt;emilio> myles: why not just passing a string?<br>
&lt;emilio> flackr: because that requires going through the platform code<br>
&lt;emilio> myles: should just be thread-safe<br>
&lt;emilio> TabAtkins: we disallow parsers on the worklet<br>
&lt;emilio> ... Chromium's css parser is not thread-safe<br>
&lt;emilio> myles: I'd be hesitant to add more API surface until there's more investigation<br>
&lt;emilio> iank_: you have a side-channel, you don't know if that font is loaded<br>
&lt;emilio> myles: I thought these weren't supposed to have any document data<br>
&lt;heycam> emilio: the fact that Chromium's CSS parser is not thread safe is a Chromium limitation<br>
&lt;emilio> myles: you want @font-face then this problem is really hard<br>
&lt;emilio> flackr: limiting it to system font limits the use cases<br>
&lt;emilio> myles: I think it'd be a good start<br>
&lt;emilio> TabAtkins: if we want to do font-face you could be able to send fontface objects<br>
&lt;emilio> myles: and no fallback/<br>
&lt;emilio> *?<br>
&lt;emilio> TabAtkins: you can do it yourself<br>
&lt;emilio> myles: that's not great<br>
&lt;emilio> TabAtkins: or send an array<br>
&lt;Rossen_> q?<br>
&lt;bkardell_> s/*?bkardell: can you not just transfer the array of resolved fonts?<br>
&lt;emilio> myles: I think we can choose between two worlds, on where you (maybe temporarily) only have access to system fonts, and one where the worklet is associated with a document and they share the same loading context and there's no need to transfer anything<br>
&lt;myles> s/system/installed/<br>
&lt;AmeliaBR> s/*?/bkardell: can you not just transfer the array of resolved fonts?/<br>
&lt;AmeliaBR> s/s\/*?bkardell: can you not just transfer the array of resolved fonts?//<br>
&lt;Rossen_> ack heycam<br>
&lt;emilio> heycam: I was going to ask with the relationship with the font loading api, but if for now there's only going to be installed fonts<br>
&lt;emilio> ... If we decide we want font-face i think we may want to not tie it to the document, and the document would have the same FontFaceSet<br>
&lt;emilio> hober: Wouldn't that require sync access from the worklet?<br>
&lt;hober> s/sync/network/<br>
&lt;emilio> heycam: if you want all the font types in the doc then sure, but we could limit it for blobs and array buffers and such<br>
&lt;emilio> [missed]<br>
&lt;emilio> heycam: you can have svg images with text in it<br>
&lt;emilio> myles: but that's not the same, no subpixel AA, etc.<br>
&lt;emilio> TabAtkins: we cannot avoid putting text on worklets at some point<br>
&lt;dbaron> heycam was talking about &lt;svg:text><br>
&lt;emilio> AmeliaBR: svg images has similar restrictions where there are no font-faces and such and it's isolated from the main document rendering<br>
&lt;emilio> ... in a way it's not that much different from how paint() is supposed to work<br>
&lt;emilio> ... if we have the same restrictions on the paint worklet so that it it can define a font-face where it doesn't have network access<br>
&lt;TabAtkins> q+<br>
&lt;emilio> ... so it is not as different as &lt;text> in an svg image<br>
&lt;emilio> ... whether that addresses authoring use-cases is another question<br>
&lt;Rossen_> ack AmeliaBR<br>
&lt;emilio> ... saying that it can only use installed fonts doesn't seem aligned with paint()<br>
&lt;emilio> ... paint is for graphical effects so you want to have control over the fonts you're drawing<br>
&lt;bkardell_> AmeliaBR:  is better articulating the question I was attempting to ask myles  earlier about the use case -- for paint<br>
&lt;emilio> ... if you want textual content it shouldn't be using paint() but be content instead<br>
&lt;emilio> ... the proposal that flackr made was adding a new typed om type for fonts<br>
&lt;emilio> ... which i think it's a sensible thing for typed om to be able to represent<br>
&lt;emilio> ... we could set that from canvas as well<br>
&lt;emilio> ... some other people were talking about FontFace object, but fonts is much more complicated, it's a list of fonts with fallback, etc.<br>
&lt;emilio> ... we should aim for typed om to be able to represent all CSS data types like the font shorthand<br>
&lt;emilio> ... but that's a different question from text in canvas in paint()<br>
&lt;emilio> ... i'm not sure where in the cycle we'd prevent you from using constructed typed om objects constructed in the worklet<br>
&lt;emilio> ... seems like Chromium's parser is a limitation for chrome but others disagreed<br>
&lt;emilio> iank_: that part of the parser may be thread-safe already<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;emilio> TabAtkins: so a multi-part proposal, I think we can do immediately, given that you can put &lt;svg:text>, I think we could add a canvas function to render svg text<br>
&lt;emilio> ... you can create an svg text in the worklet right?<br>
&lt;emilio> TabAtkins: so proposal is adding back drawText() to canvas<br>
&lt;astearns> s/so proposal/so part 1 of the proposal/<br>
&lt;emilio> ... second part of the proposal is that we should see if parsing font stuff is still a problem for browsers (particularly chrome), and if it is figuring out something for that in the short term<br>
&lt;heycam> q+<br>
&lt;emilio> ... if it's not then probably just expose it and reconsider the decisions<br>
&lt;emilio> ... about exposing parser things in the canvas<br>
&lt;emilio> iank_: I think that's already thread-safe in blink<br>
&lt;emilio> TabAtkins: font stuff in particular?<br>
&lt;emilio> iank_: yes<br>
&lt;emilio> TabAtkins: part three is: in the medium term we investigate how to expose web fonts<br>
&lt;emilio> ... hober's idea about explicitly telling the worklet what fonts to is may work<br>
&lt;emilio> myles_: another idea is making FontFaceSet transferrable<br>
&lt;emilio> TabAtkins: you still need a way to thread-that down, but that could be a way<br>
&lt;emilio> dbaron: I don't recall why we decide text stuff to not be in there?<br>
&lt;AmeliaBR> FYI, working demo of text in a Paint worklet, using WebGL: https://github.com/AdaRoseCannon/three-paint<br>
&lt;emilio> TabAtkins: it was a philosophical reason, we didn't want people to do a bunch of text stuff in paint worklet<br>
&lt;emilio> Rossen_: also we wanted to look how the measuring APIs would work<br>
&lt;emilio> ... before doing that<br>
&lt;emilio> dbaron: I do recall some system libraries not being thread-safe<br>
&lt;emilio> myles_: coretext is not thread-safe, we'd have to rewrite it and that's fine probably<br>
&lt;emilio> dbaron: we're on multiple platforms<br>
&lt;Rossen_> ack dbaron<br>
&lt;TabAtkins> emilio: I think we use mostly harfbuzz these days, and that can be threadsafe<br>
&lt;TabAtkins> myles_: CoreText is threadsafe too<br>
&lt;myles_> s/coretext/webkit's font handling/<br>
&lt;heycam> q-<br>
&lt;emilio> dbaron: this makes probably a harder dependency on the idea that paintworklet is a list of drawing commands and not a raster<br>
&lt;emilio> TabAtkins: yeah it does<br>
&lt;emilio> myles_: why adding drawText if we want to investigate better things in the future?<br>
&lt;emilio> TabAtkins: it'd be in canvas2d right?<br>
&lt;emilio> myles_: I guess what I'm saying is that the eventual solution may not look like drawText at all<br>
&lt;emilio> AmeliaBR: whatever solution should probably be coordinated with canvas api<br>
&lt;emilio> myles_: right and we may add a new api to canvas2d<br>
&lt;emilio> ... I think it's a bit too early to say that we need to support this API<br>
&lt;emilio> TabAtkins: I don't like that there's a hacky way to draw text<br>
&lt;emilio> ... but not a good way<br>
&lt;emilio> emilio: does the svg stuff _actually_ work?<br>
&lt;emilio> TabAtkins: not sure, can somebody confirm quickly that it works?<br>
&lt;emilio> TabAtkins: disabling svg text stuff is also a suitable resolution<br>
&lt;emilio> iank_: we may be able to do the FontFaceSet stuff<br>
&lt;emilio> myles_: I think that's a bad design<br>
&lt;emilio> TabAtkins: it also requires network<br>
&lt;emilio> heycam: wouldn't you be able to use local sources?<br>
&lt;TabAtkins> s/it also requires network/it doesn't give us access to installed fonts/<br>
&lt;heycam> q+<br>
&lt;emilio> myles_: I think not representing the fact that fonts are a list of fallbacks is doing a disservice to authors<br>
&lt;myles_> s/authors/users/<br>
&lt;emilio> ... I think we should have transferrable font objects, but they probably shouldn't be FontFace<br>
&lt;emilio> ... should be some sort of thin wrapper over what the font shorthand represents<br>
&lt;emilio> flackr: I'm hoping that typed om font property can represent that wrapper<br>
&lt;emilio> TabAtkins: let's solve this in the medium term so we can all think about this properly<br>
&lt;emilio> TabAtkins: I want to resolve whether text is allowed at all or not<br>
&lt;emilio> heycam: it's plausible that the svg subsystem doesn't know how to disable svg text in a standalone way<br>
&lt;emilio> myles_: svg native doesn't allow text so it may be a good fit for that<br>
&lt;emilio> heycam: so you said that the original reason to disallow text is to avoid inaccessible text, is that no longer a concern?<br>
&lt;emilio> ... or is it because it works with svg?<br>
&lt;emilio> ... because if it's because of the latter we probably don't want to give up<br>
&lt;emilio> TabAtkins: it was only one of the factors, others include text is hard, and high-quality text needing font metrics<br>
&lt;AmeliaBR> https://ada.is/three-paint/<br>
&lt;emilio> AmeliaBR: you could use webgl too, see ^<br>
&lt;emilio> myles_: no you can't, you'd need to upload the font as a texture<br>
&lt;emilio> TabAtkins: that demo is fake webgl, it's 2d<br>
&lt;emilio> ... we cannot really avoid it<br>
&lt;emilio> TabAtkins: proposed resolution is to disable text when in a paint worklet, possibly falling back to svg native<br>
&lt;emilio> ... and long term we want to lift the text restriction<br>
&lt;emilio> AmeliaBR: we could point to the SVG-in-OT restrictions<br>
&lt;emilio> RESOLVED: disable svg text when in a paint worklet, possibly falling back to svg native<br>
&lt;TabAtkins> s/falling back to/by subsetting to/<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/899#issuecomment-499939872 using your GitHub account

Received on Friday, 7 June 2019 15:53:52 UTC