Documentation ¶
Overview ¶
Package type1 implements Type 1 fonts embedded into PDF files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Standard = []Builtin{ Courier, CourierBold, CourierBoldOblique, CourierOblique, Helvetica, HelveticaBold, HelveticaBoldOblique, HelveticaOblique, TimesRoman, TimesBold, TimesBoldItalic, TimesItalic, Symbol, ZapfDingbats, }
Standard contains the standard 14 PDF fonts.
All of these fonts implement the font.Font interface.
Functions ¶
func New ¶
New creates a new Type 1 PDF font from a Type 1 PostScript font.
At least one of `psFont` and `metrics` must be non-nil. The font program is embedded, if and only if `psFont` is non-nil. If metrics is non-nil, information about kerning and ligatures is extracted, and the corresponding fields in the PDF font descriptor are filled.
Types ¶
type Builtin ¶
type Builtin string
Builtin is one of the 14 built-in PDF fonts.
const ( Courier Builtin = "Courier" CourierBold Builtin = "Courier-Bold" CourierBoldOblique Builtin = "Courier-BoldOblique" CourierOblique Builtin = "Courier-Oblique" Helvetica Builtin = "Helvetica" HelveticaBold Builtin = "Helvetica-Bold" HelveticaBoldOblique Builtin = "Helvetica-BoldOblique" HelveticaOblique Builtin = "Helvetica-Oblique" TimesRoman Builtin = "Times-Roman" TimesBold Builtin = "Times-Bold" TimesBoldItalic Builtin = "Times-BoldItalic" TimesItalic Builtin = "Times-Italic" Symbol Builtin = "Symbol" ZapfDingbats Builtin = "ZapfDingbats" )
The 14 standard PDF fonts.
All of these fonts implement the font.Font interface.
func (Builtin) StandardWidths ¶ added in v0.4.0
StandardWidths returns the widths of the encoded glyphs.
type FontDict ¶ added in v0.4.2
type FontDict struct { // Font (optional) is the (subsetted as needed) font to embed. // This is non-nil, if and only if the font program is embedded. // At least one of `Font` and `Metrics` must be non-nil. Font *type1.Font // Metrics (optional) are the font metrics for the font. // At least one of `Font` and `Metrics` must be non-nil. Metrics *afm.Metrics // SubsetTag should be a unique tag for the font subset, // or the empty string if this is the full font. SubsetTag string // Encoding (a slice of length 256) is the encoding vector used by the client. // When embedding a font, this is used to determine the `Encoding` entry in // the PDF font dictionary. Encoding []string // ResName is the resource name for the font (only used for PDF-1.0). ResName pdf.Name IsSerif bool IsScript bool IsAllCap bool IsSmallCap bool // ToUnicode (optional) is a map from character codes to unicode strings. ToUnicode *cmap.ToUnicode }
FontDict is the information needed to embed a Type 1 font.
func Extract ¶
Extract extracts information about a Type 1 font from a PDF file.
The `Font` field in the result is only filled if the font program is included in the file. `Metrics` is always present, and contains all information available in the PDF file.
func (*FontDict) BuiltinEncoding ¶ added in v0.4.2
BuiltinEncoding returns the builtin encoding vector for this font.
func (*FontDict) GetWidths ¶ added in v0.4.2
GetWidths returns the widths of the 256 encoded characters. The returned widths are given in PDF text space units.
func (*FontDict) GlyphList ¶ added in v0.4.2
GlyphList returns the list of glyph names, in a standardised order. Glyph IDs, where used, are indices into this list.
func (*FontDict) IsStandard ¶ added in v0.4.2
IsStandard returns true if the font is one of the 14 standard PDF fonts.
func (*FontDict) PostScriptName ¶ added in v0.4.2
PostScriptName returns the PostScript name of the font.