alexheretic / ab-glyph

Rust API for loading, scaling, positioning and rasterizing OpenType font glyphs
Apache License 2.0
372 stars 24 forks source link

Some .ttf fonts seem to be missing glyphs #26

Closed schell closed 3 years ago

schell commented 3 years ago

Hi! First of all, thank you, thank you for these great crates!

I'm trying to use the font Recursive for my game and I've found that it displays the incorrect is missing glyphs.

Here is a screeny of the version using Recursive_VF_1.070.ttf: Screen Shot 2021-01-16 at 8 45 40 AM

And here is the same example using OpenSans-Light.ttf: Screen Shot 2021-01-16 at 8 47 06 AM

Here's my initial layout:

    let font = {
        let mut fonts = world.write_resource::<Assets<FontArc>>();
        //fonts.load("assets/fonts/OpenSans-Light.ttf") 
        fonts.load("assets/fonts/Recursive_VF_1.070.ttf")
    };
    world
        .create_entity()
        .with(Text {
            fonts: vec![font],
            sections: vec![OwnedSection::default()
                .add_text(
                    OwnedText::new("A spot of text that has some nice layout and ")
                        .with_scale(32.0)
                        .with_color(Color::RGBA(0x33, 0x33, 0x33, 255).to_text_color()),
                )
                .add_text(
                    OwnedText::new("EVERYTHING! ")
                        .with_scale(32.0)
                        .with_color(Color::RGB(255, 255, 0).to_text_color()),
                )
                .add_text(
                    OwnedText::new("Another spot of text with transparency")
                        .with_scale(24.0)
                        .with_color(Color::RGBA(0x33, 0x33, 0x33, 127).to_text_color()),
                )
                .with_bounds((800.0, 600.0))],
        })
        .with(Name::from("welcome_text"))
        .with(Transform::default())
        .with(RenderLayers::layer2d())
        .build();

The system that builds and buffers the geometry is mostly copied from your OpenGL example in glyph_brush/examples/opengl.rs.

Furthermore, it doesn't seem to depend on what font index I decode the font with (Recursive is a big family).

alexheretic commented 3 years ago

It looks like this font's format is not fully supported by ttf-parser. I've raised an issue upstream: https://github.com/RazrFalcon/ttf-parser/issues/48.

I downloaded the font and noticed they also ship _"separatestatics" non-variable font versions. These seem to work fine so could serve as a workaround for you.

You can try any font with the image example. For example: cargo run --example image ~/Downloads/ArrowType-Recursive-1.070/fonts/ArrowType-Recursive-1.070/Recursive_Desktop/separate_statics/OTF/RecursiveSansLnrSt-Regular.otf

image_example.png

alexheretic commented 3 years ago

This has been addressed upstream & fixed with #27.

I'll publish a new release at the end of the coming week.

schell commented 3 years ago

Thank you for the quick reply and investigation 🎉 . Top notch!

alexheretic commented 3 years ago

I've published 0.2.8 with this fix