Added -coloringstrategy option, version 1.2
This commit is contained in:
parent
0e81034513
commit
a49bf0d5ea
|
|
@ -13,6 +13,7 @@ x64/
|
||||||
*.suo
|
*.suo
|
||||||
*.VC.opendb
|
*.VC.opendb
|
||||||
*.VC.db
|
*.VC.db
|
||||||
|
bin/msdf-atlas-gen
|
||||||
bin/*.lib
|
bin/*.lib
|
||||||
output.png
|
output.png
|
||||||
out/
|
out/
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
|
|
||||||
|
## Version 1.2 (2021-05-29)
|
||||||
|
|
||||||
|
- Updated to MSDFgen 1.9.
|
||||||
|
- Multiple fonts or font sizes can now be compiled into a single atlas.
|
||||||
|
- Added `-yorigin` option to choose if Y-coordinates increase from bottom to top or from top to bottom.
|
||||||
|
- Added `-coloringstrategy` option to select MSDF edge coloring heuristic.
|
||||||
|
- Shadron preview now properly loads floating-point image outputs in full range mode.
|
||||||
|
|
||||||
## Version 1.1 (2020-10-18)
|
## Version 1.1 (2020-10-18)
|
||||||
|
|
||||||
- Updated to MSDFgen 1.8.
|
- Updated to MSDFgen 1.8.
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,8 @@ Any non-empty subset of the following may be specified:
|
||||||
### Distance field generator settings
|
### Distance field generator settings
|
||||||
|
|
||||||
- `-angle <angle>` – sets the minimum angle between adjacent edges to be considered a corner. Append D for degrees (`msdf` / `mtsdf` only)
|
- `-angle <angle>` – sets the minimum angle between adjacent edges to be considered a corner. Append D for degrees (`msdf` / `mtsdf` only)
|
||||||
- `-errorcorrection <threshold>` – sets the threshold used to detect and correct potential artifacts. 0 disables error correction (`msdf` / `mtsdf` only)
|
- `-coloringstrategy <simple / inktrap / distance>` – selects the edge coloring heuristic (`msdf` / `mtsdf` only)
|
||||||
|
- `-errorcorrection <mode>` – selects the error correction algorithm. Use `help` as mode for more information (`msdf` / `mtsdf` only)
|
||||||
- `-miterlimit <value>` – sets the miter limit that limits the extension of each glyph's bounding box due to very sharp corners (`psdf` / `msdf` / `mtsdf` only)
|
- `-miterlimit <value>` – sets the miter limit that limits the extension of each glyph's bounding box due to very sharp corners (`psdf` / `msdf` / `mtsdf` only)
|
||||||
- `-overlap` – switches to distance field generator with support for overlapping contours
|
- `-overlap` – switches to distance field generator with support for overlapping contours
|
||||||
- `-nopreprocess` – disables path preprocessing which resolves self-intersections and overlapping contours
|
- `-nopreprocess` – disables path preprocessing which resolves self-intersections and overlapping contours
|
||||||
|
|
@ -116,6 +117,8 @@ Any non-empty subset of the following may be specified:
|
||||||
- `-seed <N>` – sets the initial seed for the edge coloring heuristic
|
- `-seed <N>` – sets the initial seed for the edge coloring heuristic
|
||||||
- `-threads <N>` – sets the number of threads for the parallel computation (0 = auto)
|
- `-threads <N>` – sets the number of threads for the parallel computation (0 = auto)
|
||||||
|
|
||||||
|
Use `-help` for an exhaustive list of options.
|
||||||
|
|
||||||
## Character set specification syntax
|
## Character set specification syntax
|
||||||
|
|
||||||
The character set file is a text file with UTF-8 or ASCII encoding.
|
The character set file is a text file with UTF-8 or ASCII encoding.
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -47,8 +47,8 @@ bool GlyphGeometry::load(msdfgen::FontHandle *font, double geometryScale, unicod
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlyphGeometry::edgeColoring(double angleThreshold, unsigned long long seed) {
|
void GlyphGeometry::edgeColoring(void (*fn)(msdfgen::Shape &, double, unsigned long long), double angleThreshold, unsigned long long seed) {
|
||||||
msdfgen::edgeColoringInkTrap(shape, angleThreshold, seed);
|
fn(shape, angleThreshold, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlyphGeometry::wrapBox(double scale, double range, double miterLimit) {
|
void GlyphGeometry::wrapBox(double scale, double range, double miterLimit) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public:
|
||||||
bool load(msdfgen::FontHandle *font, double geometryScale, msdfgen::GlyphIndex index, bool preprocessGeometry = true);
|
bool load(msdfgen::FontHandle *font, double geometryScale, msdfgen::GlyphIndex index, bool preprocessGeometry = true);
|
||||||
bool load(msdfgen::FontHandle *font, double geometryScale, unicode_t codepoint, bool preprocessGeometry = true);
|
bool load(msdfgen::FontHandle *font, double geometryScale, unicode_t codepoint, bool preprocessGeometry = true);
|
||||||
/// Applies edge coloring to glyph shape
|
/// Applies edge coloring to glyph shape
|
||||||
void edgeColoring(double angleThreshold, unsigned long long seed);
|
void edgeColoring(void (*fn)(msdfgen::Shape &, double, unsigned long long), double angleThreshold, unsigned long long seed);
|
||||||
/// Computes the dimensions of the glyph's box as well as the transformation for the generator function
|
/// Computes the dimensions of the glyph's box as well as the transformation for the generator function
|
||||||
void wrapBox(double scale, double range, double miterLimit);
|
void wrapBox(double scale, double range, double miterLimit);
|
||||||
/// Sets the glyph's box's position in the atlas
|
/// Sets the glyph's box's position in the atlas
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR v1.1 (2020-10-18) - standalone console program
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR v1.2 (2021-05-29) - standalone console program
|
||||||
* --------------------------------------------------------------------------------------------------
|
* --------------------------------------------------------------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2020
|
* A utility by Viktor Chlumsky, (c) 2020 - 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -26,7 +26,8 @@ using namespace msdf_atlas;
|
||||||
#define DEFAULT_PIXEL_RANGE 2.0
|
#define DEFAULT_PIXEL_RANGE 2.0
|
||||||
#define SDF_ERROR_ESTIMATE_PRECISION 19
|
#define SDF_ERROR_ESTIMATE_PRECISION 19
|
||||||
#define GLYPH_FILL_RULE msdfgen::FILL_NONZERO
|
#define GLYPH_FILL_RULE msdfgen::FILL_NONZERO
|
||||||
#define MCG_MULTIPLIER 6364136223846793005ull
|
#define LCG_MULTIPLIER 6364136223846793005ull
|
||||||
|
#define LCG_INCREMENT 1442695040888963407ull
|
||||||
|
|
||||||
#ifdef MSDFGEN_USE_SKIA
|
#ifdef MSDFGEN_USE_SKIA
|
||||||
#define TITLE_SUFFIX " & Skia"
|
#define TITLE_SUFFIX " & Skia"
|
||||||
|
|
@ -94,6 +95,8 @@ GLYPH CONFIGURATION
|
||||||
DISTANCE FIELD GENERATOR SETTINGS
|
DISTANCE FIELD GENERATOR SETTINGS
|
||||||
-angle <angle>
|
-angle <angle>
|
||||||
Specifies the minimum angle between adjacent edges to be considered a corner. Append D for degrees. (msdf / mtsdf only)
|
Specifies the minimum angle between adjacent edges to be considered a corner. Append D for degrees. (msdf / mtsdf only)
|
||||||
|
-coloringstrategy <simple / inktrap / distance>
|
||||||
|
Selects the strategy of the edge coloring heuristic.
|
||||||
-errorcorrection <mode>
|
-errorcorrection <mode>
|
||||||
Changes the MSDF/MTSDF error correction mode. Use -errorcorrection help for a list of valid modes.
|
Changes the MSDF/MTSDF error correction mode. Use -errorcorrection help for a list of valid modes.
|
||||||
-errordeviationratio <ratio>
|
-errordeviationratio <ratio>
|
||||||
|
|
@ -201,6 +204,8 @@ struct Configuration {
|
||||||
double pxRange;
|
double pxRange;
|
||||||
double angleThreshold;
|
double angleThreshold;
|
||||||
double miterLimit;
|
double miterLimit;
|
||||||
|
void (*edgeColoring)(msdfgen::Shape &, double, unsigned long long);
|
||||||
|
bool expensiveColoring;
|
||||||
unsigned long long coloringSeed;
|
unsigned long long coloringSeed;
|
||||||
GeneratorAttributes generatorAttributes;
|
GeneratorAttributes generatorAttributes;
|
||||||
bool preprocessGeometry;
|
bool preprocessGeometry;
|
||||||
|
|
@ -263,6 +268,7 @@ int main(int argc, const char * const *argv) {
|
||||||
config.imageType = ImageType::MSDF;
|
config.imageType = ImageType::MSDF;
|
||||||
config.imageFormat = ImageFormat::UNSPECIFIED;
|
config.imageFormat = ImageFormat::UNSPECIFIED;
|
||||||
config.yDirection = YDirection::BOTTOM_UP;
|
config.yDirection = YDirection::BOTTOM_UP;
|
||||||
|
config.edgeColoring = msdfgen::edgeColoringInkTrap;
|
||||||
config.kerning = true;
|
config.kerning = true;
|
||||||
const char *imageFormatName = nullptr;
|
const char *imageFormatName = nullptr;
|
||||||
int fixedWidth = -1, fixedHeight = -1;
|
int fixedWidth = -1, fixedHeight = -1;
|
||||||
|
|
@ -547,6 +553,15 @@ int main(int argc, const char * const *argv) {
|
||||||
argPos += 2;
|
argPos += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
ARG_CASE("-coloringstrategy", 1) {
|
||||||
|
if (!strcmp(argv[argPos+1], "simple")) config.edgeColoring = msdfgen::edgeColoringSimple, config.expensiveColoring = false;
|
||||||
|
else if (!strcmp(argv[argPos+1], "inktrap")) config.edgeColoring = msdfgen::edgeColoringInkTrap, config.expensiveColoring = false;
|
||||||
|
else if (!strcmp(argv[argPos+1], "distance")) config.edgeColoring = msdfgen::edgeColoringByDistance, config.expensiveColoring = true;
|
||||||
|
else
|
||||||
|
puts("Unknown coloring strategy specified.");
|
||||||
|
argPos += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ARG_CASE("-miterlimit", 1) {
|
ARG_CASE("-miterlimit", 1) {
|
||||||
double m;
|
double m;
|
||||||
if (!(parseDouble(m, argv[++argPos]) && m >= 0))
|
if (!(parseDouble(m, argv[++argPos]) && m >= 0))
|
||||||
|
|
@ -891,10 +906,18 @@ int main(int argc, const char * const *argv) {
|
||||||
|
|
||||||
// Edge coloring
|
// Edge coloring
|
||||||
if (config.imageType == ImageType::MSDF || config.imageType == ImageType::MTSDF) {
|
if (config.imageType == ImageType::MSDF || config.imageType == ImageType::MTSDF) {
|
||||||
unsigned long long glyphSeed = config.coloringSeed;
|
if (config.expensiveColoring) {
|
||||||
for (GlyphGeometry &glyph : glyphs) {
|
Workload([&glyphs, &config](int i, int threadNo) -> bool {
|
||||||
glyphSeed *= MCG_MULTIPLIER;
|
unsigned long long glyphSeed = (LCG_MULTIPLIER*(config.coloringSeed^i)+LCG_INCREMENT)*!!config.coloringSeed;
|
||||||
glyph.edgeColoring(config.angleThreshold, glyphSeed);
|
glyphs[i].edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed);
|
||||||
|
return true;
|
||||||
|
}, glyphs.size()).finish(config.threadCount);
|
||||||
|
} else {
|
||||||
|
unsigned long long glyphSeed = config.coloringSeed;
|
||||||
|
for (GlyphGeometry &glyph : glyphs) {
|
||||||
|
glyphSeed *= LCG_MULTIPLIER;
|
||||||
|
glyph.edgeColoring(config.edgeColoring, config.angleThreshold, glyphSeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR v1.1 (2020-10-18)
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR v1.2 (2021-05-29)
|
||||||
* ---------------------------------------------------------------------
|
* ---------------------------------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2020
|
* A utility by Viktor Chlumsky, (c) 2020 - 2021
|
||||||
*
|
*
|
||||||
* Generates compact bitmap font atlases using MSDFGEN.
|
* Generates compact bitmap font atlases using MSDFGEN.
|
||||||
*
|
*
|
||||||
|
|
@ -39,4 +39,4 @@
|
||||||
#include "json-export.h"
|
#include "json-export.h"
|
||||||
#include "shadron-preview-generator.h"
|
#include "shadron-preview-generator.h"
|
||||||
|
|
||||||
#define MSDF_ATLAS_VERSION "1.1"
|
#define MSDF_ATLAS_VERSION "1.2"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue