otf2ttf

package module
v0.0.0-...-a994169 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package otf2ttf converts CFF (PostScript, cubic Bézier) glyph outlines in an OpenType font to TrueType (glyf, quadratic Bézier) outlines. This exists because many printer RIPs and PDF interpreters render embedded CIDFontType2 (TrueType) fonts correctly but blank out or garble CIDFontType0 (CFF) fonts; converting the outlines lets a PDF writer embed any CFF/OpenType font in the universally supported TrueType form. Cubics are approximated with quadratic splines via the cu2qu algorithm (see cu2qu.go); with the recommended tolerance of upem/1000 the deviation is invisible at any practical size.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(sfnt *font.SFNT, maxErr float64) (*font.SFNT, error)

Convert returns a copy of the font with its CFF outlines converted to TrueType (glyf) outlines, so it can be embedded as a CIDFontType2 in a PDF. maxErr is the maximum approximation error in font units; pass 0 to use the recommended unitsPerEm/1000. Metrics tables (head, hhea, hmtx, cmap, ...) are preserved; only the outline representation changes. The conversion fails (with the original font left untouched) if any glyph's charstring cannot be interpreted, so callers can fall back to embedding the CFF as-is.

Types

This section is empty.

Jump to

Keyboard shortcuts

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