Increasing default font size of this simple go gui application

别来无恙 提交于 2019-12-11 05:06:54

问题


I am using following simple demo code to create a GUI using Fyne package:

package main
import (
    "fyne.io/fyne/widget"
    "fyne.io/fyne/app"
)
func main() {
    app := app.New()
    w := app.NewWindow("Hello")
    w.SetContent(widget.NewVBox(
        widget.NewLabel("Hello Fyne!"),
        widget.NewButton("Quit", func() {
            app.Quit()
        }),
    ))
    w.ShowAndRun()
}

It works all right but I want to increase size default font of this GUI (so that font size should increase in label, button and any other widget like entry that may be added to it).

I see there is theme object (with a TextSize() function) that can possibly be used but I am not able to use it to increase font size. There is a also RenderedTextSize(string, int, TextStyle) Size in type Driver interface.

How can I increase default font in this simple GUI application? Thanks for your help.


回答1:


You can use TextSize() within theme - you would need to provide a custom theme as set it with myApp.Settings().SetTheme().

If, however, you just wish a larger application for your own setup then you should try setting the environment variable FYNE_SCALE to something like 2.0 which will scale the whole user interface. This changes the size for your computer whereas setting the TextSize in a theme would change it for everyone.

It’s worth noting that this is not “trivial” because Fyne widgets intentionally do not offer much customisation.



来源:https://stackoverflow.com/questions/57645973/increasing-default-font-size-of-this-simple-go-gui-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!