typst: Fontname of a Type 3 font looks wrong

Description

For all other fonts, we get the expected font names of the embedded font, but for a Type 3 font, the prefix hash is included. I tested this with SumatraPDF and Adobe Reader and both show the same name. Maybe the reason is that this Font object is the only one having the Name key set: /Name /YXDKRS+SegoeUIEmoji.

Here comes the emoji 😂, which is from a different font and embedded as Type 3 font.

With older versions, emojis where embedded as a normal non-colored font and thus there was no need for Type 3 fonts.

Related: https://github.com/typst/typst/pull/5070

fontname

Reproduction URL

No response

Operating system

Windows

Typst version

  • I am using the latest version of Typst

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (4 by maintainers)

Most upvoted comments

I don’t think anyone knows what is “correct” here either. We have PDF readers (both from Adobe and from others) that don’t strip the subset tag from /Font/Name but strip it from /FontDescriptor/FontName, and then we have the validation tool in #5067 that expects /Font/Name and /FontDescriptor/FontName to be identical (including the subset tag, I just checked it with LibreOffice-generated PDF and it complained about the mismatch).

Either the PDF readers are wrong or the validation are wrong, though if you ask anyone who worked with PDF they will tell you whatever Adobe tools does is the actual standard, not whatever is written in the spec (and the spec is not saying much here, even).

Yes. LibreOffice also does it, but only in the Font Descriptor:

IIRC, I did this intentionally because I found out (like you did here) that the subset ID is not expected here, or at least apps I tested didn’t string it from /Font/Name, Unlike FontDescriptor/FontName.

About LuaTeX I really can’t find anything besides this which suggests Type 3. But they seem to use some method that only works with HarfBuzz.

I wrote the initial code in luaotfload that handles colors fonts when using HarfBuzz and it doesn’t use Type 3 fonts. I think they were probably planning to switch it to use Type 3 fonts, but does not look like this ever happened, the PDF generated by LuaTeX today still uses images directly and it has no Type 3 fonts.

I think this is the relevant difference:

   /Type /Font
   /Subtype /Type3
-  /Name /OHPKRD+TwitterColorEmojiSVGinOT
+  /Name /AppleColorEmoji

Typst prefixes the Type 3 font name with the subset id, but LibreOffice does not.

LuaTeX converts bitmap color glyphs into graphics and inserts them this way instead of font glyphs.

LibreOffice uses Type 3 fonts, which I think the same as Typst.

I don’t remember the exact details, but when I wrote the LibreOffice code I had issues with Type 3 font names and I had to jump through some hoops to make it work (some libraries, like Poppler, wouldn’t even show Type 3 font names at all). May be you can diff the two PDFs to see what is the difference.

You can try LibreOffice, it uses Type 3 for color fonts.