text,widget: remove fractional line height

The previous logic kept the y offset of a line as a fractional value
until the last possible moment in an effort to be as true to a fractional
line height as possible (minimize the error), but this interacts pathologically
with multi-line text selections, as the selections may have visibly different
gaps between lines. It's better to always shift lines by a fixed quantity of
whole pixels, even if it is technically less accurate to the desired line height.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2023-07-21 13:14:42 -04:00
committed by Elias Naur
parent 1d8b54892a
commit 8dc03ed655
2 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -513,12 +513,12 @@ func calculateYOffsets(lines []line) {
}
// Ceil the first value to ensure that we don't baseline it too close to the top of the
// viewport and cut off the top pixel.
currentY := fixed.I(lines[0].ascent.Ceil())
currentY := lines[0].ascent.Ceil()
for i := range lines {
if i > 0 {
currentY += lines[i].lineHeight
currentY += lines[i].lineHeight.Round()
}
lines[i].yOffset = currentY.Round()
lines[i].yOffset = currentY
}
}