servo / font-kit

A cross-platform font loading library written in Rust
Apache License 2.0
699 stars 104 forks source link

panic and other errors when rendering with a pcf font #127

Open indefini opened 4 years ago

indefini commented 4 years ago

I tried the render-glyph example with some artwiz fonts with the following code:

//.select_by_postscript_name(&postscript_name)
.select_best_match(&[font_kit::family_name::FamilyName::Title("artwiz drift".to_owned())], &font_kit::properties::Properties::new())
        .unwrap()

it gave me this error:

thread 'main' panicked at 'attempt to negate with overflow', src/loaders/freetype.rs:805:20 I tried to do y: -(vector.y() as i64)

but then I got

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `23`,
 right: `0`', src/loaders/freetype.rs:815:13
indefini commented 4 years ago

after looking into it a little bit, this is because there is a division by zero in raster_bounds() units_per_em is 0 for a bitmap font. (as described here https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html , this variable is not relevant for bitmap fonts) so I think for now font-kit does not support bitmap fonts. would it be easy?hard? to implement?