Documentation ¶
Overview ¶
Package type1 implements a parser for Adobe Type1 fonts, defined by .afm files (https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5004.AFM_Spec.pdf) and .pdf files (https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/T1_SPEC.pdf)
Index ¶
- Constants
- func Load(file fonts.Resource) (fonts.Faces, error)
- func ScanFont(file fonts.Resource) ([]fonts.FontDescriptor, error)
- type AFMFont
- type CharMetric
- type Encoding
- type Fl
- type Font
- func (f *Font) Cmap() (fonts.Cmap, fonts.CmapEncoding)
- func (f *Font) FontHExtents() (fonts.FontExtents, bool)
- func (f *Font) FontVExtents() (fonts.FontExtents, bool)
- func (f *Font) GlyphData(gid fonts.GID, _, _ uint16) fonts.GlyphData
- func (f *Font) GlyphExtents(glyph fonts.GID, _, _ uint16) (fonts.GlyphExtents, bool)
- func (Font) GlyphHOrigin(fonts.GID) (x, y int32, found bool)
- func (f *Font) GlyphName(gid fonts.GID) string
- func (Font) GlyphVOrigin(fonts.GID) (x, y int32, found bool)
- func (f *Font) HorizontalAdvance(gid fonts.GID) float32
- func (f *Font) LineMetric(metric fonts.LineMetric) (float32, bool)
- func (Font) LoadBitmaps() []fonts.BitmapSize
- func (f *Font) LoadMetrics() fonts.FaceMetrics
- func (f *Font) LoadSummary() (fonts.FontSummary, error)
- func (f *Font) NominalGlyph(ch rune) (fonts.GID, bool)
- func (Font) NormalizeVariations(coords []float32) []float32
- func (f *Font) PoscriptName() string
- func (f *Font) PostscriptInfo() (fonts.PSInfo, bool)
- func (f *Font) Upem() uint16
- func (f *Font) VerticalAdvance(gid fonts.GID) float32
- type KernPair
Constants ¶
const (
CHARSTRING_KEY = 4330
)
const Notdef = ".notdef"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AFMFont ¶
type AFMFont struct { // Represents the section CharMetrics in the AFM file. // The key is the name of the char. // Even not encoded chars are present CharMetrics map[string]CharMetric CharCodeToCharName [256]string // encoded chars KernPairs map[string][]KernPair // the character set of the font. CharacterSet string fonts.PSInfo Ascender Fl CapHeight Fl Descender Fl Llx Fl // the llx of the FontBox Lly Fl // the lly of the FontBox Urx Fl // the urx of the FontBox Ury Fl // the ury of the FontBox XHeight int StdHw int StdVw int // contains filtered or unexported fields }
AFMFont represents a type1 font as found in a .afm file.
func ParseAFMFile ¶
ParseAFMFile read a .afm file and return the associated font.
func (AFMFont) CharSet ¶
CharSet returns a string listing the character names defined in the font subset. The names in this string shall be in PDF syntax—that is, each name preceded by a slash (/). The names may appear in any order. The name .notdef shall be omitted; it shall exist in the font subset.
type CharMetric ¶
type Encoding ¶
type Encoding struct { Custom simpleencodings.Encoding Standard bool }
Encoding is either the standard encoding, or defined by the font
type Font ¶
type Font struct { Encoding *simpleencodings.Encoding FontID string FontBBox []Fl FontMatrix []Fl fonts.PSInfo StrokeWidth Fl PaintType int FontType int UniqueID int // contains filtered or unexported fields }
Font exposes the content of a .pfb file. The main field, regarding PDF processing, is the Encoding entry, which defines the "builtin encoding" of the font.
func Parse ¶
Parse parses an Adobe Type 1 (.pfb) font file. See `ParseAFMFile` to read the associated Adobe font metric file.
func (*Font) FontHExtents ¶
func (f *Font) FontHExtents() (fonts.FontExtents, bool)
func (*Font) FontVExtents ¶
func (f *Font) FontVExtents() (fonts.FontExtents, bool)
FontVExtents returns zero values.
func (*Font) GlyphData ¶ added in v0.0.5
GlyphData returns the outlines of the given glyph. The returned value is either a fonts.GlyphOutline or nil if an error occured.
func (*Font) GlyphExtents ¶
func (Font) GlyphHOrigin ¶
GlyphHOrigin always return 0,0,true
func (Font) GlyphVOrigin ¶
GlyphVOrigin always return 0,0,false
func (*Font) HorizontalAdvance ¶
HorizontalAdvance returns the advance of the glyph with index `index` The return value is expressed in font units. 0 is returned for invalid index values and for invalid charstring glyph data.
func (*Font) LineMetric ¶
func (f *Font) LineMetric(metric fonts.LineMetric) (float32, bool)
func (Font) LoadBitmaps ¶ added in v0.0.2
func (Font) LoadBitmaps() []fonts.BitmapSize
func (*Font) LoadMetrics ¶
func (f *Font) LoadMetrics() fonts.FaceMetrics
LoadMetrics returns the font itself.
func (*Font) LoadSummary ¶
func (f *Font) LoadSummary() (fonts.FontSummary, error)
func (Font) NormalizeVariations ¶
func (*Font) PoscriptName ¶
type KernPair ¶
type KernPair struct { SndChar string // glyph name // KerningDistance is expressed in glyph units. // It is most often negative, // that is, a negative value indicates that chars // should be closer. KerningDistance int }
KernPair represents a kerning pair, from an implicit first first glyph.