Disable subpixel shifting for y axis on Linux (#38959)

Part of https://github.com/zed-industries/zed/issues/7992
Port of #38440

<img width="3836" height="2142" alt="zed_nightly_vs_zed_dev_2"
src="https://github.com/user-attachments/assets/66bcbb9a-2159-4790-8a9a-d4814058d966"
/>

Does not change the rendering on Linux, but prepares us for the times
without cosmic-text where this will be needed.

Release Notes:

- N/A

Co-authored-by: Kate <kate@zed.dev>
Co-authored-by: John <john@zed.dev>
This commit is contained in:
Kirill Bulatov
2025-09-26 13:31:59 +00:00
committed by GitHub
co-authored by Kate John
parent 1f9279a56f
commit 21855c15e4
2 changed files with 15 additions and 12 deletions
@@ -1,7 +1,7 @@
use crate::{
Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, FontStyle, FontWeight,
GlyphId, LineLayout, Pixels, PlatformTextSystem, Point, RenderGlyphParams, SUBPIXEL_VARIANTS_X,
ShapedGlyph, ShapedRun, SharedString, Size, point, size,
SUBPIXEL_VARIANTS_Y, ShapedGlyph, ShapedRun, SharedString, Size, point, size,
};
use anyhow::{Context as _, Ok, Result};
use collections::HashMap;
@@ -274,9 +274,10 @@ impl CosmicTextSystemState {
fn raster_bounds(&mut self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
let font = &self.loaded_fonts[params.font_id.0].font;
let subpixel_shift = params
.subpixel_variant
.map(|v| v as f32 / (SUBPIXEL_VARIANTS_X as f32 * params.scale_factor));
let subpixel_shift = point(
params.subpixel_variant.x as f32 / SUBPIXEL_VARIANTS_X as f32 / params.scale_factor,
params.subpixel_variant.y as f32 / SUBPIXEL_VARIANTS_Y as f32 / params.scale_factor,
);
let image = self
.swash_cache
.get_image(
@@ -309,9 +310,10 @@ impl CosmicTextSystemState {
} else {
let bitmap_size = glyph_bounds.size;
let font = &self.loaded_fonts[params.font_id.0].font;
let subpixel_shift = params
.subpixel_variant
.map(|v| v as f32 / (SUBPIXEL_VARIANTS_X as f32 * params.scale_factor));
let subpixel_shift = point(
params.subpixel_variant.x as f32 / SUBPIXEL_VARIANTS_X as f32 / params.scale_factor,
params.subpixel_variant.y as f32 / SUBPIXEL_VARIANTS_Y as f32 / params.scale_factor,
);
let mut image = self
.swash_cache
.get_image(
+6 -5
View File
@@ -43,11 +43,12 @@ pub struct FontFamilyId(pub usize);
pub(crate) const SUBPIXEL_VARIANTS_X: u8 = 4;
pub(crate) const SUBPIXEL_VARIANTS_Y: u8 = if cfg!(target_os = "windows") {
1
} else {
SUBPIXEL_VARIANTS_X
};
pub(crate) const SUBPIXEL_VARIANTS_Y: u8 =
if cfg!(target_os = "windows") || cfg!(target_os = "linux") {
1
} else {
SUBPIXEL_VARIANTS_X
};
/// The GPUI text rendering sub system.
pub struct TextSystem {