jrmuizel / raqote

Rust 2D graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source code pro renders to shrinked text

l4l opened this issue · comments

commented

I'm not sure whether it's a raqote or font-kit issue, but with "Source Code Pro" font text renders to that:

out

and "DejaVu Sans" produces an expected result:

out

source code
[dependencies]
raqote = { git = "https://github.com/jrmuizel/raqote.git", rev = "74f0afa" }
font-kit = "0.10.0"
use font_kit::family_name::FamilyName;
use font_kit::properties::Properties;
use font_kit::source::SystemSource;
use raqote::*;

fn main() {
    let mut dt = DrawTarget::new(512, 128);

    dt.clear(SolidSource::from_unpremultiplied_argb(0xff, 0x0, 0x0, 0x0));

    // let font_name = "Source Code Pro".to_string();
    let font_name = "DejaVu Sans".to_string();
    let font = SystemSource::new()
        .select_best_match(&[FamilyName::Title(font_name)], &Properties::new())
        .unwrap()
        .load()
        .unwrap();

    let pos = Point::new(0.0, 64.0);
    let color = SolidSource::from_unpremultiplied_argb(0xff, 0xff, 0xff, 0xff);
    dt.draw_text(
        &font,
        16.0,
        "The brown fox jump over the lazy dog",
        pos,
        &Source::Solid(color),
        &DrawOptions::new(),
    );

    dt.write_png("out.png").unwrap();
}

JetBrainsMono Nerd Font also renders in shrinked text, but FiraCode Mono Nerd Font doesn't. It's very random to me, but there must be an identifiable problem somewhere.