Skip to content

🤖 and 🪵 are rendered incorrectly it would seem #26

Closed
@Jasper-Bekkers

Description

@Jasper-Bekkers

Repro case

It looks like both of these render partially (I haven't tried many more, however 🔥 from the documentation seems to render correctly). The robot-man seems to have his mouth cut off, and the log seems to have the top cut off.

Since this is my very first time diving into this library, I may well be doing something wrong. I've attached the repro of what I'm trying to do.

I've also attached the rendered image below;

use swash::scale::ScaleContext;
use swash::scale::StrikeWith;
use swash::scale::*;
use zeno::Vector;

fn main() {
    use swash::FontRef;

    let font_path = "C:/Windows/Fonts/seguiemj.ttf";

    let font_data = std::fs::read(font_path).ok().unwrap();
    let font = FontRef::from_index(&font_data, 0).unwrap();

    let mut context = ScaleContext::new();
    let mut scaler = context.builder(font).hint(true).build();
    let glyph_id = font.charmap().map('🤖');
    let image = Render::new(&[
        Source::ColorBitmap(StrikeWith::ExactSize),
        Source::ColorOutline(1),
        Source::Outline,
    ])
    .format(zeno::Format::Subpixel)
    .offset(Vector::new(0.0, 0.0))
    .render(&mut scaler, glyph_id)
    .unwrap();

    dbg!(image.placement);

    let img =
        ::image::RgbaImage::from_raw(image.placement.width, image.placement.height, image.data)
            .unwrap();
    img.save_with_format("stuff.png", ::image::ImageFormat::Png);
}

stuff

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions