otcmerge

package module
v0.0.0-...-0b678d4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

README

OTC Merge go.dev reference

Package otcmerge combines TrueType / OpenType font files (.ttf / .otf) into TrueType / OpenType Collection files (.ttc / .otc).

Individual TTF/OTF files store data in the SFNT format. For historical reasons, this means that each font file is limited to a maximum of 216 glyphs. This is not enough to cover all of unicode, and so a single font file cannot provide full unicode coverage.

TTC/OTC files are essentially the OpenType version of file archives. Each collection can contain multiple individual SFNT files within it. Since the SFNT format is organized as a series of data tables specified as offsets from the beginning of the file, a merged collection can also de-duplicate data by pointing to the same table from multiple SFNT "files" contained within the collection. Aside from this, the font files contained in a collection do not directly interact. This means that you cannot simply replace a TTF/OTF with a TTC/OTC in an arbitrary application and expect it to work: the application must specifically have support for reading collections.

This package exports a single function: Merge. This function takes multiple font files as input and produces an OpenType collection file as output. The output is given as an io.WriteSeeker because the function keeps minimal internal buffers. If you need the resulting file in memory instead of on disk, you can use a package like github.com/orcaman/writerseeker.

This package is meant to be used as a Go library. If you need a command-line tool to do this, you can use the otf2otc command from the Adobe Font Development Kit for OpenType, which is a far more mature project.

Documentation

Overview

Package otcmerge combines TrueType / OpenType font files (.ttf / .otf) into TrueType / OpenType Collection files (.ttc / .otc).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(fonts []io.ReadSeeker, out io.WriteSeeker, options ...Option) error

Merge combines the given fonts (in SFNT format) into a single OpenType Collection file. The input fonts must be individual TrueType / OpenType files; collections are not supported (and so this function cannot be used recursively). This merger is lossless. Merge will de-duplicate SFNT tables that are bit-for-bit matches, but it does not perform any other merging. Specifically, Merge does not parse the contents of SFNT tables.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option specifies additional configuration for Merge. No options are currently available, but the interface exists so that future changes are backward compatible.

Jump to

Keyboard shortcuts

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