You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
I found something odd with widget.Label when using .Truncate = fyne.TextTruncateEllipsis and multi-byte UTF-8 characters: a number of trailing characters are missing or not rendered according to the number of bytes in the multi-byte character.
For example, a two-byte chacter like 'Š' will trim 1 character from the end of the string, a three-byte character like '∞' will trim two characters, and a four-byte character like '🪃' will trim three characters from the end of the string.
Note that I'm not talking about long labels that need to be truncated based on available screen size – I'm talking about any label. It just needs to have multi-byte characters present and be using fyne.TextTruncatedEllipsis.
How to reproduce
label := widget.NewLabel("∞ is more than 12345") or use your favorite multi-byte UTF-8 character
label.Truncation = fyne.TextTruncateEllipsis
Add the label to your layout and run
Screenshots
Example code in action:
Example code
package main
import (
"fyne.io/fyne/v2""fyne.io/fyne/v2/app""fyne.io/fyne/v2/container""fyne.io/fyne/v2/widget"
)
funcmain() {
a:=app.New()
w:=a.NewWindow("UTF-8 Multi-byte Ellipsis Truncation")
w.SetMaster()
labelTruncateOff:=widget.NewLabel("TextTruncateOff")
labelTruncateOff.TextStyle.Bold=truelabelTruncateClip:=widget.NewLabel("TextTruncateClip")
labelTruncateClip.TextStyle.Bold=truelabelTruncateEllipsis:=widget.NewLabel("TextTruncateEllipsis")
labelTruncateEllipsis.TextStyle.Bold=truelabelTruncateEllipsis.TextStyle.Italic=truelabel1Byte:=widget.NewLabel("1-byte")
label1Byte.TextStyle.Bold=truelabel2Byte:=widget.NewLabel("2-byte")
label2Byte.TextStyle.Bold=truelabel3Byte:=widget.NewLabel("3-byte")
label3Byte.TextStyle.Bold=truelabel4Byte:=widget.NewLabel("4-byte")
label4Byte.TextStyle.Bold=true// Note: Monospace is used here because it seems to support more of unicode than the bundled// Noto fonts, it's not critical to reproduce the issuetestLabel1:=widget.NewLabel("x 0123456789")
testLabel1.TextStyle= fyne.TextStyle{Monospace: true}
testLabel1.Truncation=fyne.TextTruncateOfftestLabel2:=widget.NewLabel("Š 0123456789")
testLabel2.TextStyle= fyne.TextStyle{Monospace: true}
testLabel2.Truncation=fyne.TextTruncateOfftestLabel3:=widget.NewLabel("∞ 0123456789")
testLabel3.TextStyle= fyne.TextStyle{Monospace: true}
testLabel3.Truncation=fyne.TextTruncateOfftestLabel4:=widget.NewLabel("🪃 0123456789")
testLabel4.TextStyle= fyne.TextStyle{Monospace: true}
testLabel4.Truncation=fyne.TextTruncateOfftestLabel5:=widget.NewLabel("x 0123456789")
testLabel5.TextStyle= fyne.TextStyle{Monospace: true}
testLabel5.Truncation=fyne.TextTruncateCliptestLabel6:=widget.NewLabel("Š 0123456789")
testLabel6.TextStyle= fyne.TextStyle{Monospace: true}
testLabel6.Truncation=fyne.TextTruncateCliptestLabel7:=widget.NewLabel("∞ 0123456789")
testLabel7.TextStyle= fyne.TextStyle{Monospace: true}
testLabel7.Truncation=fyne.TextTruncateCliptestLabel8:=widget.NewLabel("🪃 0123456789")
testLabel8.TextStyle= fyne.TextStyle{Monospace: true}
testLabel8.Truncation=fyne.TextTruncateCliptestLabel9:=widget.NewLabel("x 0123456789")
testLabel9.TextStyle= fyne.TextStyle{Monospace: true}
testLabel9.Truncation=fyne.TextTruncateEllipsistestLabel10:=widget.NewLabel("Š 0123456789")
testLabel10.TextStyle= fyne.TextStyle{Monospace: true}
testLabel10.Truncation=fyne.TextTruncateEllipsistestLabel11:=widget.NewLabel("∞ 0123456789")
testLabel11.TextStyle= fyne.TextStyle{Monospace: true}
testLabel11.Truncation=fyne.TextTruncateEllipsistestLabel12:=widget.NewLabel("🪃 0123456789")
testLabel12.TextStyle= fyne.TextStyle{Monospace: true}
testLabel12.Truncation=fyne.TextTruncateEllipsisw.SetContent(container.NewStack(container.NewGridWithColumns(
4,
widget.NewLabel(" "),
labelTruncateOff,
labelTruncateClip,
labelTruncateEllipsis,
label1Byte,
testLabel1,
testLabel5,
testLabel9,
label2Byte,
testLabel2,
testLabel6,
testLabel10,
label3Byte,
testLabel3,
testLabel7,
testLabel11,
label4Byte,
testLabel4,
testLabel8,
testLabel12,
)))
w.ShowAndRun()
}
Fyne version
2.4.0
Go compiler version
1.21.1
Operating system and version
Windows 10, macOS Ventura 13.6
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Checklist
Describe the bug
I found something odd with
widget.Label
when using.Truncate = fyne.TextTruncateEllipsis
and multi-byte UTF-8 characters: a number of trailing characters are missing or not rendered according to the number of bytes in the multi-byte character.For example, a two-byte chacter like 'Š' will trim 1 character from the end of the string, a three-byte character like '∞' will trim two characters, and a four-byte character like '🪃' will trim three characters from the end of the string.
Note that I'm not talking about long labels that need to be truncated based on available screen size – I'm talking about any label. It just needs to have multi-byte characters present and be using
fyne.TextTruncatedEllipsis
.How to reproduce
label := widget.NewLabel("∞ is more than 12345")
or use your favorite multi-byte UTF-8 characterlabel.Truncation = fyne.TextTruncateEllipsis
Screenshots
Example code in action:
Example code
Fyne version
2.4.0
Go compiler version
1.21.1
Operating system and version
Windows 10, macOS Ventura 13.6
Additional Information
No response
The text was updated successfully, but these errors were encountered: