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

Text line not displayed in RichText #3117

Closed
matwachich opened this issue Jul 4, 2022 · 1 comment
Closed

Text line not displayed in RichText #3117

matwachich opened this issue Jul 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@matwachich
Copy link
Contributor

Describe the bug:

In a RichText, when adding an Inline TextSegment{} with a .Text finishing with a line break (\r\n or \n) ; and just after, a TextSegment{} that have a multiline .Text (containing \r\n or \n), then the first line of that second TextSegment{} is not displayed.

It can get displayed after resetting the Segments and calling Refresh on the RichText

To Reproduce:

Run the code

Screenshots:

image

Example code:

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("TEST")

	rt := widget.NewRichText(
		&widget.TextSegment{
			Text: "A Title\r\n",
			Style: widget.RichTextStyle{
				Inline:    true,
				TextStyle: fyne.TextStyle{Bold: true},
			},
		},
		&widget.TextSegment{
			Text: "Here is some text,\r\nwith a line break",
		},
	)

	btn := widget.NewButton("Refresh", func() {
		rt.Segments = []widget.RichTextSegment{
			&widget.TextSegment{
				Text: "A Title\n",
				Style: widget.RichTextStyle{
					Inline:    true,
					TextStyle: fyne.TextStyle{Bold: true},
				},
			},
			&widget.TextSegment{
				Text: "Here is some text,\nwith a line break",
			},
		}
		rt.Refresh()
	})

	w.SetContent(container.NewBorder(nil, btn, nil, nil, rt))
	w.ShowAndRun()
}

Device (please complete the following information):

  • OS: Windows 10
  • Go version: 1.18.2
  • Fyne version: 2.2.2

Workaround

I noticed that you can avoid this bug by removing the trailing \r\n from the title, and placing it the begening of the multiline text
image

@matwachich matwachich added the unverified A bug that has been reported but not verified label Jul 4, 2022
@andydotxyz
Copy link
Member

This should be resolved on develop

@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Oct 4, 2022
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