sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.66k stars 98 forks source link

CBDT/CBLC color font support (e.g. Noto Color Emoji) #1261

Open McSinyx opened 3 years ago

McSinyx commented 3 years ago

I am having trouble with Noto Color Emoji, for example,

\begin{document}
\font[family = Noto Color Emoji]😄
\end{document}

would give me

$ sile emoji.sil 
SILE v0.12.0 (Lua 5.2)
<emoji.sil>
[1] 
libtexpdf:fatal: sfnt: table not found...

I am on NixOS unstable at the moment. Other emoji fonts seem to work, including Noto Emoji (which is still the old blob one for some reason).

alerque commented 3 years ago

Confirmed I see the same thing using this font file.

alerque commented 3 years ago

This smells to me like the problem is actually the font missing something it should have, but @simoncozens or @ctrlcctrlv can probably make a more educated guess at what is happening here. It's also possible we fumbles something, perhaps related to #1142/#1144.

simoncozens commented 3 years ago

Yes, that font doesn't have a glyf or CFF table, only color tables. It's arguable that that isn't a spec-compliant font. See https://github.com/googlefonts/noto-emoji/issues/43

Note that in there, this is a build with a glyf table, but this won't help you, because it's empty. And while we have a color-fonts package, that only implements fonts with COLR/CPAL tables, as opposed to the two other color font formats (SVG/CPAL, CBLC/CBDT). Noto Color Emoji is a CBLC/CBDT format font, so we can't do anything sensible with it.

Color fonts are a horrible mess. COLR/CPAL has won the de facto standardisation war, so we can put it down to this particular font being a problem.

alerque commented 3 years ago

Thanks, that's roughly what I was guessing but couldn't articulate.

I'd be happy to accept contributions for dealing with non-standard fonts, but since (as I understand it) we don't have any real intention of "fixing" this and the real issue is the font, I'm going to go ahead and close this issue.

@McSinyx I hope than answers your question and sorry we don't support CBLC/CBDT. Do feel free to jump in with feedback if you think we're missing something on this issue or you have any others!

khaledhosny commented 2 years ago

In luaotfload (for LuaTeX) I handle fonts like this by embedding the PNG returned by HarfBuzz directly in the PDF. Another option is to create a Type 3 font from the bitmaps (though I haven't tried this one myself).

khaledhosny commented 2 years ago

Note this is not a nonstandard font, the CBDT/CBLC is part of the OpenType spec. Another bitmap table with the same issue is sbix used by Apple emoji font.

alerque commented 2 years ago

I suppose if anybody out there chimes in again (@McSinyx?) to say this is something they would actually find useful we can re-open this issue to track adding CBDT/CBLC support. Personally I don't have the time or interest to code up support, but if somebody does come along that wants it enough to make it happen I'd be happy to review and facilitate a contribution.

McSinyx commented 2 years ago

I would find it useful, but it's not a high priority to me since I've switched back to the old (blob) Noto Emoji. IMHO it'd be nice if this issue is reopened so maybe someone will be able to fix it in the future. To quote Drew DeVault:

Let me offer you a different way of thinking about issues: a place for motivated users to collaborate on narrowing down the problem and planning a potential fix. A space for the community to work, rather than an action item for you to deal with personally. It gives people a place to record additional information, and, ultimately, put together a pull request for you to review. It does not matter if this process takes days or weeks or years to complete. Over time, the issue will accumulate details and workarounds to help users identify and diagnose the problem, and to provide information for the person that might eventually write a patch/pull request.

ctrlcctrlv commented 2 years ago

I agree with @khaledhosny, @alerque. This should be reopened and renamed to "CBDT/CBLC support". I also don't have the time or interest, but that's the right way to track it.

ctrlcctrlv commented 2 years ago

I just discovered that CBDT–CBLC and sbix can be made to share the same bitmap data in principle. I haven't made a Proof of Concept font yet but if this is the case, it means that if SILE supports one or the other it should be not so difficult to make cross-platform CBDT/sbix fonts out of any font that is only CBDT or only sbix. See https://twitter.com/fr_brennan/status/1478240370412638211 for the proposed method.