fyne font example
1.0.0
英语 /日本语
示例应用程序在Fyne中使用不同的字体。
重要的
这是Fyne v2.x.的描述。如果您想知道FYNE V1.X或更早的信息,请参考V1目录。

提示
?喜欢与GUI合作吗?尝试Fyne-Theme-Generator!
fyne命令 $ go get fyne.io/fyne/v2/cmd/fyne
$ fyne
Usage: fyne [command] [parameters], where command is one of:
...
fyne bundle命令 $ fyne bundle mplus-1c-regular.ttf > bundle.go
$ head -n 9 bundle.go
// auto-generated
package main
import "fyne.io/fyne/v2"
var resourceMplus1cRegularTtf = &fyne.StaticResource{
StaticName: "mplus-1c-regular.ttf",
StaticContent: []byte{
请参阅./v2/bundle.go。
警告
文件大小很大
type myTheme struct {}
func ( * myTheme ) Font ( s fyne. TextStyle ) fyne. Resource {
if s . Monospace {
return theme . DefaultTheme (). Font ( s )
}
if s . Bold {
if s . Italic {
return theme . DefaultTheme (). Font ( s )
}
return resourceMplus1cBoldTtf
}
if s . Italic {
return theme . DefaultTheme (). Font ( s )
}
return resourceMplus1cRegularTtf
}
...请参阅./v2/theme.go。
...
a := app . New ()
a . Settings (). SetTheme ( & myTheme {})
...请参阅./v2/main.go。
bundle.go是使用Fyne命令生成的。
$ fyne bundle mplus-1c-regular.ttf > bundle.go
$ fyne bundle -append mplus-1c-bold.ttf >> bundle.go
有关更多信息,请参见下面的博客。 (日本人)
fyne命令还添加了官方教程的资源捆绑。
包括M+字体并将其用作示例字体文件。
https://mplusfonts.github.io