Skip to content

Instantly share code, notes, and snippets.

@nwillc
Created December 29, 2021 02:05
Show Gist options
  • Save nwillc/611dceee18935d9cc5979d64ce4c331c to your computer and use it in GitHub Desktop.
Save nwillc/611dceee18935d9cc5979d64ce4c331c to your computer and use it in GitHub Desktop.
func toFontRune(fs embed.FS, fontName string, name string) (FontRune, error) {
txt, err := fs.ReadFile(fontName + "/" + name)
if err != nil {
return nil, err
}
lines := strings.Split(string(txt), "\n")
var fr [][]bool
for _, line := range lines {
if len(line) < 3 {
continue
}
var l []bool
for _, c := range line {
l = append(l, c == blackPixel)
}
fr = append(fr, l)
}
return fr, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment