Open SpriteOvO opened 2 months ago
Minimal reproducible
use ab_glyph::FontRef; use imageproc::{ drawing::*, image::{Rgb, RgbImage}, rect::Rect, }; fn main() { let mut image = RgbImage::new(200, 200); let font = FontRef::try_from_slice(include_bytes!("../DejaVuSans.ttf")).unwrap(); let white = Rgb([255, 255, 255]); let scale = 64.; let text = "hello"; let (w, h) = text_size(scale, &font, text); draw_text_mut(&mut image, white, 0, 0, scale, &font, text); draw_hollow_rect_mut(&mut image, Rect::at(0, 0).of_size(w, h), white); image.save("./output.png").unwrap(); }
Rendered
This issue would be more obvious if we used other fonts or languages.
For example, NotoSansCJK-Regular.ttc
NotoSansCJK-Regular.ttc
I think It's not the wrong Y position, it's the wrong text_size
text_size
Thats probably glyph "bearing" at the top. But text_size is broken for sure!
Minimal reproducible
Rendered
This issue would be more obvious if we used other fonts or languages.
For example,
NotoSansCJK-Regular.ttc