Skip to content

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

Closed
@dweymouth

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions