Documentation
¶
Index ¶
- type Font
- func (tt *Font) Ascender() int
- func (tt *Font) BoundingBox() string
- func (tt *Font) CMap() string
- func (tt *Font) CapHeight() int
- func (tt *Font) Codepoints(runes []rune) []int
- func (tt *Font) Descender() int
- func (tt *Font) Flags() int
- func (tt *Font) GetIndex(r rune) (int, error)
- func (tt *Font) GlyphAdvance(idx int) (int, error)
- func (tt *Font) ItalicAngle() int
- func (tt *Font) PDFName() string
- func (tt *Font) ReadTableData(tbl string) ([]byte, error)
- func (tt *Font) ReadTables() error
- func (tt *Font) StemV() int
- func (tt *Font) String() string
- func (tt *Font) Subset(codepoints []int) error
- func (tt *Font) Widths() string
- func (tt *Font) WriteSubset(w io.Writer) error
- func (tt *Font) WriteTable(w io.Writer, tbl string) error
- func (tt *Font) XHeight() int
- type Glyph
- type Head
- type Hhea
- type Maxp
- type OS2
- type OS2AdditionalFields
- type Post
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Font ¶
type Font struct {
IsCFF bool
GlyphNames []string
FontName string // PostScript name for the font. Set after names table has been read or within a CFF font
UnitsPerEM uint16
ToUni map[int]rune // glyph id to unicode value
ToCodepoint map[rune]int
Hhea Hhea
Head Head
Maxp Maxp
Post Post
OS2 OS2
OS2AdditionalFields OS2AdditionalFields
Glyph []Glyph
SubsetID string
CFF *cff.CFF
// contains filtered or unexported fields
}
Font represents the font file for a TrueType font
func LoadFace ¶
LoadFace loads a truetype font. The fontindex is a 0 based index within the font (ttc or cff for example).
func Open ¶
func Open(r io.ReadSeeker, fontindex int) (*Font, error)
Open initializes the TrueType font
func (*Font) BoundingBox ¶
BoundingBox returns the /FontBBox value for the PDF file
func (*Font) Codepoints ¶
Codepoints returns the codepoints for each rune
func (*Font) GlyphAdvance ¶
GlyphAdvance returns the width of the glyph
func (*Font) ItalicAngle ¶
ItalicAngle returns the /ItalicAngle value for the PDF file
func (*Font) ReadTableData ¶
ReadTableData does not interpret the bytes read.
func (*Font) ReadTables ¶
ReadTables reads all tables from the font file
func (*Font) Subset ¶
Subset removes all data from the font except the one needed for the given code points.
func (*Font) WriteSubset ¶
WriteSubset writes a valid font to w that is suitable for including in PDF
func (*Font) WriteTable ¶
WriteTable writes the table to w.
type Glyph ¶
type Glyph []byte
Glyph is a TrueType glyph. Since we are not interested in the glyph details, only the whole data is stored here
type Head ¶
type Head struct {
MajorVersion uint16 // 1
MinorVersion uint16 // 0
FontRevision uint32 // fixed
ChecksumAdjustment uint32 // to be calculated
MagicNumber uint32 // 0x5F0F3CF5
Flags uint16
UnitsPerEm uint16
Created uint64
Modified uint64
XMin uint16
YMin uint16
XMax uint16
YMax uint16
MacStyle uint16
LowestRecPPEM uint16
FontDirectionHint int16
IndexToLocFormat int16
GlyphDataFormat int16
}
Head Font header
type Hhea ¶
type Hhea struct {
MajorVersion uint16 // 1
MinorVersion uint16 // 0
Ascender int16 // see spec
Descender int16 // see spec
LineGap int16 // Negative LineGap values are treated as zero in some legacy platform implementations.
AdvanceWidthMax uint16
MinLeftSideBearing int16
MinRightSideBearing int16
XMaxExtent int16
CaretSlopeRise int16
CaretSlopeRun int16
CaretOffset int16
MetricDataFormat int16
NumberOfHMetrics uint16
}
Hhea Horizontal Header Table.
type Maxp ¶
type Maxp struct {
Version uint32
NumGlyphs uint16
MaxPoints uint16
MaxContours uint16
MaxCompositePoints uint16
MaxCompositeContours uint16
MaxZones uint16
MaxTwilightPoints uint16
MaxStorage uint16
MaxFunctionDefs uint16
MaxInstructionDefs uint16
MaxStackElements uint16
MaxSizeOfInstructions uint16
MaxComponentElements uint16
MaxComponentDepth uint16
}
Maxp table maxp
type OS2 ¶
type OS2 struct {
Version uint16
XAvgCharWidth int16
UsWeightClass uint16
UsWidthClass uint16
FsType uint16
YSubscriptXSize int16
YSubscriptYSize int16
YSubscriptXOffset int16
YSubscriptYOffset int16
YSuperscriptXSize int16
YSuperscriptYSize int16
YSuperscriptXOffset int16
YSuperscriptYOffset int16
YStrikeoutSize int16
YStrikeoutPosition int16
SFamilyClass int16
Panose [10]uint8
UlUnicodeRange1 uint32
UlUnicodeRange2 uint32
UlUnicodeRange3 uint32
UlUnicodeRange4 uint32
AchVendID uint32
FsSelection uint16
UsFirstCharIndex uint16
UsLastCharIndex uint16
STypoAscender int16
STypoDescender int16
STypoLineGap int16
UsWinAscent uint16
UsWinDescent uint16
}
OS2 OS/2 font table
type OS2AdditionalFields ¶
type OS2AdditionalFields struct {
UlCodePageRange1 uint32
UlCodePageRange2 uint32
SxHeight int16
SCapHeight int16
UsDefaultChar uint16
UsBreakChar uint16
UsMaxContext uint16
UsLowerOpticalPointSize uint16
UsUpperOpticalPointSize uint16
}
OS2AdditionalFields has version > 0 fields