Fix Wide Character's width caculation in TextGrid#6143
Conversation
|
Thanks for the fix. I don't think go.mod is up to date though, as the new dependency is listed as indirect. |
|
Sorry, I'm not very experienced in go package management. It has been fixed now. |
In general "go mod tidy" fixes it - but in the situation of libraries requiring higher Go versions it does get more complicated. |
|
Sorry for the additional step, but TextGrid was just updated to not draw the underline as a separate object, so this is now conflicting. |
|
Done @andydotxyz But there's one more thing I'm concerned. The width of textGrid returned by Size() is also wrong in Wide Char case. package main
import (
"fmt"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Hello World")
l := widget.NewLabel("一二三")
t := widget.NewTextGridFromString("一二三")
w.SetContent(container.NewHBox(
l, t,
))
fmt.Printf("Label width is correct as %.1f, but textgrid width is wrong as %.1f",
l.Size().Width, t.Size().Width)
// Label width is correct as 58.0, but textgrid width is wrong as 24.0
w.ShowAndRun()
}And I can't figure out a clean way to fix, because currently all cells in the TextGrid are constrained to have the same size. type textGridContent struct {
BaseWidget
text *TextGrid
rows int
cellSize fyne.Size
visible []fyne.CanvasObject
}I'd like to make a seperate PR, what do you think? |
|
For performance all cells are the same size as you say. |
|
I think it's ready now. |
* use ”stride“ approach for wide character handling * Add a test
Description:
Simply use https://github.com/mattn/go-runewidth to caculate wide char's widith in TextGrid.
Fixes #6099
Checklist: