MsdfGenerator
final class MsdfGenerator
Package: dev.joid.tool.msdf · Module: tool-msdf · Source: MsdfGenerator.java
Generates the MSDF atlas of a font file, as a font.msdf file that JOID loads without generating it again.
Description
Section titled “Description”JOID calls it at the first load of a font file and caches the result; run it from the command line to ship the atlases ready.
Learn more
Section titled “Learn more”Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | main(String[] arguments) static | Reads the options --font (required), --output, --charset, --range, --width, --height and --size, then writes font.msdf into the output folder and prints a summary that starts with [JOID]. |
String | generate(byte[] data, File target, int[] codepoints, int width, int height, double range, double requested) static | Writes the atlas of the font bytes into the file, with the glyphs of those code points that the font draws, at that atlas size in pixels and that distance range in pixels, and returns a one-line summary. |
int[] | codepoints(String charset) static | Returns the code points of a charset: the path of a file that holds one, or ranges and values such as [32, 126], 8364. |
Constants and fields
Section titled “Constants and fields”| Type | Name | Value | Summary |
|---|---|---|---|
int | REVISION | 1 | The revision of the generator, part of the cache key of the atlases that JOID generates: a new revision generates them again. |
int | WIDTH | 2048 | The default width of the atlas, in pixels. |
int | HEIGHT | 2048 | The default height of the atlas, in pixels. |
double | RANGE | 24D | The default distance range, in pixels of the atlas. |
String | CHARSET | "[32, 563]" | The default charset, the code points from 32 to 563: Basic Latin, Latin-1 Supplement, Latin Extended-A and most of Latin Extended-B. |
Method details
Section titled “Method details”void main(String[] arguments) static
Throws:
IllegalArgumentException: Usage: msdf —font <file.ttf|file.otf> [—output <directory>] [—charset <file|ranges>] [—range <pixels>] [—width <pixels>] [—height <pixels>] [—size <pixels>]
Reads the options --font (required), --output, --charset, --range, --width, --height and --size, then writes font.msdf into the output folder and prints a summary that starts with [JOID].
Throws an IllegalArgumentException with the usage for a missing font or an unknown option, and when an option has no value.
generate
Section titled “generate”String generate(byte[] data, File target, int[] codepoints, int width, int height, double range, double requested) static
Writes the atlas of the font bytes into the file, with the glyphs of those code points that the font draws, at that atlas size in pixels and that distance range in pixels, and returns a one-line summary.
A requested glyph size of 0D or less takes the largest size that fits; a larger one throws an IllegalStateException when the glyphs do not fit at it.
codepoints
Section titled “codepoints”int[] codepoints(String charset) static
Throws:
IllegalArgumentException: The charset … is neither a file nor codepoints like [32, 126], 8364: check the path or separate the values with commas
Returns the code points of a charset: the path of a file that holds one, or ranges and values such as [32, 126], 8364.
Throws an IllegalArgumentException when the text is neither.
Constant and field details
Section titled “Constant and field details”REVISION
Section titled “REVISION”int REVISION
The revision of the generator, part of the cache key of the atlases that JOID generates: a new revision generates them again.
int WIDTH
The default width of the atlas, in pixels.
HEIGHT
Section titled “HEIGHT”int HEIGHT
The default height of the atlas, in pixels.
double RANGE
The default distance range, in pixels of the atlas.
CHARSET
Section titled “CHARSET”String CHARSET
The default charset, the code points from 32 to 563: Basic Latin, Latin-1 Supplement, Latin Extended-A and most of Latin Extended-B.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
