Skip to content

Commit 2ede254

Browse files
committed
Fixed asymmetrical range with scanline mode, version 1.4
1 parent c76a323 commit 2ede254

7 files changed

Lines changed: 29 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11

2+
## Version 1.4 (2026-03-05)
3+
4+
- Updated to MSDFgen 1.13
5+
- Improved BMP file output - support for BGRA (`mtsdf` mode), optimized size of grayscale files
6+
- Fixed incorrect output with asymmetrical distance range when inversion occurs due to scanline pass (`-scanline`)
7+
- Improved precision of cubic curve distance computation
8+
- Fixed a bug incorrectly adjusting convergent edge segments in shape normalization
9+
- The library now operates on bitmap section references (instead of contiguous bitmap references), which makes it possible to generate a distance field directly into a subsection of a larger bitmap or a bitmap with the opposite row ordering
10+
- Updated Shadron preview output
11+
- Fixed a bug in `FontGeometry` constructor
12+
213
## Version 1.3 (2024-06-01)
314

415
- Updated to MSDFgen 1.12

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 - 2025 Viktor Chlumsky
3+
Copyright (c) 2020 - 2026 Viktor Chlumsky
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

msdf-atlas-gen/Workload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ bool Workload::finishSequential() {
2020
}
2121

2222
bool Workload::finishParallel(int threadCount) {
23-
bool result = true;
23+
std::atomic<bool> result(true);
2424
std::atomic<int> next(0);
2525
std::function<void(int)> threadWorker = [this, &result, &next](int threadNo) {
26-
for (int i = next++; result && i < chunks; i = next++) {
26+
for (int i = next++; i < chunks && result; i = next++) {
2727
if (!workerFunction(i, threadNo))
2828
result = false;
2929
}

msdf-atlas-gen/glyph-generators.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33

44
namespace msdf_atlas {
55

6+
static float sdfZeroValue(const GlyphGeometry &glyph) {
7+
msdfgen::Range range = glyph.getBoxRange();
8+
return range.lower != range.upper ? float(range.lower/(range.lower-range.upper)) : .5f;
9+
}
10+
611
void scanlineGenerator(const msdfgen::BitmapSection<float, 1> &output, const GlyphGeometry &glyph, const GeneratorAttributes &attribs) {
712
msdfgen::rasterize(output, glyph.getShape(), glyph.getBoxScale(), glyph.getBoxTranslate(), MSDF_ATLAS_GLYPH_FILL_RULE);
813
}
914

1015
void sdfGenerator(const msdfgen::BitmapSection<float, 1> &output, const GlyphGeometry &glyph, const GeneratorAttributes &attribs) {
1116
msdfgen::generateSDF(output, glyph.getShape(), glyph.getBoxProjection(), glyph.getBoxRange(), attribs.config);
1217
if (attribs.scanlinePass)
13-
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), MSDF_ATLAS_GLYPH_FILL_RULE);
18+
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), sdfZeroValue(glyph), MSDF_ATLAS_GLYPH_FILL_RULE);
1419
}
1520

1621
void psdfGenerator(const msdfgen::BitmapSection<float, 1> &output, const GlyphGeometry &glyph, const GeneratorAttributes &attribs) {
1722
msdfgen::generatePSDF(output, glyph.getShape(), glyph.getBoxProjection(), glyph.getBoxRange(), attribs.config);
1823
if (attribs.scanlinePass)
19-
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), MSDF_ATLAS_GLYPH_FILL_RULE);
24+
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), sdfZeroValue(glyph), MSDF_ATLAS_GLYPH_FILL_RULE);
2025
}
2126

2227
void msdfGenerator(const msdfgen::BitmapSection<float, 3> &output, const GlyphGeometry &glyph, const GeneratorAttributes &attribs) {
@@ -25,7 +30,7 @@ void msdfGenerator(const msdfgen::BitmapSection<float, 3> &output, const GlyphGe
2530
config.errorCorrection.mode = msdfgen::ErrorCorrectionConfig::DISABLED;
2631
msdfgen::generateMSDF(output, glyph.getShape(), glyph.getBoxProjection(), glyph.getBoxRange(), config);
2732
if (attribs.scanlinePass) {
28-
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), MSDF_ATLAS_GLYPH_FILL_RULE);
33+
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), sdfZeroValue(glyph), MSDF_ATLAS_GLYPH_FILL_RULE);
2934
if (attribs.config.errorCorrection.mode != msdfgen::ErrorCorrectionConfig::DISABLED) {
3035
config.errorCorrection.mode = attribs.config.errorCorrection.mode;
3136
config.errorCorrection.distanceCheckMode = msdfgen::ErrorCorrectionConfig::DO_NOT_CHECK_DISTANCE;
@@ -40,7 +45,7 @@ void mtsdfGenerator(const msdfgen::BitmapSection<float, 4> &output, const GlyphG
4045
config.errorCorrection.mode = msdfgen::ErrorCorrectionConfig::DISABLED;
4146
msdfgen::generateMTSDF(output, glyph.getShape(), glyph.getBoxProjection(), glyph.getBoxRange(), config);
4247
if (attribs.scanlinePass) {
43-
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), MSDF_ATLAS_GLYPH_FILL_RULE);
48+
msdfgen::distanceSignCorrection(output, glyph.getShape(), glyph.getBoxProjection(), sdfZeroValue(glyph), MSDF_ATLAS_GLYPH_FILL_RULE);
4449
if (attribs.config.errorCorrection.mode != msdfgen::ErrorCorrectionConfig::DISABLED) {
4550
config.errorCorrection.mode = attribs.config.errorCorrection.mode;
4651
config.errorCorrection.distanceCheckMode = msdfgen::ErrorCorrectionConfig::DO_NOT_CHECK_DISTANCE;

msdf-atlas-gen/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
/*
3-
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR - standalone console program
4-
* --------------------------------------------------------------------------------
5-
* A utility by Viktor Chlumsky, (c) 2020 - 2025
6-
*/
3+
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR - standalone console program
4+
* --------------------------------------------------------------------------------
5+
* A utility by Viktor Chlumsky, (c) 2020 - 2026
6+
*/
77

88
#ifdef MSDF_ATLAS_STANDALONE
99

msdf-atlas-gen/msdf-atlas-gen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/*
55
* MULTI-CHANNEL SIGNED DISTANCE FIELD ATLAS GENERATOR
66
* ---------------------------------------------------
7-
* A utility by Viktor Chlumsky, (c) 2020 - 2025
7+
* A utility by Viktor Chlumsky, (c) 2020 - 2026
88
* Generates compact bitmap font atlases using MSDFgen
99
*/
1010

vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/master/docs/vcpkg.schema.json",
33
"name": "msdf-atlas-gen",
4-
"version": "1.3.0",
4+
"version": "1.4.0",
55
"description": "Multi-channel signed distance field atlas generator",
66
"homepage": "https://github.com/Chlumsky/msdf-atlas-gen",
77
"license": "MIT",

0 commit comments

Comments
 (0)