fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.56k stars 1.37k forks source link

Fyne doesn't recognize my screens DPI #3630

Open heytyshawn opened 1 year ago

heytyshawn commented 1 year ago

Checklist

Describe the bug

When I run any fyne app the text is twice as big and blurry. I have another monitor plugged in and I have to move the window between screens to get it to scale down properly.

How to reproduce

  1. Run your app.
  2. Move the window to another monitor (that you have plugged in)
  3. Move the window back

You may have to do it 3-4 times but it'll eventually scale it down properly.

Screenshots

image image image

Example code

package main

import (
    "fmt"
    "time"

    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/widget"
)

func main() {
    a := app.New()
    win := a.NewWindow("Title")

    clock := widget.NewLabel("")
    updateTime(clock)
    win.SetContent(clock)
    go func() {
        for range time.Tick(time.Second) {
            updateTime(clock)
        }
    }()
    win.Show()
    a.Run()
    fmt.Println("Program closed!")
}

func updateTime(clock *widget.Label) {
    clock.SetText(time.Now().Format("Time: 03:04:05"))
}

Fyne version

v2.3.0

Go compiler version

go1.19.3 windows/amd64

Operating system

Windows

Operating system version

Windows 11

Additional Information

SYSTEM MODEL: ASUS Tuf Gaming FX505DT OS: Windows 11 64 bit PROCESSOR: AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx

heytyshawn commented 1 year ago

this is my first time opening an issue so let me know if i did something wrong

andydotxyz commented 1 year ago

Thanks for this. Just for clarity, the text is the right size - but the window is too large, is that correct?

heytyshawn commented 1 year ago

i'm sorry for the late reply, the window is the correct size I believe but the text is upscaled and blurry. I have to move it between monitors for it to sccale down.

heytyshawn commented 1 year ago

actually i after running the demo, the window is also too big at first and all the text are also upscaled and blurry when you launch the app. i screenshotted it over vs code so you could compare it to their text size. once i move the window back and forth between monitors everything scales down to the right size as shown in the screenshots

before image

after image

heytyshawn commented 1 year ago

Thanks for this. Just for clarity, the text is the right size - but the window is too large, is that correct?

I'm not sure if I have to use the reply feature in order to ping you

andydotxyz commented 1 year ago

Can you please describe the resolution, physical size and arrangement of each of your monitors?

Please can you switch fyne_Demo to the "Advanced" tab and quit it? Then load again. On the initial load read out the scale value, tell us the new value when you move to the other monitor, and then again what the value is when you move back?

Thanks!

jackbillstrom commented 1 year ago

@andydotxyz This one seems to turn cold, however I'm experiencing the same issue on my Ubuntu desktop.

When I run go run fyne.io/fyne/v2/cmd/fyne_demo@latest and visit the "Advanced tab" I get the following values (in barely a second)

But then it flashes and turns into:

I haven't activated any scaling on my Ubuntu 23.04 laptop.

Screen

14-inch FHD, (1920 x 1080) 16:91920x1080 pixels, 144hz internal on a Asus Rog G14 Zephyrus

Fyne version

v2.3.5

Go compiler version

go version go1.20.3 linux/amd64

Operating system

Ubuntu Desktop 23.04, using Wayland Gnome Version 44.2 Linux 6.2.0-25-generic

EDIT Not able to test it between two displays until next week.

andydotxyz commented 1 year ago

Given that the issue above is reported to be about multiple screens I don't see how your issue can be the same if you've not tested it with an external display?

From your info above I'm not sure that I see what the problem is, it seems to be identifying the DPI correctly (though not fast perhaps?)

jackbillstrom commented 1 year ago

I apologize if I was not clear about my problem, I felt that this was similar so I jumped on this issue.

My main problem is that FYNE_SCALE isn't being treated correctly when I try to force it to "1", only want's to be "1.3", to try getting rid of the "blur".

Saw a solution to hard code the env FYNE_SCALE using os.Setenv("FYNE_SCALE", "1") at https://github.com/fyne-io/fyne/issues/2897 but without any different result.

And after looking around here and seeing this issue, I thought we've might be having the same issue.

Sorry about that and thanks for a great project 🫡

andydotxyz commented 1 year ago

My main problem is that FYNE_SCALE isn't being treated correctly when I try to force it to "1", only want's to be "1.3", to try getting rid of the "blur".

That's not what FYNE_SCALE does. A value of 1 attempts to match the OS. On macOS and Windows that is easy as they have defined scale. On Linux this is not the case as each DE/WM handles it differently. We cannot work relative to pixel size because a UHDPI display would show your window at 1/2 the size or less of another screen. So we use the DPI to work out what a standard font size would use in pixels - that is the baseline (on your system this is 1.3). From there FYNE_SCALE goes up or down. So you could use 0.77 to take the 1.3 down to 1.0...

andydotxyz commented 1 year ago

Can you please describe the resolution, physical size and arrangement of each of your monitors?

Please can you switch fyne_Demo to the "Advanced" tab and quit it? Then load again. On the initial load read out the scale value, tell us the new value when you move to the other monitor, and then again what the value is when you move back?

Thanks!

Can you help us with this info @heytyshawn ? I have not been able to replicate

db47h commented 10 months ago

See https://github.com/fyne-io/fyne/issues/3537#issuecomment-1793482457 for a possible explanation/workaround.

Although this is for a different OS, AFAIK Windows also uses the monitor's EDID to get its physical size, and glfw uses that same information.