-
Notifications
You must be signed in to change notification settings - Fork 2
/
subfont.go
35 lines (29 loc) · 1.19 KB
/
subfont.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2021 The Embedded Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package subfont
import "image"
// Subfont provides Last-First+1 font glyphs for runes form First to Last. The
// glyphs are stored in Data starting from Offset.
type Subfont struct {
First rune // first character in the subfont
Last rune // last character in the subfont
Offset int // offset in Data to the first character
Data Data // character data
}
// Loader is the interface that wraps the Load method.
//
// Load loads a subfont containing the given rune. A successful call returns
// the pointer to the loaded subfont. Load may also add and/or remove any
// subfonts from the current list and return the updated version.
type Loader interface {
Load(r rune, current []*Subfont) (containing *Subfont, updated []*Subfont)
}
// Data represents a glyph storage.
type Data interface {
// Advance returns the advance for the i-th glyph.
Advance(i int) int
// Glyph returns the data of the i-th glyph. The returned image is valid
// until the next Glyph call.
Glyph(i int) (img image.Image, origin image.Point, advance int)
}