Skip to content

Turn non-breaking space (and other whitespace) into a space #703

Description

@DJMcNab

LLM contribution: Fable for investigation and to generate test.

If a font is missing non breaking space (U+00A0), HarfRust shapes them in the same way as a space (if the font supports that). This also applies for some different space characters (Claude claims U+2000..=U+200A, U+205F, but not U+3000 - https://crbug.com/1193282).

I believe this is a Parley level font selection question, rather than a Parley Core (soon to be Engine) thing?

Reproduction failing test (Fable authored, based on our Roboto not having NARROW NO-BREAK SPACE):

#[test]
fn space_like_char_missing_from_font_should_not_trigger_fallback() {
    let mut env = TestEnv::new(test_name!(), None);

    let text = "a\u{202F}b";
    let mut builder = env.ranged_builder(text);
    builder.push_default(StyleProperty::FontSize(2048.0));
    let mut layout = builder.build(text);
    layout.break_all_lines(None);

    let num_runs: usize = layout.lines().map(|line| line.runs().count()).sum();
    assert_eq!(
        num_runs, 1,
        "U+202F was itemized to a fallback font instead of using Roboto's space glyph"
    );
    assert_eq!(layout.width(), 2516.0);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions