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 is rendered with visibly incorrect offsets #283

Closed
cart opened this issue Aug 22, 2020 · 5 comments
Closed

Text is rendered with visibly incorrect offsets #283

cart opened this issue Aug 22, 2020 · 5 comments
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@cart
Copy link
Member

cart commented Aug 22, 2020

This is clearly visible in the "scene" example. It is less visible for "smaller" text.
image

@cart cart added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Aug 22, 2020
@cart
Copy link
Member Author

cart commented Aug 22, 2020

I think this has to do with us "offsetting" the text from "bottom" to "top" instead of from "top" to "bottom". I chose to go buttom->up because the bottom is where our origin is, but we might need to rethink this. Here is how ab_glyph does typesetting in their examples: https://github.com/alexheretic/ab-glyph/blob/master/dev/examples/image.rs

@inodentry
Copy link
Contributor

TBH, the current "wavy" rendering looks kinda cute. I like the effect. ;)

That said, ofc this is a bug and should be fixed.

This was referenced Oct 24, 2020
@mockersf
Copy link
Member

the scene example is now fixed with #725, but there's still issue of wavy test...

scene fixed:
before: scene - b6004e44cff73876f2ba04f342bfe8129a7f5222 - after: scene - ef86ce98ed8a21eeb00e60c0b3bd7d4f17544c92

issue gets more noticeable with smaller text size (below 35 is more visible)

Code to display text example
use bevy::prelude::*;

fn main() {
    App::build()
        .add_default_plugins()
        .add_startup_system(setup.system())
        .run();
}

fn setup(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands
        // 2d camera
        .spawn(UiCameraComponents::default());

    commands.spawn(NodeComponents {
        style: Style {
            flex_direction: FlexDirection::Column,
            ..Default::default()
        },
        material: materials.add(Color::NONE.into()),
        ..Default::default()
    });

    commands.with_children(|container| {
        for i in 0..10 {
            let size = (20 + i * 5) as f32;
            container
            .spawn(TextComponents {
                style: Style {
                    size: Size {
                        height: Val::Px(size  + 10.),
                        ..Default::default()

                    },
                    ..Default::default()
                },
                text: Text {
                    value: format!("{}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.", size),
                    font: asset_server.load("fonts/FiraSans-Bold.ttf"),
                    style: TextStyle {
                        font_size: size ,
                        color: Color::WHITE,
                    },
                },
                ..Default::default()
            });
        }
    });
}

before: b6004e44cff73876f2ba04f342bfe8129a7f5222 - after: now

@cart
Copy link
Member Author

cart commented Oct 31, 2020

Arg nice catch. We should definitely leave this open.

@memoryruins
Copy link
Contributor

Resolved by #765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

4 participants