font

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package font provides support for TrueType fonts.

Index

Constants

This section is empty.

Variables

View Source
var UserFontDir string

UserFontDir is the location for installed TTF or OTF font files.

View Source
var UserFontMetrics = map[string]TTFLight{}

UserFontMetrics represents font metrics for TTF or OTF font files installed into UserFontDir.

Functions

func GlyphSpaceUnits

func GlyphSpaceUnits(userSpaceUnits float64, fontScalingFactor int) float64

GlyphSpaceUnits transforms userSpaceUnits into glyphspace Units.

func InstallTrueTypeCollection

func InstallTrueTypeCollection(fontDir, fn string) error

InstallTrueTypeCollection saves an internal representation of all fonts contained in a TrueType collection to the pdfcpu config dir.

func InstallTrueTypeFont

func InstallTrueTypeFont(fontDir, fontName string) error

InstallTrueTypeFont saves an internal representation of TrueType font fontName to the pdfcpu config dir.

func IsUserFont

func IsUserFont(fontName string) bool

IsUserFont returns true for installed TrueType fonts.

func LoadUserFonts

func LoadUserFonts() error

LoadUserFonts loads any installed TTF or OTF font files.

func Read

func Read(fileName string) ([]byte, error)

Read reads in the font file bytes from gob

func Subset

func Subset(fontName string, usedGIDs map[uint16]bool) ([]byte, error)

Subset creates a new font file based on usedGIDs.

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 UserSpaceUnits

func UserSpaceUnits(glyphSpaceUnits float64, fontScalingFactor int) float64

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.

func (TTFLight) Gids

func (fd TTFLight) Gids() []int

func (TTFLight) String

func (fd TTFLight) String() string

func (TTFLight) SupportsScript

func (fd TTFLight) SupportsScript(id string) (bool, error)

SupportsScript returns true if ttf supports the unicodeblocks identified by iso15924 id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL