Skip to content

MsdfFontLoader

final class MsdfFontLoader
Package: dev.joid.lib.font.impl.msdf · Module: core · Source: MsdfFontLoader.java

Loads an MSDF font from the files of its faces, in the background, and completes a future with the MsdfFont.

Load each font once, when your application starts, and keep the MsdfFont in a field (Load a font family).

A TrueType or OpenType file generates its MSDF atlas on the first load and reads it from the cache folder afterwards; a .msdf file made by the msdf tool loads as it is. The future completes on the render thread, at the next frame, through runOnRenderThread of the thread bridge (Threads); join() on the render thread waits for the load there.

ReturnsSignatureSummary
CompletableFuture<MsdfFont>load(Object… faces) staticReads every face in parallel and completes with one MsdfFont that holds them all.

CompletableFuture<MsdfFont> load(Object... faces) static

Reads every face in parallel and completes with one MsdfFont that holds them all. Each argument is an IMsdfSource, or anything Asset.of accepts (a path, a File, a URL, a stream, an Asset): its first bytes pick OpenTypeMsdfSource or BinaryMsdfSource. The weight and the style of each face come from the file; wrap the file in a source and call weight(...) or italic(...) to override them.

The future completes exceptionally with IllegalArgumentException when no face is given or two faces share a weight and a style, and with IOException when a file cannot be read or generated. In dev mode, the time each face took is logged.


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