OpenType v0.5.1 OpenType

Provides parsers and utilities

Link to this section Summary

Functions

Returns the list of OpenType features that are enabled by default

Discover the OpenType features supported by the font

Returns a series of positioned glyphs (a tuple of {glyphs, positions})

Create an empty structure with sensible defaults

Parse the binary data that makes up a font

Open and parse a font file. Returns the parsed font structure

Link to this section Functions

Link to this function default_features()

Returns the list of OpenType features that are enabled by default.

This list is determined by the OpenType specification. Note that fonts are not required to support these features, nor are they necessarily used by all scripts (for example, the features for positional forms are typically only used by cursive scripts such as Arabic).

Link to this function discover_features(ttf)

Discover the OpenType features supported by the font.

This can be used to present optional features to a layout engine or end user.

Link to this function hasTable?(ttf, name)
Link to this function layout_text(ttf, text, features \\ nil, script \\ nil, lang \\ nil)

Returns a series of positioned glyphs (a tuple of {glyphs, positions}).

Once a font has been parsed, this function will apply OpenType features to perform substitution and positioning. If no features are specified, default_features/0 will be enabled.

This version does not apply width or height constraints, line breaking, or a bidirectional algorithm. Such layout logic is assumed to be handled by the caller.

If the script tag is not specified, it will attempt to autodetect it using OpenType.Layout.detect_script/1. If undetected or unsupported by the font it will fall back to the “DFLT” (default) script tag.

If the language tag is not specified, it will follow the spec and fall back to the default language.

Create an empty structure with sensible defaults.

This will likely be replaced in future with a proper struct.

Link to this function parse(ttf, data)

Parse the binary data that makes up a font.

Link to this function parse_file(filename)

Open and parse a font file. Returns the parsed font structure.

The current version assumes an uncompressed OpenType or TrueType font. For a font collection, it returns only the first font in the collection.