1 Star 0 Fork 24

eddylapis/Fyne

forked from Gitee 极速下载/Fyne 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
text.go 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Andy Williams 提交于 2019-01-03 06:12 +08:00 . Refactor to the fyne.io/fyne import URL
package canvas
import (
"image/color"
"fyne.io/fyne"
"fyne.io/fyne/theme"
)
// Text describes a text primitive in a Fyne canvas.
// A text object can have a style set which will apply to the whole string.
// No formatting or text parsing will be performed
type Text struct {
baseObject
Alignment fyne.TextAlign // The alignment of the text content
Color color.Color // The main text draw colour
Text string // The string content of this Text
TextSize int // Size of the text - if the Canvas scale is 1.0 this will be equivalent to point size
TextStyle fyne.TextStyle // The style of the text content
}
// MinSize returns the minimum size of this text objet based on it's font size and content.
// This is normally determined by the render implementation.
func (t *Text) MinSize() fyne.Size {
return fyne.CurrentApp().Driver().RenderedTextSize(t.Text, t.TextSize, t.TextStyle)
}
// NewText returns a new Text implementation
func NewText(text string, color color.Color) *Text {
return &Text{
Color: color,
Text: text,
TextSize: theme.TextSize(),
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/eddylapis/Fyne.git
git@gitee.com:eddylapis/Fyne.git
eddylapis
Fyne
Fyne
v1.0.0

搜索帮助