Skip to content

Commit

Permalink
Fix text legibility by rounding vertex positions (#151)
Browse files Browse the repository at this point in the history
Co-authored-by: Madeline Sparkles <[email protected]>
  • Loading branch information
LPGhatguy and msparkles committed May 3, 2024
1 parent 2ea1ecc commit 2eda113
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/yakui-core/src/paint/paint_dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ use crate::dom::Dom;
use crate::geometry::Rect;
use crate::id::{ManagedTextureId, WidgetId};
use crate::layout::LayoutDom;
use crate::paint::{PaintCall, Pipeline};
use crate::widget::PaintContext;

use super::layers::PaintLayers;
use super::primitives::{PaintCall, PaintMesh, Vertex};
use super::primitives::{PaintMesh, Vertex};
use super::texture::{Texture, TextureChange};

/// Contains all information about how to paint the current set of widgets.
Expand Down Expand Up @@ -202,7 +203,18 @@ impl PaintDom {
let vertices = mesh.vertices.into_iter().map(|mut vertex| {
let mut pos = vertex.position * self.scale_factor;
pos += self.unscaled_viewport.pos();

// Currently, we only round the vertices of geometry fed to the text
// pipeline because rounding all geometry causes hairline cracks in
// some geometry, like rounded rectangles.
//
// See: https://github.com/SecondHalfGames/yakui/issues/153
if mesh.pipeline == Pipeline::Text {
pos = pos.round();
}

pos /= self.surface_size;

vertex.position = pos;
vertex
});
Expand Down

0 comments on commit 2eda113

Please sign in to comment.