Skip to content

Commit 21855c1

Browse files
SomeoneToIgnorelocalccswannysec
authored
Disable subpixel shifting for y axis on Linux (#38959)
Part of #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 <[email protected]> Co-authored-by: John <[email protected]>
1 parent 1f9279a commit 21855c1

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
Bounds, DevicePixels, Font, FontFeatures, FontId, FontMetrics, FontRun, FontStyle, FontWeight,
33
GlyphId, LineLayout, Pixels, PlatformTextSystem, Point, RenderGlyphParams, SUBPIXEL_VARIANTS_X,
4-
ShapedGlyph, ShapedRun, SharedString, Size, point, size,
4+
SUBPIXEL_VARIANTS_Y, ShapedGlyph, ShapedRun, SharedString, Size, point, size,
55
};
66
use anyhow::{Context as _, Ok, Result};
77
use collections::HashMap;
@@ -274,9 +274,10 @@ impl CosmicTextSystemState {
274274

275275
fn raster_bounds(&mut self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
276276
let font = &self.loaded_fonts[params.font_id.0].font;
277-
let subpixel_shift = params
278-
.subpixel_variant
279-
.map(|v| v as f32 / (SUBPIXEL_VARIANTS_X as f32 * params.scale_factor));
277+
let subpixel_shift = point(
278+
params.subpixel_variant.x as f32 / SUBPIXEL_VARIANTS_X as f32 / params.scale_factor,
279+
params.subpixel_variant.y as f32 / SUBPIXEL_VARIANTS_Y as f32 / params.scale_factor,
280+
);
280281
let image = self
281282
.swash_cache
282283
.get_image(
@@ -309,9 +310,10 @@ impl CosmicTextSystemState {
309310
} else {
310311
let bitmap_size = glyph_bounds.size;
311312
let font = &self.loaded_fonts[params.font_id.0].font;
312-
let subpixel_shift = params
313-
.subpixel_variant
314-
.map(|v| v as f32 / (SUBPIXEL_VARIANTS_X as f32 * params.scale_factor));
313+
let subpixel_shift = point(
314+
params.subpixel_variant.x as f32 / SUBPIXEL_VARIANTS_X as f32 / params.scale_factor,
315+
params.subpixel_variant.y as f32 / SUBPIXEL_VARIANTS_Y as f32 / params.scale_factor,
316+
);
315317
let mut image = self
316318
.swash_cache
317319
.get_image(

crates/gpui/src/text_system.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ pub struct FontFamilyId(pub usize);
4343

4444
pub(crate) const SUBPIXEL_VARIANTS_X: u8 = 4;
4545

46-
pub(crate) const SUBPIXEL_VARIANTS_Y: u8 = if cfg!(target_os = "windows") {
47-
1
48-
} else {
49-
SUBPIXEL_VARIANTS_X
50-
};
46+
pub(crate) const SUBPIXEL_VARIANTS_Y: u8 =
47+
if cfg!(target_os = "windows") || cfg!(target_os = "linux") {
48+
1
49+
} else {
50+
SUBPIXEL_VARIANTS_X
51+
};
5152

5253
/// The GPUI text rendering sub system.
5354
pub struct TextSystem {

0 commit comments

Comments
 (0)