// SPDX-License-Identifier: Unlicense OR BSD-3-Clause

// Package opentype provides the low level routines // required to read and write Opentype font files, including collections. // // This package is designed to provide an efficient, lazy, reading API. // // For the parsing of the various tables, see package [tables].
package opentype type Tag uint32 // NewTag returns the tag for <abcd>. func (, , , byte) Tag { return Tag(uint32() | uint32()<<8 | uint32()<<16 | uint32()<<24) } // MustNewTag gives you the Tag corresponding to the acronym. // This function will panic if the string passed in is not 4 bytes long. func ( string) Tag { if len() != 4 { panic("invalid tag: must be exactly 4 bytes") } _ = [3] return NewTag([0], [1], [2], [3]) } // String return the ASCII form of the tag. func ( Tag) () string { return string([]byte{ byte( >> 24), byte( >> 16), byte( >> 8), byte(), }) } type GID uint32 type GlyphExtents struct { XBearing float32 // Left side of glyph from origin YBearing float32 // Top side of glyph from origin Width float32 // Distance from left to right side Height float32 // Distance from top to bottom side } type SegmentOp uint8 const ( SegmentOpMoveTo SegmentOp = iota SegmentOpLineTo SegmentOpQuadTo SegmentOpCubeTo ) type SegmentPoint struct { X, Y float32 // expressed in fonts units } // Move translates the point. func ( *SegmentPoint) (, float32) { .X += .Y += } type Segment struct { Op SegmentOp // Args is up to three (x, y) coordinates, depending on the // operation. // The Y axis increases up. Args [3]SegmentPoint } // ArgsSlice returns the effective slice of points // used (whose length is between 1 and 3). func ( *Segment) () []SegmentPoint { switch .Op { case SegmentOpMoveTo, SegmentOpLineTo: return .Args[0:1] case SegmentOpQuadTo: return .Args[0:2] case SegmentOpCubeTo: return .Args[0:3] default: panic("unreachable") } }