`draw_text_mut` does not seem to account for accents when placing text.
Very simple, if I ask imageproc for text_size and then snugly render e.g. an Ä:
pub fn txt_img() -> DynamicImage {
use imageproc::drawing::draw_text_mut;
let mplantin = include_bytes!("../resources/fonts/mplantin.ttf");
let mplantin = ab_glyph::FontArc::try_from_slice(mplantin).unwrap();
let font_size = 128.0;
let word = "ÁÄaaa";
let (mut w, mut h) = imageproc::drawing::text_size(font_size, &mplantin, word);
let mut image: DynamicImage = DynamicImage::new_rgba8(w, h);
draw_text_mut(&mut image, image::Rgba([ 100u8, 100u8, 100u8, 255u8 ]), 0, 0, font_size, &mplantin, word);
image
}
The accents are cut off:
But there is additional space at the bottom:
Which, if I offset by the right amount (16 in this case), seems to fit perfectly snug.
Which leads me to believe imageproc accounts for accents when doing text_size but not when placing the text.
I remember fixing the text_size function.
It’s in the master branch.
imageproc = { git = "https://github.com/image-rs/imageproc.git", branch = "master" }
I remember fixing the
text_sizefunction. Trymasterbranch.imageproc = { git = "https://github.com/image-rs/imageproc.git", branch = "master" }
Maybe it doesn’t solve this issue, but it can be related if someone wants to test draw_text and text_size changes. And I think I already tried to raise a question about additional spacing, which depends on specific glyphs, and we decided not to add it.
~~Yep, master works for me immediately and perfectly fine, thank you very much!~~
~~Feel free to close the issue as you see fit.~~
On second check, master fixed my particular unrelated troubles with rendering text (so thank you very much), but this particular issue actually still remains, so keeping this open
And as for
Which leads me to believe imageproc accounts for accents when doing text_size but not when placing the text.
idk how imageproc actually works, cause that space on the bottom also fits low glyphs like g and in my font, ( so maybe wrong about this