Skip to content

Commit 0ce4ac9

Browse files
143mailliwosiewicz
authored andcommitted
gpui: Fix cosmic-text raster_bounds calculation (#30552)
Closes #30526. This PR makes the CacheKey used by raster_bounds and rasterize_glyph the same, as they had not used the same sub pixel shift previously. Fixing this resolves both the alignment and text-rendering issues introduced in `ddf8d07`. Release Notes: - Fixed text rendering issues on Linux.
1 parent 5f17bef commit 0ce4ac9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/gpui/src/platform/linux/text_system.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ impl CosmicTextSystemState {
299299

300300
fn raster_bounds(&mut self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
301301
let font = &self.loaded_fonts_store[params.font_id.0];
302+
let subpixel_shift = params
303+
.subpixel_variant
304+
.map(|v| v as f32 / (SUBPIXEL_VARIANTS as f32 * params.scale_factor));
302305
let image = self
303306
.swash_cache
304307
.get_image(
@@ -307,7 +310,7 @@ impl CosmicTextSystemState {
307310
font.id(),
308311
params.glyph_id.0 as u16,
309312
(params.font_size * params.scale_factor).into(),
310-
(0.0, 0.0),
313+
(subpixel_shift.x, subpixel_shift.y.trunc()),
311314
cosmic_text::CacheKeyFlags::empty(),
312315
)
313316
.0,

0 commit comments

Comments
 (0)