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 EmbedInfoCFFComposite ¶
type EmbedInfoCFFComposite 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 }
EmbedInfoCFFComposite 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 EmbedInfoCFFComposite.Embed.
func (*EmbedInfoCFFComposite) Embed ¶
Embed adds a composite OpenType/CFF font to a PDF file. This is the reverse of ExtractCFFComposite
type EmbedInfoCFFSimple ¶
type EmbedInfoCFFSimple 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 }
EmbedInfoCFFSimple 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 EmbedInfoCFFSimple.Embed.
func (*EmbedInfoCFFSimple) Embed ¶
Embed adds the font to a PDF file. This is the reverse of ExtractCFFSimple
type EmbedInfoGlyfComposite ¶
type EmbedInfoGlyfComposite 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 }
EmbedInfoGlyfComposite is the information needed to embed a composite OpenType/glyf font.
func ExtractGlyfComposite ¶
ExtractGlyfComposite extracts information for a composite OpenType/glyf font.
type EmbedInfoGlyfSimple ¶
type EmbedInfoGlyfSimple 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 }
EmbedInfoGlyfSimple is the information needed to embed a simple OpenType/glyf font.
func ExtractGlyfSimple ¶
ExtractGlyfSimple extracts information about a simple OpenType font.