visualfc / atk

Another Golang Tcl/Tk binding GUI ToolKit
GNU Lesser General Public License v2.1
97 stars 19 forks source link

关于font.go #14

Closed 52LY closed 3 years ago

52LY commented 3 years ago

你好,我看了tk/font.go,

func NewUserFont(family string, size int, attributes ...*FontAttr) *UserFont
func NewUserFontFromClone(font Font) *UserFont

这两个函数返回*UserFont,我大概明白

下面几个设置*UserFont属性的函数:

func (w *UserFont) SetFamily(family string) *UserFont 
func (w *UserFont) SetSize(size int) *UserFont
func (w *UserFont) SetBold(bold bool) *UserFont 
func (w *UserFont) SetItalic(italic bool) *UserFont 
func (w *UserFont) SetUnderline(underline bool) *UserFont
func (w *UserFont) SetOverstrike(overstrike bool) *UserFont 

都返回了*UserFont,设置字体属性完毕后我感觉应该不需要返回*UserFont 如有错误,请见谅

我看了下font的demo,这里面: https://github.com/visualfc/atk_demo/blob/master/font/font.go, 第三十八行

是这样写的,w.font.SetFamily(cmbFamily.CurrentText()) 而不是 w.font = w.font.SetFamily(cmbFamily.CurrentText())

https://github.com/visualfc/atk/blob/master/tk/layout.go, 51行至81行的几个Set函数也是这样

func (w *LayoutSpacer) SetSpace(space int) *LayoutSpacer
func (w *LayoutSpacer) SetExpand(expand bool) *LayoutSpacer
func (w *LayoutSpacer) SetWidth(width int) *LayoutSpacer
func (w *LayoutSpacer) SetHeight(height int) *LayoutSpacer
visualfc commented 3 years ago

谢谢指正,这块返回 error 比较适合。

visualfc commented 3 years ago

fixed