Honor preformatted whitespace in shaped text

This commit is contained in:
SGavrl committed 2026-07-31 01:23:47 +00:00
1 parent 139d4e77e1
commit 476191d9c8
3 files changed
+146 -11

No files matched your search

+18
View File
@@ -615,6 +615,10 @@ pub struct LayoutStyle {
/// shaped text (a fixed ratio made real-site prose noticeably tighter than
/// Chromium).
pub line_height: Option<LineHeight>,
/// `white-space`. Inherited; `None` means inherit the nearest ancestor's
/// value (or the initial `normal`). The inline shaper uses this to retain
/// author/source newlines in code blocks and to select wrapping behavior.
pub white_space: Option<WhiteSpace>,
/// Deferred functional line-height (`calc()`, `min()`, `clamp()`) resolved
/// after the element font and live viewport are known.
pub line_height_expression: Option<String>,
@@ -786,6 +790,20 @@ pub enum LineHeight {
Relative(Dimension),
}
/// The legacy `white-space` shorthand values needed by inline collection and
/// line breaking. `BreakSpaces` currently shares pre-wrap's wrapping model;
/// its finer trailing-space opportunity rules can be added independently.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum WhiteSpace {
#[default]
Normal,
NoWrap,
Pre,
PreWrap,
PreLine,
BreakSpaces,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TextTransform {
None,