Font Asset Generator based on OpenLL Specifications
What is openll-asset-generator? (llassetgen)
The openll-asset-generator, or in short llassetgen, is a cross-platform C++ generator for font assets. Font assets are needed for rendering fonts in various realtime-applications. With llassetgen, the user can adapt the parameters via CLI, GUI or can directly use the core lib. The GUI offers a pre-render using the generated font asset.
On the master-branch you will find everything tested using CI (Appveyor, Travis). On the develop-branch you find more features and fixes, but they are not thoroughly tested due to dependency issues on the CI servers.
What is a font asset?
A font asset consists of the data needed to render a font.
Main Workflow
| Service | System | Compiler | Status |
|---|---|---|---|
| Travis-CI | Ubuntu 14.04, macOS | GCC 4.8, Clang 3.9 AppleClang 8.1 | |
| AppVeyor | Windows | MSVC 2015 MSVC 2017 |
The core library and its applications can be installed either by downloading an installer, e.g., the latest x64 installer for Microsoft Visual Studio 2017, or downloading and extracting one of the precompiled archives, e.g. runtime, examples, and dev. Alternatively, download the source code and commence building from source. See latest release.
We plan to provide the Font Asset Generator using PPAs. Until then, download the source code and commence building from source.
We plan to provide the Font Asset Generator via homebrew package manager. Until then, download the source code and commence building from source.
For an alternative setup that only requires bash and Docker, see below (CLI only).
Necessary for the core library (llassetgen) and the CLI application (llassetgen-cmd)
Additionally necessary to build the rendering application (llassetgen-rendering):
For compilation, a C++11 compliant compiler, e.g., GCC 4.8, Clang 3.9, AppleClang 8.1, MSVC 2015, is required.
First, download the source code as archive. or via git:
> git clone https://github.com/cginternals/openll-asset-generator.git
> cd openll-asset-generator
Then, depending on the version of globjects you want to build, choose the appropriate tag or branch, e.g., for the 1.0 release:
> git fetch --tags
> git checkout v1.0-master
The actual compilation can be done using CMake and your favorite compiler and IDE.
For a simplified cross-platform build and usage setup for the CLI, a Dockerfile and two convenience scripts are provided:
./build_docker.sh
./run_docker.sh <parameters>
The parameters are the same as described in the section below. The results are saved in the subfolder output.
To see how to use our core lib, you can explore the following two applications that come with llassetgen: llassetgen-cmd and llassetgen-rendering. Further below you find details on the used algorithms and parameters.
The CLI application llassetgen-cmd provides two subcommands:
distfield applies a distance transform to an input imageatlas generates a font atlas, optionally applying a distance transform and creating a font file in the FNT format.The following examples introduce the basic parameters of distfield and atlas. To see a list of all the options, run llassetgen-cmd distfield --help or llassetgen-cmd atlas --help.
Take the existing file image.png and apply a distance transform, then write the result to distancefield.png:
llassetgen-cmd distfield image.png distancefield.png
Create an atlas for the Arial font containing only the glyphs 'a', 'b' and 'c', and write it to atlas.png:
llassetgen-cmd atlas --fontname Arial --glyph abc atlas.png
Create an atlas containing all printable ASCII glyphs, with a font size of 256 pixels, then use the Parabola Envelope algorithm to apply a distance transform. Write the resulting distance field to atlas.png and generate an FNT file, which is written to atlas.fnt:
llassetgen-cmd atlas --ascii --fontsize 256 --distfield parabola --fontname Arial atlas.png --fnt
Since a distance field creates a "glow" around every glyph, add 20 pixels of padding around each glyph in the atlas to create the necessary space. To improve the final rendering quality of the font, apply a 4x downsampling to every glyph:
llassetgen-cmd atlas --padding 20 --downsampling 4 --ascii --distfield parabola --fontname Arial atlas.png
Additionally to the CLI, you can use the GUI-application llassetgen-rendering. It offers a preview of the rendering using the calculated distance field. Using the GUI, you can change all parameters and see their direct impact on the final image.
llassetgen-rendering uses the fragment-shader as in OpenLL for Super Sampling. Rendering parameters are:
Our implemented packing algorithms are based on the publication by Jukka Jylänki: A thousand ways to pack the bin -- a practical approach to two-dimensional rectangle bin packing (2010), except that for now, we don't use multiple bins (i.e. textures).
The Shelf Bin Packing (O(n log(n))) performs faster, but there are cases where Max Rects Packing (O(n^5)) gives better results.
Parameters: All glyph sizes, downsampled.
llassetgen offers two algorithms for the distance field creation:
The Algorithm "Dead-Reckoning" is based on: GREVERA, George J. The “dead reckoning” signed distance transform. Computer Vision and Image Understanding, 2004, 95. Jg., Nr. 3, S. 317-333.. There are 10 accesses per pixel over 4 passes.
The Algorithm called "Parabola Envelope" is based on: FELZENSZWALB, Pedro; HUTTENLOCHER, Daniel. Distance transforms of sampled functions. Cornell University, 2004.. There are 4 accesses per pixel over 2 passes, thus this algorithm is considerably faster than the "Dead-Reckoning" while not resulting in a lower quality distance field.
Content type
Image
Digest
Size
400.8 MB
Last updated
almost 8 years ago
docker pull cginternals/openll-asset-generator:develop