davidbalbert / Watt

A high performance text editor for macOS.
MIT License
57 stars 2 forks source link

As you type on one line, the text might shift left and right by a point or a fraction of a point? #59

Closed davidbalbert closed 1 year ago

davidbalbert commented 1 year ago

I can't figure out if this is happening for sure. It almost looks like it gets fuzzier and then less fuzzy.

davidbalbert commented 1 year ago

Things I've learned so far:

  1. Each glyph's x coordinate doesn't change (CTRunGetPositions), even when the glyphs move.
  2. It happens with multiple fonts, both variable-width and fixed-width.
  3. The layer's position doesn't move.
  4. The NSAttributedString doesn't have any unexpected attributes.
  5. The Line's origin is correct, and for monospaced fonts, width of the line divided by the number of characters in the line doesn't change (as long as you set textContainer.lineFragmentPadding to 0).
  6. It happens even if lineFragmentPadding is 0.
  7. Everything returned by lineMetrics(for:in:) seems fine.
davidbalbert commented 1 year ago

This happened because the bounds of each LineLayer were fractional. I have no idea why that caused the issue.