2

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.

rnso
  • 23,686
  • 25
  • 112
  • 234

1 Answers1

3

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.

andy.xyz
  • 2,567
  • 1
  • 13
  • 18
  • How do I add TextSize() in SetTheme() (or how to create a new theme)? Can you show me by modifying code from my question above. – rnso Aug 25 '19 at 13:08
  • There is an example in our fyne_demo app. The theme code is at https://github.com/fyne-io/fyne/blob/master/cmd/fyne_demo/screens/theme.go – andy.xyz Aug 25 '19 at 13:35
  • Using `FYNE_SCALE` environment variable is a great method. Best wishes for your software. – rnso Aug 25 '19 at 15:53
  • Any comment/answer to this question for which I have received no response: https://stackoverflow.com/questions/57503660/make-an-andlabs-ui-window-non-resizable – rnso Aug 25 '19 at 15:59
  • Is it possible to change settings like textsize and background color of individual components like a particular label or entry in `Fyne`? – rnso Aug 26 '19 at 01:11
  • I have added above as as separate question: https://stackoverflow.com/questions/57651536/how-to-change-color-of-gui-components – rnso Aug 26 '19 at 03:50