Documentation ¶
Index ¶
- Constants
- type Font
- func (f *Font) Bounds(scale fixed.Int26_6) fixed.Rectangle26_6
- func (f *Font) FUnitsPerEm() int32
- func (f *Font) HMetric(scale fixed.Int26_6, i Index) HMetric
- func (f *Font) Index(x rune) Index
- func (f *Font) Kern(scale fixed.Int26_6, i0, i1 Index) fixed.Int26_6
- func (f *Font) Name(id NameID) string
- func (f *Font) VMetric(scale fixed.Int26_6, i Index) VMetric
- type FormatError
- type GlyphBuf
- type HMetric
- type Index
- type IndexableFace
- type NameID
- type Options
- type Point
- type UnsupportedError
- type VMetric
Constants ¶
const ( NameIDCopyright NameID = 0 NameIDFontFamily = 1 NameIDFontSubfamily = 2 NameIDUniqueSubfamilyID = 3 NameIDFontFullName = 4 NameIDNameTableVersion = 5 NameIDPostscriptName = 6 NameIDTrademarkNotice = 7 NameIDManufacturerName = 8 NameIDDesignerName = 9 NameIDFontDescription = 10 NameIDFontVendorURL = 11 NameIDFontDesignerURL = 12 NameIDFontLicense = 13 NameIDFontLicenseURL = 14 NameIDPreferredFamily = 16 NameIDPreferredSubfamily = 17 NameIDCompatibleName = 18 NameIDSampleText = 19 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
A Font represents a Truetype font.
func Parse ¶
Parse returns a new Font for the given TTF or TTC data.
For TrueType Collections, the first font in the collection is parsed.
func (*Font) Bounds ¶
func (f *Font) Bounds(scale fixed.Int26_6) fixed.Rectangle26_6
Bounds returns the union of a Font's glyphs' bounds.
func (*Font) FUnitsPerEm ¶
FUnitsPerEm returns the number of FUnits in a Font's em-square's side.
func (*Font) Kern ¶
Kern returns the horizontal adjustment for the given glyph pair. A positive kern means to move the glyphs further apart.
type FormatError ¶
type FormatError string
A FormatError reports that the input is not a valid TrueType font.
func (FormatError) Error ¶
func (e FormatError) Error() string
type GlyphBuf ¶
type GlyphBuf struct { // AdvanceWidth is the glyph's advance width. AdvanceWidth fixed.Int26_6 // Bounds is the glyph's bounding box. Bounds fixed.Rectangle26_6 // Points contains all Points from all contours of the glyph. If hinting // was used to load a glyph then Unhinted contains those Points before they // were hinted, and InFontUnits contains those Points before they were // hinted and scaled. Points, Unhinted, InFontUnits []Point // Ends is the point indexes of the end point of each contour. The length // of Ends is the number of contours in the glyph. The i'th contour // consists of points Points[Ends[i-1]:Ends[i]], where Ends[-1] is // interpreted to mean zero. Ends []int // contains filtered or unexported fields }
A GlyphBuf holds a glyph's contours. A GlyphBuf can be re-used to load a series of glyphs from a Font.
type IndexableFace ¶
type IndexableFace interface { font.Face // GlyphAtIndex returns the draw.DrawMask parameters (dr, mask, maskp) to draw the // glyph identified by gid at the sub-pixel destination location dot, and that glyph's // advance width. // // It returns !ok if the face does not contain a glyph for r. // // The contents of the mask image returned by one Glyph call may change // after the next Glyph call. Callers that want to cache the mask must make // a copy. GlyphAtIndex(dot fixed.Point26_6, gid Index) ( dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool) }
func NewFace ¶
func NewFace(f *Font, opts *Options) IndexableFace
NewFace returns a new font.Face for the given Font.
type NameID ¶
type NameID uint16
A NameID identifies a name table entry.
See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
type Options ¶
type Options struct { // Size is the font size in points, as in "a 10 point font size". // // A zero value means to use a 12 point font size. Size float64 // DPI is the dots-per-inch resolution. // // A zero value means to use 72 DPI. DPI float64 // Hinting is how to quantize the glyph nodes. // // A zero value means to use no hinting. Hinting font.Hinting // GlyphCacheEntries is the number of entries in the glyph mask image // cache. // // If non-zero, it must be a power of 2. // // A zero value means to use 512 entries. GlyphCacheEntries int // SubPixelsX is the number of sub-pixel locations a glyph's dot is // quantized to, in the horizontal direction. For example, a value of 8 // means that the dot is quantized to 1/8th of a pixel. This quantization // only affects the glyph mask image, not its bounding box or advance // width. A higher value gives a more faithful glyph image, but reduces the // effectiveness of the glyph cache. // // If non-zero, it must be a power of 2, and be between 1 and 64 inclusive. // // A zero value means to use 4 sub-pixel locations. SubPixelsX int // SubPixelsY is the number of sub-pixel locations a glyph's dot is // quantized to, in the vertical direction. For example, a value of 8 // means that the dot is quantized to 1/8th of a pixel. This quantization // only affects the glyph mask image, not its bounding box or advance // width. A higher value gives a more faithful glyph image, but reduces the // effectiveness of the glyph cache. // // If non-zero, it must be a power of 2, and be between 1 and 64 inclusive. // // A zero value means to use 1 sub-pixel location. SubPixelsY int // Stroke is the number of pixels that the font glyphs are being stroked. // // A zero values means no stroke. Stroke int }
Options are optional arguments to NewFace.
type Point ¶
type Point struct {
X, Y fixed.Int26_6
// The Flags' LSB means whether or not this Point is 'on' the contour.
// Other bits are reserved for internal use.
Flags uint32
}
A Point is a co-ordinate pair plus whether it is 'on' a contour or an 'off' control point.
type UnsupportedError ¶
type UnsupportedError string
An UnsupportedError reports that the input uses a valid but unimplemented TrueType feature.
func (UnsupportedError) Error ¶
func (e UnsupportedError) Error() string