Use euclid::Scale to convert between physical and logical coord spaces

This commit is contained in:
meehl committed 2026-08-24 23:57:19 +02:00
1 parent 8ba72fd7df
commit 8d17f8e64f
12 files changed
+70 -155

No files matched your search

+4 -7
View File
@@ -1,6 +1,6 @@
use crate::{
color::Srgba,
dpi::{ConvertToLogical, ConvertToPhysical, LogicalPoint},
dpi::LogicalPoint,
fonts::{Alignment, FontStyle, LayoutJob},
math::{Point, Quad, Rect, Size},
pob::Context,
@@ -357,13 +357,10 @@ unsafe extern "C-unwind" fn draw_string(state: *mut ffi::lua_State) -> c_int {
}
// Align layout origin with the physical pixel grid to reduce blurriness
let pixels_per_point = ctx.window_state.scale_factor();
let position = position
.to_physical::<f32, _>(pixels_per_point)
.round()
.to_logical(pixels_per_point);
let scale_factor = ctx.window_state.scale_factor();
let position = (position * scale_factor).round() / scale_factor;
let layout = ctx.fonts.borrow_mut().layout(job, pixels_per_point);
let layout = ctx.fonts.borrow_mut().layout(job, scale_factor);
for glyph in &layout.glyphs {
ctx.recorder.draw_glyph(
glyph.rect.translate(position.to_vector()),