linebender / linebender/piet

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

Open
#414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

piet-direct2d text
Dominant language
Rust
Stars
1.4k
Forks
98
PR merge metrics
No merged PRs in 30d

Description

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

In #409 I added the following test:

```rust
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the line_test_tabs test described in the issue and the factory.new_text_layout call, then trace the DirectWrite layout implementation that supplies line_metric(0). Compare its handling of tab characters with the expected trailing_whitespace value and confirm the test passes without dropping text.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.