Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text rendered at wrong Y position #687

Open
SpriteOvO opened this issue Sep 21, 2024 · 0 comments
Open

Text rendered at wrong Y position #687

SpriteOvO opened this issue Sep 21, 2024 · 0 comments

Comments

@SpriteOvO
Copy link

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

image

This issue would be more obvious if we used other fonts or languages.

For example, NotoSansCJK-Regular.ttc

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant