bevy/crates
ickshonpe e2916fbad1
Subtract 1 from text positions to account for glyph texture padding. (#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>
2024-02-02 20:01:01 +00:00
..
bevy_a11y resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
bevy_animation Replace the cubic_spline_interpolation macro with a generic function (#11605) 2024-01-29 19:50:30 +00:00
bevy_app Expressively define plugins using functions (#11080) 2024-01-27 02:40:15 +00:00
bevy_asset Fix AssetTransformer breaking LabeledAssets (#11626) 2024-02-02 14:57:31 +00:00
bevy_audio Optional override for global spatial scale (#10419) 2024-01-25 16:29:35 +00:00
bevy_core Adding derive Reflect for tick structs (#11641) 2024-02-01 16:11:32 +00:00
bevy_core_pipeline RenderGraph Labelization (#10644) 2024-01-31 14:51:19 +00:00
bevy_derive Reexport winit::platform::android::activity::* in bevy_winit (#11011) 2023-12-19 20:15:03 +00:00
bevy_diagnostic Replace DiagnosticId by DiagnosticPath (#9266) 2024-01-20 15:42:51 +00:00
bevy_dylib Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_dynamic_plugin Mark DynamicPluginLoadError internal error types as source (#11618) 2024-01-30 23:37:00 +00:00
bevy_ecs Adding derive Reflect for tick structs (#11641) 2024-02-01 16:11:32 +00:00
bevy_ecs_compile_fail_tests Dynamic queries and builder API (#9774) 2024-01-16 19:16:49 +00:00
bevy_encase_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gilrs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_gizmos RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
bevy_gltf RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
bevy_hierarchy Make the MapEntities trait generic over Mappers, and add a simpler EntityMapper (#11428) 2024-01-28 19:51:46 +00:00
bevy_input Fix cyclic dep (#11523) 2024-01-25 17:44:32 +00:00
bevy_internal Add Accessibility plugin to default plugins docs (#11512) 2024-01-28 10:04:43 +00:00
bevy_log move once from bevy_log to bevy_utils, to allow for it's use in bevy_ecs (#11419) 2024-01-19 06:07:41 +00:00
bevy_macro_utils Bump toml_edit in build-template-pages tool (#11342) 2024-01-16 05:23:18 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math return Direction3d from Transform::up and friends (#11604) 2024-02-02 15:05:35 +00:00
bevy_mikktspace Enable the unsafe_op_in_unsafe_fn lint (#11591) 2024-01-28 23:18:11 +00:00
bevy_pbr Gate diffuse and specular transmission behind shader defs (#11627) 2024-02-02 15:01:56 +00:00
bevy_ptr bevy_ptr: fix unsafe_op_in_unsafe_fn lint (#11610) 2024-01-30 23:37:29 +00:00
bevy_reflect Add the ability to manually create ParsedPaths (+ cleanup) (#11029) 2024-02-01 19:22:40 +00:00
bevy_reflect_compile_fail_tests bevy_reflect: Type parameter bounds (#9046) 2024-01-28 16:24:03 +00:00
bevy_render RenderGraph Labelization (#10644) 2024-01-31 14:51:19 +00:00
bevy_scene Make the MapEntities trait generic over Mappers, and add a simpler EntityMapper (#11428) 2024-01-28 19:51:46 +00:00
bevy_sprite RenderAssetPersistencePolicy → RenderAssetUsages (#11399) 2024-01-30 13:22:10 +00:00
bevy_tasks Fix wrong transmuted type in TaskPool::scope_with_executor_inner (#11455) 2024-01-21 18:08:45 +00:00
bevy_text Subtract 1 from text positions to account for glyph texture padding. (#11662) 2024-02-02 20:01:01 +00:00
bevy_time Add paused run condition (#11313) 2024-01-12 22:18:57 +00:00
bevy_transform return Direction3d from Transform::up and friends (#11604) 2024-02-02 15:05:35 +00:00
bevy_ui RenderGraph Labelization (#10644) 2024-01-31 14:51:19 +00:00
bevy_utils impl Borrow and AsRef for CowArc (#11616) 2024-01-30 14:27:53 +00:00
bevy_window Update cursor.rs (#11617) 2024-01-30 16:34:17 +00:00
bevy_winit Cleanup bevy winit (#11489) 2024-01-28 21:09:23 +00:00