Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese text doesn't truncate properly using fyne.TextTruncateEllipsis #4998

Closed
2 tasks done
dweymouth opened this issue Jul 11, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@dweymouth
Copy link
Contributor

Checklist

  • 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

When truncating text in a label, richtext, etc. Japanese text (and possibly other scripts too) don't truncate at the right position and instead overstep the boundary of the widget.

How to reproduce

Run the example app

Screenshots

image

Example code

package main

import (
	"image/color"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/layout"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("Test truncate")
	l1 := widget.NewLabel("hereisakindoflonglabeltextwithnospaces")
	l1.Truncation = fyne.TextTruncateEllipsis
	l2 := widget.NewLabel("これはテキストの切り捨てがどのように機能するかをテストするための日本語の文です")
	l2.Truncation = fyne.TextTruncateEllipsis
	rect := &canvas.Rectangle{
		StrokeColor: &color.NRGBA{R: 255, A: 255},
		StrokeWidth: 2,
	}
	w.SetContent(container.New(layout.NewGridLayoutWithColumns(2),
		container.NewVBox(l1, l2),
		rect,
	))
	w.Resize(fyne.NewSize(300, 150))
	w.ShowAndRun()
}

Fyne version

develop

Go compiler version

n/a

Operating system and version

mac

Additional Information

No response

@dweymouth dweymouth added unverified A bug that has been reported but not verified bug Something isn't working and removed unverified A bug that has been reported but not verified labels Jul 11, 2024
@dweymouth dweymouth changed the title Japanese text doesn't truncate properly Japanese text doesn't truncate properly using fyne.TextTruncateEllipsis Jul 12, 2024
@dweymouth dweymouth added this to the E fixes (v2.5.x) milestone Jul 14, 2024
@andydotxyz
Copy link
Member

I have a local fix that should resolve the issue and will open a PR soon.
However it does not completely fix the test case provided as that is a mix of different types of text which triggers a bug in go-text as far as I can see. Reported upstream and will see what the team say (go-text/typesetting#166)

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jul 19, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 28, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Jul 28, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Aug 19, 2024
dweymouth added a commit to dweymouth/fyne that referenced this issue Aug 19, 2024
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Aug 30, 2024
@andydotxyz
Copy link
Member

Fixed on develop, will merge to release before .2

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Oct 10, 2024
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants