FormatParser.Font
(format_parser v2.14.0)
Copy Markdown
A Font struct and functions.
The Font struct contains the fields format and nature.
Supported Formats
| Format | Extension | Description |
|---|---|---|
:ttf | .ttf | TrueType Font |
:otf | .otf | OpenType Font |
:fon | .fon | Windows bitmap font |
:woff | .woff | Web Open Font Format |
:woff2 | .woff2 | Web Open Font Format 2 |
Examples
iex> {:ok, file} = File.read("priv/test.ttf")
iex> FormatParser.parse(file)
%FormatParser.Font{format: :ttf, nature: :font}
Summary
Functions
Parses a font file or result.
Types
@type t() :: %FormatParser.Font{format: atom() | nil, nature: :font}
A struct representing a parsed font file.
Fields
:format- The font format as an atom (e.g.,:ttf,:otf,:woff), ornilif unknown:nature- Always:fontfor font files
Functions
Parses a font file or result.
- If given a tuple
{:error, file}wherefileis a binary, attempts to parse the font from the file. - If given a binary
file, attempts to parse the font from the file. - For any other input, returns the input as-is (passthrough for parser chain).
Examples
iex> {:ok, file} = File.read("priv/test.ttf")
iex> FormatParser.Font.parse(file)
%FormatParser.Font{format: :ttf, nature: :font}
iex> FormatParser.Font.parse(%FormatParser.Image{})
%FormatParser.Image{}