Documentation ¶
Overview ¶
Package opentype implements OpenType fonts embedded into PDF files.
Use of this package should be avoided when creating new documents: If the given font contains CFF glyphs, then it is more efficient to embed the font via cff.NewSimple or cff.NewComposite instead. If the given font contains TrueType glyphs, truetype.NewSimple or truetype.NewComposite should be used instead of the function from this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶ added in v0.4.0
New makes a PDF font from an OpenType/TrueType font. The font can be embedded as a simple font or as a composite font.
If the font has CFF outlines, it is often more efficient to embed the CFF glyph data without the OpenType wrapper. Consider using seehuhn.de/go/pdf/font/cff.New instead of this function. If the font has TrueType outlines, it is often more efficient to embed the font as a TrueType font instead of an OpenType font. Consider using seehuhn.de/go/pdf/font/truetype.New instead of this function.
Types ¶
type FontDictCFFComposite ¶ added in v0.4.2
type FontDictCFFComposite struct { // Font is the font to embed (already subsetted, if needed). Font *sfnt.Font // SubsetTag should be a unique tag for the font subset, // or the empty string if this is the full font. SubsetTag string CMap *cmap.Info IsAllCap bool IsSmallCap bool // ToUnicode (optional) is a map from character codes to unicode strings. ToUnicode *cmap.ToUnicode }
FontDictCFFComposite is the information needed to embed a composite OpenType/CFF font.
func ExtractCFFComposite ¶
ExtractCFFComposite extracts information about a composite OpenType/CFF font from a PDF file. This is the inverse of FontDictCFFComposite.Embed.
func (*FontDictCFFComposite) Embed ¶ added in v0.4.2
Embed adds a composite OpenType/CFF font to a PDF file. This implements the font.Dict interface. This is the reverse of ExtractCFFComposite
type FontDictCFFSimple ¶ added in v0.4.2
type FontDictCFFSimple struct { // Font is the font to embed (already subsetted, if needed). Font *sfnt.Font // SubsetTag should be a unique tag for the font subset, // or the empty string if this is the full font. SubsetTag string // Encoding is the encoding vector used by the client (a slice of length 256). // This may be different from the font's built-in encoding. Encoding []glyph.ID IsAllCap bool IsSmallCap bool // ToUnicode (optional) is a map from character codes to unicode strings. ToUnicode *cmap.ToUnicode }
FontDictCFFSimple is the information needed to embed a simple OpenType/CFF font.
func ExtractCFFSimple ¶
ExtractCFFSimple extracts information about a simple OpenType/CFF font. This is the inverse of FontDictCFFSimple.Embed.
func (*FontDictCFFSimple) Embed ¶ added in v0.4.2
Embed adds the font to a PDF file. This implements the font.Dict interface. This is the reverse of ExtractCFFSimple
type FontDictGlyfComposite ¶ added in v0.4.2
type FontDictGlyfComposite struct { // Font is the font to embed (already subsetted, if needed). Font *sfnt.Font // SubsetTag should be a unique tag for the font subset, // or the empty string if this is the full font. SubsetTag string CMap *cmap.Info CIDToGID []glyph.ID ForceBold bool IsAllCap bool IsSmallCap bool // ToUnicode (optional) is a map from character codes to unicode strings. ToUnicode *cmap.ToUnicode }
FontDictGlyfComposite is the information needed to embed a composite OpenType/glyf font.
func ExtractGlyfComposite ¶
ExtractGlyfComposite extracts information for a composite OpenType/glyf font.
type FontDictGlyfSimple ¶ added in v0.4.2
type FontDictGlyfSimple struct { // Font is the font to embed (already subsetted, if needed). Font *sfnt.Font // SubsetTag should be a unique tag for the font subset, // or the empty string if this is the full font. SubsetTag string // Encoding is the encoding vector used by the client (a slice of length 256). // Together with the font's built-in encoding, this is used to determine // the `Encoding` entry of the PDF font dictionary. Encoding []glyph.ID ForceBold bool IsAllCap bool IsSmallCap bool // ToUnicode (optional) is a map from character codes to unicode strings. ToUnicode *cmap.ToUnicode }
FontDictGlyfSimple is the information needed to embed a simple OpenType/glyf font.
func ExtractGlyfSimple ¶
ExtractGlyfSimple extracts information about a simple OpenType font.