Repository navigation
Only scan for color glyphs in is_color_glyph. - #4929
inferiorhumanorgans wants to merge 2 commits into
Conversation
laurmaedje
left a comment
There was a problem hiding this comment.
Why do they need to be unsupported though? Can't we handle monochrome bitmap fonts just like other color fonts?
| if sbix.best_strike(pixels_per_em).is_some() { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Don't we also need to check for the glyph ID somewhere?
It doesn't need to be unsupported but the fonts that've been reported to have monochrome bitmaps also have outline glyphs. What I took away from #4335 is that outline glyphs are preferred unless we're dealing with emoji (color) fonts that have color bitmaps and monochrome outlines. I have code to parse the monochrome bitmaps but it's not clear what logic should apply when choosing between monochrome outline and monochrome bitmap. As-is this unbreaks PNG rendering for the aforementioned fonts and preserves the preference for color bitmaps. |
|
I see. So we have the problem that the priority chain is |
|
No, the current order places mono bitmaps at the same priority as color bitmaps because Specifically the order is:
My proposal is:
The fonts so far that have been reported to trigger the mono bitmap code path also have mono outlines for those glyphs. This change will allow typst to use/prefer those mono outlines without interfering with e.g. Apple's emoji font (color bitmaps + mono outlines) or Noto Sans (color outlines only). // crates/typst-render/src/text.rs for PNG rendering
pub fn render_text(canvas: &mut sk::Pixmap, state: State, text: &TextItem) {
// This should return false for mono bitmaps that we don't support
if is_color_glyph(&text.font, glyph) {
let glyph_frame = frame_for_glyph(&text.font, glyph.id);
crate::render_frame(canvas, state, &glyph_frame);
} else {
render_outline_glyph(canvas, state, text, id);
}
} |
What I meant is that the desired order is I think the changes you propose make sense in principle, but while at it, I'd like to eliminate all possible panics. Also, unless I'm mistaken, we can skip the low-level table lookups by simply checking for PNG format in the output of I thought for the past weeks that the panic is very rare and this rather low priority, but it appears that 0.12 testing crashes on some emoji fonts in the web app, so it's more urgent than I thought. For this reason, I've implemented the changes I mention above myself: #5159. Feel free to take a look and give your input there. |
|
Closing in favor of #5159 |
This will prevent typst from picking up (unsupported) monochrome bitmaps in Windows system fonts e.g. Cambria Math and SimSun and the resulting panic (see #4335). One path leading to panic is eliminated, however:
draw_raster_glyphand to bubble up some error handling.