Fyne で日本語フォントを利用するサンプルアプリケーションです。
Sample application that uses different fonts in Fyne.
これは Fyne v1.x についての説明です. Fyne v2.x について知りたい場合は v2 以下を参照してください.
This is a description for Fyne v1.x. If you want to know for Fyne v2.x, please refer to the v2 directory.
If you prefer to work with the GUI, see fyne-theme-generator.
$ go get fyne.io/fyne/cmd/fyne
$ fyne
Usage: fyne [command] [parameters], where command is one of:
...
$ fyne bundle mplus-1c-regular.ttf > bundle.go
$ head -n 9 bundle.go
// auto-generated
package main
import "fyne.io/fyne"
var resourceMplus1cRegularTtf = &fyne.StaticResource{
StaticName: "mplus-1c-regular.ttf",
StaticContent: []byte{
See bundle.go.
Warning: the file size is very large
type myTheme struct{}
func (myTheme) TextFont() fyne.Resource { return resourceMplus1cRegularTtf }
...
See theme.go.
...
a := app.New()
a.Settings().SetTheme(&myTheme{})
...
See main.go.
bundle.go
は fyne command を利用して生成しています.
$ fyne bundle mplus-1c-regular.ttf > bundle.go
$ fyne bundle -append mplus-1c-bold.ttf >> bundle.go
詳細については以下の記事に記載しています.
公式のチュートリアルにもリソースのバンドルについて追記されました.
bundle.go
is generated using fyne command.
$ fyne bundle mplus-1c-regular.ttf > bundle.go
$ fyne bundle -append mplus-1c-bold.ttf >> bundle.go
See the Blog below for more information. (Japanese)
An official tutorial has also been added on resource bundling.
M+ FONTS is included and used as a sample font file.