cmap

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Overview

Package cmap reads and writes "cmap" tables. https://docs.microsoft.com/en-us/typography/opentype/spec/cmap

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format12 added in v0.3.4

type Format12 map[uint32]glyph.ID

Format12 represents a format 12 cmap subtable. https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#format-12-segmented-coverage

The binary encoding is most efficient, if consecutive code points are mapped to consecutive glyph IDs.

func (Format12) CodeRange added in v0.3.4

func (cmap Format12) CodeRange() (low, high rune)

func (Format12) Encode added in v0.3.4

func (cmap Format12) Encode(language uint16) []byte

func (Format12) Lookup added in v0.3.4

func (cmap Format12) Lookup(code rune) glyph.ID

type Format4

type Format4 map[uint16]glyph.ID

Format4 represents a format 4 cmap subtable. https://docs.microsoft.com/en-us/typography/opentype/spec/cmap#format-4-segment-mapping-to-delta-values

func (Format4) CodeRange

func (cmap Format4) CodeRange() (low, high rune)

CodeRange returns the smallest and largest code point in the subtable.

func (Format4) Encode

func (cmap Format4) Encode(language uint16) []byte

Encode encodes the subtable into a byte slice.

func (Format4) Lookup

func (cmap Format4) Lookup(r rune) glyph.ID

Lookup implements the Subtable interface.

type Key

type Key struct {
	PlatformID uint16 // Platform ID.
	EncodingID uint16 // Platform-specific encoding ID.
	Language   uint16
}

Key selects a subtable of a cmap table.

type Subtable

type Subtable interface {
	// Lookup returns the glyph index for the given rune.
	// If the rune is not found, Lookup returns 0 (corresponding to the ".notdef" glyph).
	Lookup(r rune) glyph.ID

	// Encode returns the binary form of the subtable.
	Encode(language uint16) []byte

	// CodeRange returns the smallest and largest code point in the subtable.
	CodeRange() (low, high rune)
}

Subtable represents a decoded cmap subtable.

type Table

type Table map[Key][]byte

Table contains all subtables from a cmap table.

func Decode

func Decode(data []byte) (Table, error)

Decode returns all subtables of the given "cmap" table. The returned subtables are guaranteed to be at least 10 bytes long and to have a valid format value (0, 2, 4, 6, 8, 10, 12, 13 or 14) in the first two bytes.

func (Table) Encode

func (ss Table) Encode() []byte

Encode converts the cmap table into binary form.

func (Table) Get

func (ss Table) Get(key Key) (Subtable, error)

Get decodes the given cmap subtable.

func (Table) GetBest

func (ss Table) GetBest() (Subtable, error)

GetBest selects the "best" subtable from a cmap table.

func (Table) GetNoLang added in v0.3.5

func (ss Table) GetNoLang(platformID, encodingID uint16) (Subtable, error)

Jump to

Keyboard shortcuts

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