font.go 715 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2012 The Walk Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build windows
  5. package declarative
  6. import (
  7. "github.com/lxn/walk"
  8. )
  9. type Font struct {
  10. Family string
  11. PointSize int
  12. Bold bool
  13. Italic bool
  14. Underline bool
  15. StrikeOut bool
  16. }
  17. func (f Font) Create() (*walk.Font, error) {
  18. if f.Family == "" && f.PointSize == 0 {
  19. return nil, nil
  20. }
  21. var fs walk.FontStyle
  22. if f.Bold {
  23. fs |= walk.FontBold
  24. }
  25. if f.Italic {
  26. fs |= walk.FontItalic
  27. }
  28. if f.Underline {
  29. fs |= walk.FontUnderline
  30. }
  31. if f.StrikeOut {
  32. fs |= walk.FontStrikeOut
  33. }
  34. return walk.NewFont(f.Family, f.PointSize, fs)
  35. }