Documentation ¶
Overview ¶
Package type1 implements reading and writing of PostScript Type 1 fonts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileFormat ¶
type FileFormat int
FileFormat specifies the on-disk format of a font file.
const ( FormatPFA FileFormat = iota + 1 // hex eexec FormatPFB // hex eexec, pfb wrapper FormatBinary // binary eexec FormatNoEExec // no eexec )
List of supported file formats.
type Font ¶
type Font struct { *FontInfo Glyphs map[string]*Glyph Private *PrivateDict Encoding []string CreationDate time.Time }
Font represents a Type 1 font.
TODO(voss): make this more similar to cff.Font
func Read ¶
Read reads a Type 1 font from a reader. The function supports both ".pfa" and ".pfb" files.
func (*Font) BBox ¶
BBox returns the font bounding box. This is the smallest rectangle enclosing all glyphs in the font.
func (*Font) GlyphList ¶
GlyphList returns a list of all glyph names in the font. The list starts with ".notdef", followed by the glyphs in the Encoding vector, followed by the remaining glyph names in alphabetical order.
func (*Font) NumGlyphs ¶
NumGlyphs returns the number of glyphs in the font (including the .notdef glyph).
type FontInfo ¶
type FontInfo struct { // PostScript language name (FontName or CIDFontName) of the font. FontName string // Version is the version number of the font program. Version string // Notice is used to save any trademark notice/information for the font. Notice string // The copyright notice of the font. Copyright string // FullName is a unique, human-readable name for an individual font. FullName string // FamilyName is a human-readable name for a group of fonts that are // stylistic variants of a single design. All fonts that are members of // such a group should have exactly the same FamilyName value. FamilyName string // A human-readable name for the weight, or "boldness," of a font. Weight string // ItalicAngle is the angle, in degrees counterclockwise from the vertical, // of the dominant vertical strokes of the font. ItalicAngle float64 // IsFixedPitch is a flag indicating whether the font is a fixed-pitch // (monospaced) font. IsFixedPitch bool // UnderlinePosition is the recommended distance from the baseline for // positioning underlining strokes. This number is the y coordinate (in the // glyph coordinate system) of the center of the stroke. UnderlinePosition funit.Float64 // UnderlineThickness is the recommended stroke width for underlining, in // units of the glyph coordinate system. UnderlineThickness funit.Float64 // FontMatrix is the transformation from glyph space to user space. FontMatrix [6]float64 }
FontInfo contains information about a font.
type Glyph ¶
type Glyph struct { Cmds []GlyphOp HStem []funit.Int16 VStem []funit.Int16 WidthX float64 WidthY float64 }
Glyph represents a glyph in a Type 1 font.
TODO(voss): use float64 instead of funit.Int16?
type GlyphOp ¶
type GlyphOp struct { Op GlyphOpType Args []float64 }
GlyphOp is a Type 1 glyph drawing command.
type GlyphOpType ¶
type GlyphOpType byte
GlyphOpType is the type of a Type 1 glyph drawing command.
const ( // OpMoveTo tarts a new subpath at the given point. OpMoveTo GlyphOpType = iota + 1 // OpLineTo appends a straight line segment from the previous point to the // given point. OpLineTo // OpCurveTo appends a Bezier curve segment from the previous point to the // given point. OpCurveTo // OpClosePath closes the current subpath by appending a straight line from // the current point to the starting point of the current subpath. This // does not change the current point. OpClosePath )
func (GlyphOpType) String ¶
func (op GlyphOpType) String() string
type InvalidFontError ¶
type InvalidFontError struct {
Reason string
}
InvalidFontError indicates a problem with font data.
func (*InvalidFontError) Error ¶
func (err *InvalidFontError) Error() string
type KernPair ¶
type KernPair struct {
Left, Right string
Adjust funit.Int16 // negative = move glyphs closer together
}
KernPair represents a kerning pair.
type PrivateDict ¶
type PrivateDict struct { // BlueValues is an array containing an even number of integers. // The first integer in each pair is less than or equal to the second integer. // The first pair is the baseline overshoot position and the baseline. // All subsequent pairs describe alignment zones for the tops of character features. BlueValues []funit.Int16 OtherBlues []funit.Int16 BlueScale float64 BlueShift int32 BlueFuzz int32 // StdHW is the dominant width of horizontal stems for glyphs in the font. StdHW float64 // StdVW the dominant width of vertical stems. // Typically, this will be the width of straight stems in lower case letters. StdVW float64 ForceBold bool }
PrivateDict contains information about a font's private dictionary.
type WriterOptions ¶
type WriterOptions struct {
Format FileFormat // which file format to write (default: FormatPFA)
}
WriterOptions contains options for writing a font.