Skip to content

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.

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.

ReturnsSignatureSummary
voidmain(String[] arguments) staticReads 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].
Stringgenerate(byte[] data, File target, int[] codepoints, int width, int height, double range, double requested) staticWrites 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) staticReturns the code points of a charset: the path of a file that holds one, or ranges and values such as [32, 126], 8364.
TypeNameValueSummary
intREVISION1The revision of the generator, part of the cache key of the atlases that JOID generates: a new revision generates them again.
intWIDTH2048The default width of the atlas, in pixels.
intHEIGHT2048The default height of the atlas, in pixels.
doubleRANGE24DThe default distance range, in pixels of the atlas.
StringCHARSET"[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.

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.

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.

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.

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.

int HEIGHT

The default height of the atlas, in pixels.

double RANGE

The default distance range, in pixels of the atlas.

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

Report a problem with this page