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

TextGrid background color shows visual artifacts when FYNE_SCALE is not 1.0, 1.5, or 2.0 #4844

Open
2 tasks done
rasteric opened this issue May 16, 2024 · 0 comments
Open
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@rasteric
Copy link

rasteric commented May 16, 2024

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 glyphs have a TextGridStyle with BGColor that differs from the background, and FYNE_SCALE is set to values like 1.2 or 1.4, then text with the background color shows some vertical and horizontal lines between glyphs. This does not occur when the scale is set to values 1.0, 1.5, and 2.0. It is only tested on Linux.

This might seem like a harmless glitch but the artifacts can be quite extreme with some colors and users who change the scale will likely set FYNE_SCALE to values such as 1.2 or 1.3 where the problem occurs.

Workaround: none known

How to reproduce

Create a TextGrid and set it as main content, use some text generator like "github.com/drhodes/golorem" to fill it with strings, set a background color range, and show and display the window with the text grid. Launch with:

FYNE_SCALE=1.2 go run grid.go

Screenshots

In the following examples, the first has Scale 1.0 and the last has 1.5. These are fine. The two in the middle have scale 1.2 and 1.4 respectively, and show the artifacts.

Grid_Scale_1 0
Grid_Scale_1 2
Grid_Scale_1 4
Grid_Scale_1 5

Example code

package main

import (
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
	lorem "github.com/drhodes/golorem"
)

func main() {
	a := app.New()
	w := a.NewWindow("Example")
    s:=""
	for i := 0; i < 60; i++ {
		s += lorem.Sentence(5, 30)
		s += "\n"
	}
    g:=widget.NewTextGridFromString(s)
    g.SetStyleRange(0,5, 50,10, &widget.CustomTextGridStyle{FGColor: theme.ForegroundColor(), BGColor: theme.SelectionColor()})
    w.SetContent(g)
    w.ShowAndRun()
}

Fyne version

2.4

Go compiler version

go version go1.22.0 linux/amd64

Operating system and version

Linux Mint 21.3 Cinnamon

Additional Information

There seems to be a line of pixels with background color between glyphs with certain scales. Some of the lines are irregular, indicating different bounding boxes of glyphs. This might be a more general driver / font rendering problem.
This could be a rounding error because the rendering is not non-pixel precise. It might be possible to fix the problem by manually drawing background rectangles of the right / a slightly larger size.

@rasteric rasteric added the unverified A bug that has been reported but not verified label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

1 participant