Documentation ¶
Overview ¶
Package font provides support for TrueType fonts.
Index ¶
- Variables
- func Ascent(fontName string, fontSize int) float64
- func BoundingBox(fontName string) *types.Rectangle
- func CharWidth(fontName string, r rune) int
- func CoreFontNames() []string
- func Descent(fontName string, fontSize int) float64
- func GlyphSpaceUnits(userSpaceUnits float64, fontScalingFactor int) float64
- func InstallFontFromBytes(fontDir, fontName string, bb []byte) error
- func InstallTrueTypeCollection(fontDir, fn string) error
- func InstallTrueTypeFont(fontDir, fontName string) error
- func IsCoreFont(fontName string) bool
- func IsUserFont(fontName string) bool
- func LineHeight(fontName string, fontSize int) float64
- func LoadUserFonts() error
- func Read(fileName string) ([]byte, error)
- func Size(text, fontName string, width float64) int
- func SizeForLineHeight(fontName string, lh float64) int
- func Subset(fontName string, usedGIDs map[uint16]bool) ([]byte, error)
- func SupportedFont(fontName string) bool
- func TextWidth(text, fontName string, fontSize int) float64
- func UserFontNames() []string
- func UserFontNamesVerbose() []string
- func UserSpaceFontBBox(fontName string, fontSize int) *types.Rectangle
- func UserSpaceUnits(glyphSpaceUnits float64, fontScalingFactor int) float64
- type TTFLight
Constants ¶
This section is empty.
Variables ¶
var UserFontDir string
UserFontDir is the location for installed TTF or OTF font files.
var UserFontMetrics = map[string]TTFLight{}
UserFontMetrics represents font metrics for TTF or OTF font files installed into UserFontDir.
var UserFontMetricsLock = &sync.RWMutex{}
Functions ¶
func BoundingBox ¶
BoundingBox returns the font bounding box for a given font as specified in the corresponding AFM file.
func CoreFontNames ¶
func CoreFontNames() []string
CoreFontNames returns a list of the 14 PDF standard Type 1 fonts.
func GlyphSpaceUnits ¶
GlyphSpaceUnits transforms userSpaceUnits into glyphspace Units.
func InstallFontFromBytes ¶
InstallFontFromBytes saves an internal representation of TrueType font fontName to the pdfcpu config dir.
func InstallTrueTypeCollection ¶
InstallTrueTypeCollection saves an internal representation of all fonts contained in a TrueType collection to the pdfcpu config dir.
func InstallTrueTypeFont ¶
InstallTrueTypeFont saves an internal representation of TrueType font fontName to the pdfcpu config dir.
func IsCoreFont ¶
IsCoreFont returns true for the 14 PDF standard Type 1 fonts.
func IsUserFont ¶
IsUserFont returns true for installed TrueType fonts.
func LineHeight ¶
LineHeight returns fontname's line height in userspace units corresponding to fontSize.
func LoadUserFonts ¶
func LoadUserFonts() error
LoadUserFonts loads any installed TTF or OTF font files.
func Size ¶
Size returns the needed font size (aka. font scaling factor) in points for rendering a given text string using a given font name with a given user space width.
func SizeForLineHeight ¶
SizeForLineHeight returns the needed font size in points for rendering using a given font name fitting into given line height lh.
func SupportedFont ¶
SupportedFont returns true for core fonts or user installed fonts.
func TextWidth ¶
TextWidth represents the width in user space units for a given text string, font name and font size.
func UserFontNames ¶
func UserFontNames() []string
UserFontNames return a list of all installed TrueType fonts.
func UserFontNamesVerbose ¶
func UserFontNamesVerbose() []string
UserFontNamesVerbose return a list of all installed TrueType fonts including glyph count.
func UserSpaceFontBBox ¶
UserSpaceFontBBox returns the font box for given font name and font size in user space coordinates.
func UserSpaceUnits ¶
UserSpaceUnits transforms glyphSpaceUnits into userspace units.
Types ¶
type TTFLight ¶
type TTFLight struct { PostscriptName string // name: NameID 6 Protected bool // OS/2: fsType UnitsPerEm int // head: unitsPerEm Ascent int // OS/2: sTypoAscender Descent int // OS/2: sTypoDescender CapHeight int // OS/2: sCapHeight FirstChar uint16 // OS/2: fsFirstCharIndex LastChar uint16 // OS/2: fsLastCharIndex UnicodeRange [4]uint32 // OS/2: Unicode Character Range LLx, LLy, URx, URy float64 // head: xMin, yMin, xMax, yMax (fontbox) ItalicAngle float64 // post: italicAngle FixedPitch bool // post: isFixedPitch Bold bool // OS/2: usWeightClass == 7 HorMetricsCount int // hhea: numOfLongHorMetrics GlyphCount int // maxp: numGlyphs GlyphWidths []int // hmtx: fd.HorMetricsCount.advanceWidth Chars map[uint32]uint16 // cmap: Unicode character to glyph index ToUnicode map[uint16]uint32 // map glyph index to unicode character Planes map[int]bool // used Unicode planes }
TTFLight represents a TrueType font w/o font file.