pdfcpu: github.com/pdfcpu/pdfcpu/pkg/font Index | Files

package font

import "github.com/pdfcpu/pdfcpu/pkg/font"

Package font provides support for TrueType fonts.


Package Files

install.go metrics.go


var UserFontMetrics = map[string]TTFLight{}

UserFontMetrics represents font metrics for user installed TrueType fonts.

func Ascent Uses

func Ascent(fontName string, fontSize int) float64

Ascent returns fontname's ascent in userspace units corresponding to fontSize.

func BoundingBox Uses

func BoundingBox(fontName string) *types.Rectangle

BoundingBox returns the font bounding box for a given font as specified in the corresponding AFM file.

func CharWidth Uses

func CharWidth(fontName string, c int) int

CharWidth returns the character width for a char and font in glyph space units.

func CoreFontNames Uses

func CoreFontNames() []string

CoreFontNames returns a list of the 14 PDF standard fonts.

func Descent Uses

func Descent(fontName string, fontSize int) float64

Descent returns fontname's descent in userspace units corresponding to fontSize.

func Dir Uses

func Dir() (string, error)

Dir returns the path where pdfcpu stores font info for embedding.

func GlyphSpaceUnits Uses

func GlyphSpaceUnits(userSpaceUnits float64, fontScalingFactor int) float64

GlyphSpaceUnits transforms userSpaceUnits into glyphspace Units.

func InstallTrueTypeFont Uses

func InstallTrueTypeFont(fontDir, fontName string) error

InstallTrueTypeFont compiles font attributes needed to build a font descriptor.

func IsCoreFont Uses

func IsCoreFont(fontName string) bool

IsCoreFont returns true for the 14 PDF standard fonts.

func IsUserFont Uses

func IsUserFont(fontName string) bool

IsUserFont returns true for installed TrueType fonts.

func LineHeight Uses

func LineHeight(fontName string, fontSize int) float64

LineHeight returns fontname's line height in userspace units corresponding to fontSize.

func Read Uses

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

Read reads in the font file bytes from gob

func Size Uses

func Size(text, fontName string, width float64) int

Size returns the needed font size (aka. font scaling factor) in points for rendering a given text string using a given font name with a given user space width.

func SupportedFont Uses

func SupportedFont(fontName string) bool

SupportedFont returns true for core fonts or user installed fonts.

func TextWidth Uses

func TextWidth(text, fontName string, fontSize int) float64

TextWidth represents the width in user space units for a given text string, font name and font size.

func UserFontNames Uses

func UserFontNames() []string

UserFontNames return a list of all installed TrueType fonts.

func UserSpaceFontBBox Uses

func UserSpaceFontBBox(fontName string, fontSize int) *types.Rectangle

UserSpaceFontBBox returns the font box for given font name and font size in user space coordinates.

func UserSpaceUnits Uses

func UserSpaceUnits(glyphSpaceUnits float64, fontScalingFactor int) float64

UserSpaceUnits transforms glyphSpaceUnits into userspace units.

type TTFLight Uses

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]uint32 // cmap

TTFLight represents a TrueType font w/o font file.

func (TTFLight) IsCJK Uses

func (fd TTFLight) IsCJK() bool

func (TTFLight) String Uses

func (fd TTFLight) String() string

Package font imports 14 packages (graph) and is imported by 4 packages. Updated 2020-05-27. Refresh now. Tools for package owners.