Documentation
¶
Overview ¶
Package sfnt implements support for OpenType and TrueType font files.
Index ¶
- type Font
- func (f *Font) AsCFF() *cff.Font
- func (f *Font) BBox() (bbox funit.Rect16)
- func (f *Font) Clone() *Font
- func (f *Font) EnsureGlyphNames()
- func (f *Font) FullName() string
- func (f *Font) GetFontInfo() *type1.FontInfo
- func (f *Font) GlyphBBox(gid glyph.ID) funit.Rect16
- func (f *Font) GlyphBBoxes() []funit.Rect16
- func (f *Font) GlyphName(gid glyph.ID) string
- func (f *Font) GlyphWidth(gid glyph.ID) funit.Int16
- func (f *Font) GlyphWidthPDF(gid glyph.ID) float64
- func (f *Font) InstallCMap(s cmap.Subtable)
- func (f *Font) IsCFF() bool
- func (f *Font) IsFixedPitch() bool
- func (f *Font) IsGlyf() bool
- func (f *Font) MakeGlyphNames() []string
- func (f *Font) NewLayouter(lang language.Tag, gsubFeatures, gposFeatures map[string]bool) (*Layouter, error)
- func (f *Font) NumGlyphs() int
- func (f *Font) PostScriptName() string
- func (f *Font) Subfamily() string
- func (f *Font) Subset(glyphs []glyph.ID) (*Font, error)
- func (f *Font) Widths() []funit.Int16
- func (f *Font) WidthsPDF() []float64
- func (f *Font) Write(w io.Writer) (int64, error)
- func (f *Font) WriteOpenTypeCFFPDF(w io.Writer) error
- func (f *Font) WriteTrueTypePDF(w io.Writer) (int64, error)
- type Layouter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Font ¶ added in v0.3.5
type Font struct { FamilyName string Width os2.Width Weight os2.Weight IsRegular bool // glyphs are in the standard weight/style for the font IsBold bool // glyphs are emboldened IsItalic bool // font contains italic or oblique glyphs IsOblique bool // font contains oblique glyphs IsSerif bool IsScript bool // Glyphs resemble cursive handwriting. CodePageRange os2.CodePageRange Version head.Version CreationTime time.Time ModificationTime time.Time Description string SampleText string Copyright string Trademark string License string LicenseURL string PermUse os2.Permissions UnitsPerEm uint16 FontMatrix [6]float64 Ascent funit.Int16 Descent funit.Int16 // negative LineGap funit.Int16 // LineGap = Leading - Ascent + Descent CapHeight funit.Int16 XHeight funit.Int16 ItalicAngle float64 // Italic angle (degrees counterclockwise from vertical) UnderlinePosition funit.Float64 // Underline position (negative) UnderlineThickness funit.Float64 // Underline thickness Outlines interface{} // either *cff.Outlines or *glyf.Outlines CMapTable cmap.Table Gdef *gdef.Table Gsub *gtab.Info Gpos *gtab.Info }
Font contains information about a TrueType or OpenType font.
TODO(voss): clarify the relation between IsOblique, IsItalic, and ItalicAngle != 0.
func Read ¶
Read reads a TrueType or OpenType font from an io.Reader. If r does not implement the io.ReaderAt interface, the whole font file will be read into memory.
func (*Font) AsCFF ¶ added in v0.3.5
AsCFF returns the CFF font data for the given font. Panics if the font does not contain CFF outlines.
func (*Font) EnsureGlyphNames ¶ added in v0.3.5
func (f *Font) EnsureGlyphNames()
EnsureGlyphNames makes sure that all glyphs in the font have a name. If all names are present, the function does nothing. Otherwise, the function tries to infer the missing glyph names from the "cmap" and "gsub" tables.
func (*Font) GetFontInfo ¶ added in v0.3.5
GetFontInfo returns an Adobe FontInfo structure for the given font.
func (*Font) GlyphBBox ¶ added in v0.3.5
GlyphBBox returns the glyph bounding box for one glyph in font design units.
func (*Font) GlyphBBoxes ¶ added in v0.3.5
GlyphBBoxes returns the glyph bounding boxes for the font.
func (*Font) GlyphName ¶ added in v0.3.5
GlyphName returns the name of a glyph. If the name is not known, the empty string is returned.
func (*Font) GlyphWidth ¶ added in v0.3.5
GlyphWidth returns the advance width of the glyph with the given glyph ID, in font design units.
func (*Font) GlyphWidthPDF ¶ added in v0.4.0
GlyphWidthPDF returns the advance width in PDF text space units.
func (*Font) InstallCMap ¶ added in v0.3.5
InstallCMap replaces the cmap table in the font with the given subtable.
func (*Font) IsFixedPitch ¶ added in v0.3.5
IsFixedPitch returns true if all glyphs in the font have the same width.
func (*Font) IsGlyf ¶ added in v0.3.5
IsGlyf returns true if the font contains TrueType glyph outlines.
func (*Font) MakeGlyphNames ¶ added in v0.3.5
MakeGlyphNames returns a list of glyph names which can be used for the font. If all names are present, the function returns the existing names. Otherwise, the function tries to infer the missing glyph names from the "cmap" and "gsub" tables.
func (*Font) NewLayouter ¶ added in v0.4.5
func (f *Font) NewLayouter(lang language.Tag, gsubFeatures, gposFeatures map[string]bool) (*Layouter, error)
NewLayouter creates a new layouter for the given cmap and lookups.
func (*Font) PostScriptName ¶ added in v0.4.0
PostScriptName returns the PostScript name of the font.
func (*Font) Subset ¶ added in v0.3.5
Subset returns a subset of the font containing containing the given glyphs at the first positions. More glyphs may be included in the subset, if they occur as ligatures between the given glyphs.
func (*Font) WidthsPDF ¶ added in v0.4.0
WidthsPDF returns the advance widths of the glyphs in the font.
func (*Font) WriteOpenTypeCFFPDF ¶ added in v0.3.5
WriteOpenTypeCFFPDF writes a minimal OpenType file, which includes only the tables required for PDF embedding.
func (*Font) WriteTrueTypePDF ¶ added in v0.3.5
WriteTrueTypePDF writes the binary form of a TrueType font to the given writer. Only the tables needed for PDF embedding are included.
if the font does not use TrueType outlines, the function panics.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package cff implements reading and writing of CFF fonts.
|
Package cff implements reading and writing of CFF fonts. |
Package cmap reads and writes "cmap" tables.
|
Package cmap reads and writes "cmap" tables. |
examples
|
|
extract-cff
Extract-cff extracts the CFF data from OpenType font files.
|
Extract-cff extracts the CFF data from OpenType font files. |
font-info
Font-info shows information about a font file.
|
Font-info shows information about a font file. |
list-sfnt-tables
List-sfnt-tables prints a list of the tables in an sfnt font file.
|
List-sfnt-tables prints a list of the tables in an sfnt font file. |
rewrite-font
Rewrite-font rewrites the font files given on the command line.
|
Rewrite-font rewrites the font files given on the command line. |
Package glyf reads and writes "glyf" and "loca" tables.
|
Package glyf reads and writes "glyf" and "loca" tables. |
Package glyph contains types for representing glyphs.
|
Package glyph contains types for representing glyphs. |
Package head reads and writes "head" tables.
|
Package head reads and writes "head" tables. |
Package header reads and writes TrueType and OpenType file headers.
|
Package header reads and writes TrueType and OpenType file headers. |
Package hmtx reads and writes "hhea" and "hmtx" tables.
|
Package hmtx reads and writes "hhea" and "hmtx" tables. |
internal
|
|
debug
Package debug provides a simple font for use in unit tests.
|
Package debug provides a simple font for use in unit tests. |
Package kern reads and writes "kern" tables.
|
Package kern reads and writes "kern" tables. |
Package mac implements the Mac Roman encoding.
|
Package mac implements the Mac Roman encoding. |
Package maxp reads and writes "maxp" tables.
|
Package maxp reads and writes "maxp" tables. |
Package name reads and writes "name" tables.
|
Package name reads and writes "name" tables. |
opentype
|
|
anchor
Package anchor encodes and decodes OpenType "Anchor Tables".
|
Package anchor encodes and decodes OpenType "Anchor Tables". |
classdef
Package classdef reads and writes OpenType "Class Definition Tables".
|
Package classdef reads and writes OpenType "Class Definition Tables". |
coverage
Package coverage reads and writes OpenType "Coverage Tables".
|
Package coverage reads and writes OpenType "Coverage Tables". |
gdef
Package gdef reads and writes OpenType "GDEF" tables.
|
Package gdef reads and writes OpenType "GDEF" tables. |
gtab
Package gtab reads and writes OpenType "GSUB" and "GPOS" tables.
|
Package gtab reads and writes OpenType "GSUB" and "GPOS" tables. |
markarray
Package markarray contains types for representing OpenType mark array tables.
|
Package markarray contains types for representing OpenType mark array tables. |
Package os2 reads and writes "OS/2" tables.
|
Package os2 reads and writes "OS/2" tables. |
Package post reads and writes "post" tables.
|
Package post reads and writes "post" tables. |