-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Subtract 1 from text positions to account for glyph texture padding. #11662
Merged
alice-i-cecile
merged 2 commits into
bevyengine:main
from
ickshonpe:glyph-position-padding-fix
Feb 2, 2024
Merged
Subtract 1 from text positions to account for glyph texture padding. #11662
alice-i-cecile
merged 2 commits into
bevyengine:main
from
ickshonpe:glyph-position-padding-fix
Feb 2, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ickshonpe
added
C-Bug
An unexpected or incorrect behavior
A-Text
Rendering and layout for characters
labels
Feb 2, 2024
matiqo15
approved these changes
Feb 2, 2024
rparrett
reviewed
Feb 2, 2024
alice-i-cecile
requested changes
Feb 2, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once there's a comment added, this LGTM.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
alice-i-cecile
approved these changes
Feb 2, 2024
tjamaan
pushed a commit
to tjamaan/bevy
that referenced
this pull request
Feb 6, 2024
…evyengine#11662) # Objective Glyph positions don't account for padding added to the font texture atlas, resulting in them being off by one physical pixel in both axis. ## Example ```rust use bevy::{ prelude::*, window::WindowResolution }; fn main() { App::new() .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { resolution: WindowResolution::default().with_scale_factor_override(1.), ..Default::default() }), ..Default::default() })) .add_systems(Startup, setup) .run(); } fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { commands.spawn(Camera2dBundle::default()); commands.spawn( TextBundle::from_section( "QQQQQ", TextStyle { font: asset_server.load("FiraMono-Medium.ttf"), font_size: 14.0, ..default() }, ) .with_style(Style { left:Val::Px(10.), top: Val::Px(10.), ..default() }) .with_background_color(Color::RED) ); } ``` <img width="350" alt="QQQQQ-bad" src="https://github.com/bevyengine/bevy/assets/27962798/6a509aee-64c8-4ee8-a8c1-77ee65355898"> The coordinates are off by one in physical coordinates, not logical. So the difference only becomes obvious with `UiScale` and the window scale factor set to low values. ## Solution Translate glyph positions by -1 in both axes. <img width="300" alt="QQQQQ-good" src="https://github.com/bevyengine/bevy/assets/27962798/16e3f6d9-1223-48e0-9fdd-b682a3e8ade4"> --- ## Changelog * Translate the positions for each glyph by -1 in both axes in `bevy_text::glyph_brush::process_glyphs` --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Glyph positions don't account for padding added to the font texture atlas, resulting in them being off by one physical pixel in both axis.
Example
The coordinates are off by one in physical coordinates, not logical. So the difference only becomes obvious with
UiScale
and the window scale factor set to low values.Solution
Translate glyph positions by -1 in both axes.
Changelog
bevy_text::glyph_brush::process_glyphs