Skip to content

Commit

Permalink
Charset parsing from argument string
Browse files Browse the repository at this point in the history
  • Loading branch information
Chlumsky committed Jun 1, 2024
1 parent d120bb3 commit c27de59
Show file tree
Hide file tree
Showing 5 changed files with 261 additions and 178 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@

## Version 1.3 (forthcoming)
## Version 1.3 (2024-06-01)

- Updated to MSDFgen 1.10
- Updated to MSDFgen 1.12
- Switched to vcpkg as the primary dependency management system
- Removed Visual Studio solution and Makefile - now has to be generated by CMake
- CMake configuration overhaul, added installation configuration
- Switched to libpng as the primary PNG file encoder
- Added uniform grid mode (`-uniformgrid`) where atlas is laid out in a rectangular grid
- Added options to add extra padding around glyphs (`-empadding`, `-pxpadding` and similar)
- Added the possibility to specify asymmetrical distance range (`-aemrange`, `-apxrange`)
- Added `-pxalign` option which governs glyph alignment with the pixel grid
- Added `-allglyphs` option as alternative to explicit charset / glyphset
- Added `-chars` and `-glyphs` options to specify charset / glyphset directly on command line
- Added `-varfont` option to configure variables of variable fonts
- Added `-version` option to print program version
- Arguments with double dash (e.g. `--font`) now also accepted
- Minor fix to positioning for `-type hardmask`
- Errors are now reported to `stderr`
- TinyXML 2 no longer required as a dependency

### Version 1.2.2 (2021-09-06)

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is a utility for generating compact font atlases using [MSDFgen](https://gi

The atlas generator loads a subset of glyphs from a TTF or OTF font file, generates a distance field for each of them, and tightly packs them into an atlas bitmap (example below). The finished atlas and/or its layout metadata can be exported as an [Artery Font](https://github.com/Chlumsky/artery-font-format) file, a plain image file, a CSV sheet or a structured JSON file.

![Atlas example](https://user-images.githubusercontent.com/18639794/76163889-811f2e80-614a-11ea-9b28-1eed54dbb899.png)
![Atlas example](https://github.com/Chlumsky/msdf-atlas-gen/assets/18639794/ee8bfc77-7d36-4cbb-82df-aa8a02424b4a)

A font atlas is typically stored in texture memory and used to draw text in real-time rendering contexts such as video games.

Expand Down Expand Up @@ -47,13 +47,16 @@ Use the following command line arguments for the standalone version of the atlas

- `-font <fontfile.ttf/otf>` (required) &ndash; sets the input font file.
- Alternatively, use `-varfont <fontfile.ttf/otf?var0=value0&var1=value1>` to configure a variable font.
- `-charset <charset.txt>` &ndash; sets the character set. The ASCII charset will be used if not specified. See [the syntax specification](#character-set-specification-syntax) of `charset.txt`.
- `-charset <charset.txt>` &ndash; sets the character set. See [the syntax specification](#character-set-specification-syntax) of `charset.txt`.
- `-glyphset <glyphset.txt>` &ndash; sets the set of input glyphs using their indices within the font file. See [the syntax specification](#glyph-set-specification).
- `-chars` / `-glyphs <set string>` sets the above character / glyph set in-line. See [the syntax specification](#character-set-specification-syntax).
- `-allglyphs` &ndash; sets the set of input glyphs to all glyphs present within the font file.
- `-fontscale <scale>` &ndash; applies a scaling transformation to the font's glyphs. Mainly to be used to generate multiple sizes in a single atlas, otherwise use [`-size`](#glyph-configuration).
- `-fontname <name>` &ndash; sets a name for the font that will be stored in certain output files as metadata.
- `-and` &ndash; separates multiple inputs to be combined into a single atlas.

If no character set or glyph set is provided, and `-allglyphs` is not used, the ASCII charset will be used.

### Bitmap atlas type

`-type <type>` &ndash; see [Atlas types](#atlas-types)
Expand Down
4 changes: 3 additions & 1 deletion msdf-atlas-gen/Charset.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class Charset {
std::set<unicode_t>::const_iterator begin() const;
std::set<unicode_t>::const_iterator end() const;

/// Load character set from a text file with the correct syntax
/// Load character set from a text file with compliant syntax
bool load(const char *filename, bool disableCharLiterals = false);
/// Parse character set from a string with compliant syntax
bool parse(const char *str, size_t strLength, bool disableCharLiterals = false);

private:
std::set<unicode_t> codepoints;
Expand Down
Loading

0 comments on commit c27de59

Please sign in to comment.