font_linux.go 921 B

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