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.
This commit is contained in:
william341 2025-05-12 07:10:40 -04:00 committed by GitHub
parent 8000151aa9
commit 634b275931
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -299,6 +299,9 @@ impl CosmicTextSystemState {
fn raster_bounds(&mut self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
let font = &self.loaded_fonts_store[params.font_id.0];
let subpixel_shift = params
.subpixel_variant
.map(|v| v as f32 / (SUBPIXEL_VARIANTS as f32 * params.scale_factor));
let image = self
.swash_cache
.get_image(
@ -307,7 +310,7 @@ impl CosmicTextSystemState {
font.id(),
params.glyph_id.0 as u16,
(params.font_size * params.scale_factor).into(),
(0.0, 0.0),
(subpixel_shift.x, subpixel_shift.y.trunc()),
cosmic_text::CacheKeyFlags::empty(),
)
.0,