func fromString(s string, fc font.Face) []*glyph { var gs []*glyph for _, r := range s { if b, a, ok := fc.GlyphBounds(r); ok { gs = append(gs, &glyph{r: r, b: b, a: a}) } } return gs }
// enumerate returns all glyphs with a valid index. func enumerate(f *truetype.Font, fc font.Face) []*glyph { var gs []*glyph for r := rune(1); r < (1<<16)-1; r++ { if r == '\uFEFF' { continue // ignore BOM } if f.Index(r) != 0 { b, a, _ := fc.GlyphBounds(r) gs = append(gs, &glyph{r: r, b: b, a: a}) } } return gs }
func newGlyphPage(face fnt.Face, r rune) *glyphPage { // Start the page big enough to hold the initial rune. b, _, _ := face.GlyphBounds(r) bounds := rectangle26_6toRect(b) size := math.Size{W: glyphPageWidth, H: glyphPageHeight}.Max(bounds.Size()) size.W = align(size.W, glyphSizeAlignment) size.H = align(size.H, glyphSizeAlignment) page := &glyphPage{ image: image.NewAlpha(image.Rect(0, 0, size.W, size.H)), size: size, entries: make(map[rune]glyphEntry), rowHeight: 0, } page.add(face, r) return page }