Skip to content

draw_text_mut does not seem to account for accents when placing text. #710

@Gremious

Description

@Gremious

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:

txt

But there is additional space at the bottom:

image

Which, if I offset by the right amount (16 in this case), seems to fit perfectly snug.

image

Which leads me to believe imageproc accounts for accents when doing text_size but not when placing the text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions