Skip to content

Commit

Permalink
Tmp fix for fyne-io#4998
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jul 28, 2024
1 parent ca7410c commit 91d99b1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions widget/richtext.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,14 @@ func lineBounds(seg *TextSegment, wrap fyne.TextWrap, trunc fyne.TextTruncation,
widthChecker := func(low int, high int) bool {
return measurer(text[low:high]).Width <= measureWidth
}
// Supersonic: temporary fix for https://github.com/fyne-io/fyne/issues/4998
widthCheckerEllipsis := func(low, high int) bool {
if low == 0 && high == len(text)-1 {
return measurer(text[low:high]).Width <= measureWidth
}
return measurer(text[low:high]).Width+
measurer([]rune{'…'}).Width <= measureWidth
}

reuse := 0
yPos := float32(0)
Expand Down Expand Up @@ -1063,11 +1071,18 @@ func lineBounds(seg *TextSegment, wrap fyne.TextWrap, trunc fyne.TextTruncation,
}
default:
if trunc == fyne.TextTruncateEllipsis {
// Supersonic: temporary fix for https://github.com/fyne-io/fyne/issues/4998
high = binarySearch(widthCheckerEllipsis, low, high)
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, high, high < len(text)})
reuse++

/* orig Fyne code:
txt := []rune(seg.Text)[low:high]
end, full := truncateLimit(string(txt), seg.Visual().(*canvas.Text), int(measureWidth), []rune{'…'})
high = low + end
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, high, !full})
reuse++
*/
} else if trunc == fyne.TextTruncateClip {
high = binarySearch(widthChecker, low, high)
bounds = append(bounds, rowBoundary{[]RichTextSegment{seg}, reuse, low, high, false})
Expand Down

0 comments on commit 91d99b1

Please sign in to comment.