ttf

package
v1.16.3-0...-543e744 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct {
	Embeddable             bool
	UnitsPerEm             uint16
	PostScriptName         string
	Bold                   bool
	ItalicAngle            int16
	IsFixedPitch           bool
	TypoAscender           int16
	TypoDescender          int16
	UnderlinePosition      int16
	UnderlineThickness     int16
	Xmin, Ymin, Xmax, Ymax int16
	CapHeight              int16
	Widths                 []uint16
	Chars                  map[uint16]uint16
}

T contains metrics of a TrueType font.

func Parse

func Parse(fileStr string) (TtfRec T, err error)

Parse extracts various metrics from a TrueType font file.

Example
font, err := Parse(test.FontDir() + "/calligra.ttf")
if err == nil {
	fmt.Printf("Postscript name:  %s\n", font.PostScriptName)
	fmt.Printf("unitsPerEm:       %8d\n", font.UnitsPerEm)
	fmt.Printf("Xmin:             %8d\n", font.Xmin)
	fmt.Printf("Ymin:             %8d\n", font.Ymin)
	fmt.Printf("Xmax:             %8d\n", font.Xmax)
	fmt.Printf("Ymax:             %8d\n", font.Ymax)
} else {
	fmt.Printf("%s\n", err)
}
Output:

Postscript name:  CalligrapherRegular
unitsPerEm:           1000
Xmin:                 -173
Ymin:                 -234
Xmax:                 1328
Ymax:                  899

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL