linebender / piet

An abstraction for 2D graphics.
Apache License 2.0
1.25k stars 94 forks source link

DirectWrite doesn't count tabs as trailing whitespace in single-line layout? #414

Open cmyr opened 3 years ago

cmyr commented 3 years ago

This is very much related to #411, but slightly more specific.

In #409 I added the following test:

fn line_test_tabs() {
    let line_text = "a\t\t\t\t\n";
    let mut factory = make_factory();
    let layout = factory.new_text_layout(line_text).build().unwrap();
    assert_eq!(layout.line_count(), 2);
    assert_eq!(layout.line_text(0), Some(line_text));
    let metrics = layout.line_metric(0).unwrap();
    assert_eq!(metrics.trailing_whitespace, line_text.len() - 1);
}

and this is now passing in coretext; previously it was running out of layout space and dropping some of the text.

DirectWrite currently fails this test, reporting its trailing whitespace length as '1'.

I think this is a matter of different expectations around trailing whitespace for these two APIs, but I can't investigate this week, since I don't have access to a windows machine.