Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for emojis #239

Open
orhun opened this issue Nov 19, 2023 · 2 comments
Open

Add support for emojis #239

orhun opened this issue Nov 19, 2023 · 2 comments

Comments

@orhun
Copy link

orhun commented Nov 19, 2023

I realized silicon is not working when I have emoji in the code. Is this supported?

@lost22git
Copy link

same

warning] No font found for character `🤣`
[warning] No font found for character `👻`
[warning] No font found for character `🦉`
`warning] No font found for character `
[warning] No font found for character `🤣`
[warning] No font found for character `👻`
[warning] No font found for character `🦉`
`warning] No font found for character `

@chris-av
Copy link

chris-av commented Apr 3, 2024

So here is what I tried.

silicon --font "Apple Color Emoji" inputfile.sh -o output.png

No error is shown, unless I run Rust in debug mode with RUST_BACKTRACE. Then I get this:

screenshot-20240403--00_31_58_AM

The panic is being thrown when calling Self:get_glyph_width(). I think this is the offending line:

    fn get_glyph_width(font: &Font, id: u32, size: f32) -> u32 {
        let metrics = font.metrics();
        let advance = font.advance(id).unwrap();
        (advance / metrics.units_per_em as f32 * size).x().ceil() as u32; // offending line here
    }

I guess with emoji, the metrics.units_per_em appears to be zero (see screenshot), but since it is coerced to a number, the end result of get_glyph_width is a large number that overflows and causes the panic.

Edit: I did verify that "Apple Color Emoji" is a font that is listed by the silicon --list-fonts output. Same result with other fallback emoji font, like "Noto Color Emoji".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants