font_linux.go 963 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2014 The Go 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. //go:build !android
  5. // +build !android
  6. package font
  7. import "io/ioutil"
  8. func buildDefault() ([]byte, error) {
  9. // Try Noto first, but fall back to Droid as the latter was deprecated
  10. noto, nerr := ioutil.ReadFile("/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf")
  11. if nerr != nil {
  12. if droid, err := ioutil.ReadFile("/usr/share/fonts/truetype/droid/DroidSans.ttf"); err == nil {
  13. return droid, nil
  14. }
  15. }
  16. return noto, nerr
  17. }
  18. func buildMonospace() ([]byte, error) {
  19. // Try Noto first, but fall back to Droid as the latter was deprecated
  20. noto, nerr := ioutil.ReadFile("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf")
  21. if nerr != nil {
  22. if droid, err := ioutil.ReadFile("/usr/share/fonts/truetype/droid/DroidSansMono.ttf"); err == nil {
  23. return droid, nil
  24. }
  25. }
  26. return noto, nerr
  27. }