Unexpected panic when rasterizing specific font at specific size
Hello there,
as written in the title, when trying to rasterize a very specific text at scale 24.0 with the font Bitter-Regular.otf, I get a panic when rendering the word "Gauntl".
I created a repository that you can clone and cargo run
for a minimal example with the problematic font included (I copied the ascii
example and modified the font size, the font and the word, nothing else).
You can have a look at the repository here: https://github.com/Cobrand/rusttype-bug-example
The panic output with RUST_BACKTRACE=1 :
thread 'main' panicked at 'index out of bounds: the len is 100 but the index is 18446744073709551615', /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ab_glyph_rasterizer-0.1.2/src/raster.rs:85:17
stack backtrace:
...
13: core::panicking::panic_bounds_check
at src/libcore/panicking.rs:62
14: <usize as core::slice::SliceIndex<[T]>>::index_mut
at /home/cobrand/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/slice/mod.rs:3109
15: core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut
at /home/cobrand/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/slice/mod.rs:2966
16: <alloc::vec::Vec<T> as core::ops::index::IndexMut<I>>::index_mut
at /home/cobrand/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc/vec.rs:1987
17: ab_glyph_rasterizer::raster::Rasterizer::draw_line
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ab_glyph_rasterizer-0.1.2/src/raster.rs:85
18: <rusttype::outliner::OutlineRasterizer as ttf_parser::OutlineBuilder>::line_to
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/outliner.rs:122
19: <rusttype::outliner::OutlineTranslator<T> as ttf_parser::OutlineBuilder>::line_to
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/outliner.rs:68
20: <rusttype::outliner::OutlineScaler<T> as ttf_parser::OutlineBuilder>::line_to
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/outliner.rs:22
21: ttf_parser::tables::cff::Builder::line_to
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ttf-parser-0.6.2/src/tables/cff.rs:297
22: ttf_parser::tables::cff::_parse_char_string
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ttf-parser-0.6.2/src/tables/cff.rs:392
23: ttf_parser::tables::cff::parse_char_string
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ttf-parser-0.6.2/src/tables/cff.rs:265
24: ttf_parser::tables::cff::outline
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ttf-parser-0.6.2/src/tables/cff.rs:168
25: ttf_parser::Font::outline_glyph
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/ttf-parser-0.6.2/src/lib.rs:1256
26: rusttype::ScaledGlyph::build_outline
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/lib.rs:253
27: rusttype::PositionedGlyph::build_outline
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/lib.rs:416
28: rusttype::PositionedGlyph::draw
at /home/cobrand/.cargo/registry/src/github.com-1ecc6299db9ec823/rusttype-0.9.2/src/lib.rs:451
29: rusttype_bug::main
at src/main.rs:58
Note that the bug seems to trigger very specificly with that word and no other for some reason. "Gauntlxxxx" will panic as well, but "Gaunt" for instance, will not. Likewise, "Gaunlt" will not panic.