You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File content(at the bottom should be attached raw, not formatted file - github removes some non-printable characters, so copying from here may not work):
\00
command
timeout -v 100 typst compile TEST___FILE.typ
cause this
thread 'main' panicked at crates/typst-pdf/src/font.rs:203:75:
called `Result::unwrap()` on an `Err` value: UnknownKind
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
##### Automatic Fuzzer note, output status "Some(101)", output signal "None"
That's weird though, in theory this should only fail if the font is invalid. So either some invalid font is used when rendering this, or there is a bug in the subsetter.
And I can't reproduce it on my local machine. Do you think you could find out what font Typst is trying to use here? In case you can compile Typst yourself locally, you could do it by printing the font name in the subset_font method, for example.
typst compile appendix_1182521647_IDX_13_RAND_16144817441186598688330.typ
[crates/typst-pdf/src/font.rs:201:5] &font = Font(Noto Color Emoji, Normal-400-FontStretch(1000))
thread 'main' panicked at crates/typst-pdf/src/font.rs:204:75:
called `Result::unwrap()` on an `Err` value: UnknownKind
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@laurmaedje So it's pretty much as I expected, the bitmap version of Noto Color Emoji only has the CBDT/CBLC table, and in the subsetter we only check whether either CFF or glyf exists, otherwise we return UnknownKind. There was another user on Discord who also reported getting a crash, but in this case I suspect it's because it's trying to embed a CFF2 font.
For this particular issue, we should probably try to figure out why Typst attempts to subset the font in the first place, as for bitmap-based fonts it should only ever store them as a color font.
More generally, regarding the CFF2 thing, what should happen before the next update is:
In subsetter we should probably add an additional hint to the error if CFF2 or any other of the color tables are present.
Either we get export diagnostics before the next update, in which case we can catch the error and inform the user about it more appropriately, or we figure out some mechanism to not let Typst pick up CFF2 fonts in the first place.
I could reproduce the same/a similar error as well with a different example:
#settext(font: "Apple Color Emoji")
#emoji.face.grin some text
With AppleColorEmoji.ttf being present in fonts/AppleColorEmoji.ttf
❯ typst compile --font-path fonts test.typ
thread 'main' panicked at crates/typst-pdf/src/font.rs:202:75:
called `Result::unwrap()` on an `Err` value: UnknownKind
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I investigated this a bit with the Apple Color Emoji version linked above. While what Typst does is certainly not ideal, this font seems rather broken to me:
As @LaurenzV mentioned, it only contains a CBDT table, no glyf or CFF table. So far so good.
Its cmap maps the space character to glyph ID 3.
But the CDBT table does not contain an image for ID 3!
Typst's is_color_glyph function thus returns false for id 3 and therefore tries to encode it as normal text and subsequently attempts subsetting it.
Activity
bluebear94 commentedon Jul 17, 2024
This is planned to be turned into an export diagnostic:
typst/crates/typst-pdf/src/font.rs
Lines 200 to 203 in 0ea4b1b
LaurenzV commentedon Jul 18, 2024
That's weird though, in theory this should only fail if the font is invalid. So either some invalid font is used when rendering this, or there is a bug in the subsetter.
LaurenzV commentedon Jul 18, 2024
And I can't reproduce it on my local machine. Do you think you could find out what font Typst is trying to use here? In case you can compile Typst yourself locally, you could do it by printing the font name in the
subset_fontmethod, for example.qarmin commentedon Jul 18, 2024
Ubuntu 24.04, probably default font
laurmaedje commentedon Jul 22, 2024
I can't reproduce this either, also not by setting Noto Color Emoji manually.
qarmin commentedon Jul 22, 2024
I cannot reproduce this with precompiled typst 0.11.1 (786457e) from https://github.com/typst/typst/releases/tag/v0.11.1
but can with self-compiled version from git branch.
This file was found by CI, so I'm almost sure that this not happens to only me
LaurenzV commentedon Jul 26, 2024
I'm able to reproduce this on my Ubuntu virtual machine now, will try to look into it.
LaurenzV commentedon Jul 26, 2024
@laurmaedje So it's pretty much as I expected, the bitmap version of Noto Color Emoji only has the CBDT/CBLC table, and in the subsetter we only check whether either CFF or glyf exists, otherwise we return
UnknownKind. There was another user on Discord who also reported getting a crash, but in this case I suspect it's because it's trying to embed a CFF2 font.For this particular issue, we should probably try to figure out why Typst attempts to subset the font in the first place, as for bitmap-based fonts it should only ever store them as a color font.
More generally, regarding the CFF2 thing, what should happen before the next update is:
subsetterwe should probably add an additional hint to the error if CFF2 or any other of the color tables are present.Andrew15-5 commentedon Jul 29, 2024
I can only reproduce with the git version, and it panics here:
typst/crates/typst-pdf/src/font.rs
Line 202 in c4dd6fa
Reproduction:
release and dev profiles. Linux.
The title should include the NULL character instead of any 1 byte. Because other bytes are compiling just fine.
pavelzw commentedon Aug 8, 2024
I could reproduce the same/a similar error as well with a different example:
With
AppleColorEmoji.ttfbeing present infonts/AppleColorEmoji.ttfI got
AppleColorEmoji.ttffrom https://github.com/samuelngs/apple-emoji-linux/releases/download/v17.4/AppleColorEmoji.ttf (sha256486dc940bc9b858fdf317f97aa607f04a850481074375551a9af87ea569550f1)Using the typst build from 7496dd7 on an M1 Pro MacBook (installed with
brew install --HEAD typst).[-]Panic when compiling 1 byte file[/-][+]Panic due to failed subsetting for bitmap fonts[/+]laurmaedje commentedon Sep 17, 2024
I investigated this a bit with the Apple Color Emoji version linked above. While what Typst does is certainly not ideal, this font seems rather broken to me:
Typst's
is_color_glyphfunction thus returnsfalsefor id 3 and therefore tries to encode it as normal text and subsequently attempts subsetting it.laurmaedje commentedon Oct 1, 2024
Subsetting shouldn't crash anymore as there are now export stage diagnostics. The font handling is still buggy though.
[-]Panic due to failed subsetting for bitmap fonts[/-][+]Failed subsetting for bitmap fonts[/+]