Documentation
¶
Overview ¶
Package goafm provides a custom type Number which wraps float64 value.
Index ¶
Constants ¶
const ( FontMetrics = iota CharMetrics KernData KernPairsHorizontal KernPairsVertical KernTracking Composites )
Variables ¶
var AGLFN = map[uint16]NamePair{}/* 586 elements not displayed */
AGLFN is the Adobe Glyph List for New Fonts.
Functions ¶
Types ¶
type AFMError ¶
AFMError represents an error in the AFM file.
func NewAFMError ¶
NewAFMError creates a new AFMError with the given line number and error message.
type Array ¶
type Array struct {
A []interface{}
}
Array is the implementation of an array in the AFM specification.
type Boolean ¶
type Boolean bool
Boolean represents a boolean value in the AFM specification.
func NewBoolean ¶
NewBoolean creates a new Boolean with the value represented by the string.
type CharMetric ¶
type CharMetric struct {
C int // C is the character code. REQUIRED.
WX Number // WX is the character width. REQUIRED.
W0X Number // W0X is the character width in x for direction 0.
W1X Number // W1X is the character width in x for direction 1.
WY Number // WY is the character width in y.
W0Y Number // W0Y is the character width in y for direction 0.
W1Y Number // W1Y is the character width in y for direction 1.
W [2]Number // W is the character width vector.
W0 [2]Number // W0 is the character width vector for direction 0.
W1 [2]Number // W1 is the character width vector for direction 1.
VV [2]Number // VV has the same meaning as VVector in the global font program information, but for a single character.
N string // N is the character name.
B [4]Number // B is the bounding box.
L [2]string // L is the ligature sequence.
}
CharMetric defines the structure of a character metric in an AFM file. It holds information about a character's code, width, bounding box, name, and ligature sequence.
func (CharMetric) String ¶
func (c CharMetric) String() string
type Composite ¶
type Composite struct {
// Name is the name of the composite
Name string
// Parts is a slice of CompositePart instances
Parts []CompositePart
}
Composite represents a structure containing information about a composite
type CompositePart ¶
type CompositePart struct {
// Name is the name of the part
Name string
// Dx is the x-dimension of the part
Dx Number
// Dy is the y-dimension of the part
Dy Number
}
CompositePart represents a single part in a composite
type FontMetric ¶
type FontMetric struct {
FontName string // (Required) Name of the font program as presented to the PostScript language `findfont` operator.
FullName string // (Optional) The full text name of the font.
FamilyName string // (Optional) The name of the typeface family to which the font belongs.
Weight string // (Optional) Weight of the font.
FontBBox [4]Number // Four numbers giving the lower left corner and the upper right corner of the font bounding box, in the sequence llx lly urx ury.
Version string // (Optional) Font program version identifier. Matches the string found in the FontInfo dictionary of the font program itself.
Notice string // (Optional) Font name trademark or copyright notice.
EncodingScheme string // (Optional) String indicating the default encoding vector for this font program.
MappingScheme int // (Not present with base font programs.) Integer code describing the mapping scheme.
EscapeChar int // (Required if MappingScheme 3, not present otherwise). The byte value of the escape character used for this escape-mapped font program.
CharacterSet string // (Optional) String describing the character set (glyph complement) of this font program.
Characters int // (Optional) The number of characters defined in this font program.
IsBaseFont Boolean // (Optional) boolean is true if this font program is a base font and false otherwise.
VVector [2]Number // (Required when MetricsSets 2) Components of a vector from origin 0 (the origin for writing direction 0) to origin 1 (the origin for writing direction 1).
IsFixedV Boolean // (Optional) If boolean is true, this indicates that VVector is the same for every character in this font.
IsCIDFont Boolean // (Required if AFM is for a CID-keyed font) If the boolean is true, the font is a CID-keyed font, and the metrics are in CID number order
CapHeight Number // (Optional) Usually the y-value of the top of the capital H. If this font program contains no capital H, this keyword might be missing or numbermight be 0.
XHeight Number // (Optional) Typically the y-value of the top of the lowercase x. If this font program contains no lowercase x, this keyword might be missing or numbermight be 0.
Ascender Number // (Optional) For roman font programs: usually the y-value of the top of the lowercase d. If this font program contains no lowercase d, this keyword mightbe missing or number might be 0.
Descender Number // (Optional) For roman font programs: typically the y-value of the bottom of the lowercase p. If this font program contains no lowercase p, this keywordmight be missing or number might be 0.
StdHW Number // (Optional) This number specifies the dominant width of horizontal stems
StdVW Number // (Optional) This number specifies the dominant width of vertical stems
BlendAxisTypes Array // (Required) The value of BlendAxisTypes is an array of strings that specify the name of each axis in the order in which the master designs are organizedin the multiple master font program.
BlendDesignPositions Array // (Required) The value of BlendDesignPositions is an array of k arrays that give the locations of the k master designs in the design space. E
BlendDesignMap Array // (Required) The value of BlendDesignMap is an array of n arrays where n is the number of design axes contained in the multiple master font program.
WeightVector Array // (Required) The WeightVector array specifies the factors for deriving a weighted average of the master designs in a multiple master font program.
UnderlinePosition Number // (Optional) Distance from the baseline for centering underlining strokes.
UnderlineThickness Number // (Optional) This is the stroke width for underlining, and is generally proportional to the stroke widths of characters in the font program.
ItalicAngle Number // (Optional) Angle (in degrees counter-clockwise from the vertical) of the dominant vertical strokes of the font.
CharWidth [2]Number // (Optional) The x and y components of the width vector of this font program’s characters.
IsFixedPitch Boolean // (Optional) If boolean is true, this indicates that the font program is a fixed pitch (monospaced) font.
CharMetricsByCode map[int]*CharMetric
CharMetricsByName map[string]*CharMetric
KernPair map[string]map[string]*KernPair
KernPairVertical map[string]map[string]*KernPair
KernTracks map[int]*KernTrack
Composites map[string]*Composite
}
FontMetric from an AFM file provides both global metrics for a font program and the metrics of each individual character.
func Parse ¶
func Parse(b []byte) (*FontMetric, error)
Parse takes in a byte slice and returns a FontMetric pointer and an error.
func ParseFile ¶
func ParseFile(filename string) (*FontMetric, error)
ParseFile takes in a filename and returns a FontMetric pointer and an error.
func (*FontMetric) MetricByCode ¶
func (fm *FontMetric) MetricByCode(code int) *CharMetric
MetricByCode returns the CharMetric of the font metric by code.
func (*FontMetric) MetricByName ¶
func (fm *FontMetric) MetricByName(name string) *CharMetric
MetricByName returns the CharMetric of the font metric by name.
func (*FontMetric) MetricByRune ¶
func (fm *FontMetric) MetricByRune(r rune) *CharMetric
MetricByRune returns the CharMetric of the font metric by the rune representation.
type KernPair ¶
type KernPair struct {
// First is the first character of the kern pair
First string
// Second is the second character of the kern pair
Second string
// DX is the horizontal adjustment for the kern pair
DX Number
// DY is the vertical adjustment for the kern pair
DY Number
}
KernPair defines the KernPair data structure
type KernTrack ¶
type KernTrack struct {
// Degree holds the degree of the kerning.
Degree int
// MinPt holds the minimum point size for the kerning.
MinPt Number
// MinKern holds the minimum kerning for the minimum point size.
MinKern Number
// MaxPt holds the maximum point size for the kerning.
MaxPt Number
// MaxKern holds the maximum kerning for the maximum point size.
MaxKern Number
}
KernTrack holds information about kerning for a font with a specific degree.
type NamePair ¶
type NamePair struct {
// contains filtered or unexported fields
}
NamePair is a pair of glyph name and character name.
type Number ¶
type Number float64
Number type wraps float64 value.
func (*Number) IsInt ¶
IsInt returns a boolean indicating whether the Number type holds an int value.