-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add msdf-atlas-gen as regular folder
- Loading branch information
Showing
62 changed files
with
6,501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/build/ | ||
/Debug/ | ||
/Release/ | ||
/Debug Library/ | ||
/Release Library/ | ||
/x86/ | ||
/x64/ | ||
.vs/ | ||
.vscode/ | ||
.DS_Store | ||
*.exe | ||
*.zip | ||
*.user | ||
*.sdf | ||
*.pdb | ||
*.ipdb | ||
*.iobj | ||
*.suo | ||
*.VC.opendb | ||
*.VC.db | ||
/bin/*.lib | ||
/bin/msdf-atlas-gen | ||
output.png | ||
CMakeUserPresets.json | ||
out/ | ||
/cmake-gen.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
## Version 1.3 (2024-06-01) | ||
|
||
- 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) | ||
|
||
- CMake support | ||
- Conan package manager support | ||
|
||
### Version 1.2.1 (2021-07-09) | ||
|
||
- Updated to MSDFgen 1.9.1 | ||
|
||
## 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) | ||
|
||
- Updated to MSDFgen 1.8. | ||
- Glyph geometry is now preprocessed by Skia to resolve irregularities which were previously unsupported and caused artifacts. | ||
- The scanline pass and overlapping contour mode is made obsolete by this step and has been disabled by default. The preprocess step can be disabled by the new `-nopreprocess` switch and the former enabled by `-scanline` and `-overlap` respectively. | ||
- The project can be built without the Skia library, forgoing the geometry preprocessing feature. This is controlled by the macro definition `MSDFGEN_USE_SKIA`. | ||
- Glyphs can now also be loaded by glyph index rather than Unicode values. In the standalone version, a set of glyphs can be passed by `-glyphset` in place of `-charset`. | ||
- Glyphs not present in the font should now be correctly skipped instead of producing a placeholder symbol. | ||
- Added `-threads` argument to set the number of concurrent threads used during distance field generation. | ||
|
||
### Version 1.0.1 (2020-03-09) | ||
|
||
- Updated to MSDFgen 1.7.1. | ||
|
||
## Version 1.0 (2020-03-08) | ||
|
||
- Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 - 2024 Viktor Chlumsky | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
local dep = Solution.Util.CreateDepTable("msdf-atlas-gen", { "msdfgen" }) | ||
|
||
Solution.Util.CreateStaticLib(dep.Name, Solution.Projects.Current.BinDir, dep.Dependencies, function() | ||
Solution.Util.SetLanguage("C++") | ||
Solution.Util.SetCppDialect(20) | ||
|
||
local srcDir = dep.Path .. "/msdf-atlas-gen" | ||
|
||
local defines = { "_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS", "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS" } | ||
local links = {} | ||
local files = | ||
{ | ||
srcDir .. "/AtlasGenerator.h", | ||
srcDir .. "/AtlasStorage.h", | ||
srcDir .. "/BitmapAtlasStorage.h", | ||
srcDir .. "/BitmapAtlasStorage.hpp", | ||
srcDir .. "/bitmap-blit.cpp", | ||
srcDir .. "/bitmap-blit.h", | ||
srcDir .. "/Charset.cpp", | ||
srcDir .. "/Charset.h", | ||
srcDir .. "/charset-parser.cpp", | ||
srcDir .. "/csv-export.cpp", | ||
srcDir .. "/csv-export.h", | ||
srcDir .. "/DynamicAtlas.h", | ||
srcDir .. "/DynamicAtlas.hpp", | ||
srcDir .. "/FontGeometry.cpp", | ||
srcDir .. "/FontGeometry.h", | ||
srcDir .. "/GlyphBox.h", | ||
srcDir .. "/glyph-generators.cpp", | ||
srcDir .. "/glyph-generators.h", | ||
srcDir .. "/GlyphGeometry.cpp", | ||
srcDir .. "/GlyphGeometry.h", | ||
srcDir .. "/GridAtlasPacker.cpp", | ||
srcDir .. "/GridAtlasPacker.h", | ||
srcDir .. "/image-encode.cpp", | ||
srcDir .. "/image-encode.h", | ||
srcDir .. "/image-save.h", | ||
srcDir .. "/image-save.hpp", | ||
srcDir .. "/ImmediateAtlasGenerator.h", | ||
srcDir .. "/ImmediateAtlasGenerator.hpp", | ||
srcDir .. "/json-export.cpp", | ||
srcDir .. "/json-export.h", | ||
srcDir .. "/msdf-atlas-gen.h", | ||
srcDir .. "/Padding.cpp", | ||
srcDir .. "/Padding.h", | ||
srcDir .. "/Rectangle.h", | ||
srcDir .. "/RectanglePacker.cpp", | ||
srcDir .. "/RectanglePacker.h", | ||
srcDir .. "/rectangle-packing.h", | ||
srcDir .. "/rectangle-packing.hpp", | ||
srcDir .. "/Remap.h", | ||
srcDir .. "/shadron-preview-generator.cpp", | ||
srcDir .. "/shadron-preview-generator.h", | ||
srcDir .. "/size-selectors.cpp", | ||
srcDir .. "/size-selectors.h", | ||
srcDir .. "/TightAtlasPacker.cpp", | ||
srcDir .. "/TightAtlasPacker.h", | ||
srcDir .. "/types.h", | ||
srcDir .. "/utf8.cpp", | ||
srcDir .. "/utf8.h", | ||
srcDir .. "/Workload.cpp", | ||
srcDir .. "/Workload.h", | ||
} | ||
|
||
warnings "Off" | ||
|
||
Solution.Util.SetDefines(defines) | ||
Solution.Util.SetLinks(links) | ||
Solution.Util.SetFiles(files) | ||
Solution.Util.SetIncludes(dep.Path) | ||
end) | ||
|
||
Solution.Util.CreateDep(dep.NameLow, dep.Dependencies, function() | ||
Solution.Util.SetIncludes(dep.Path) | ||
Solution.Util.SetLinks({ dep.Name }) | ||
end) |
Binary file not shown.
42 changes: 42 additions & 0 deletions
42
Dependencies/msdf-atlas-gen/msdf-atlas-gen/AtlasGenerator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#pragma once | ||
|
||
#include <msdfgen.h> | ||
#include "Remap.h" | ||
#include "GlyphGeometry.h" | ||
|
||
namespace msdf_atlas { | ||
|
||
namespace { | ||
|
||
/** Prototype of an atlas generator class. | ||
* An atlas generator maintains the atlas bitmap (AtlasStorage) and its layout and facilitates | ||
* generation of bitmap representation of glyphs. The layout of the atlas is given by the caller. | ||
*/ | ||
class AtlasGenerator { | ||
|
||
public: | ||
AtlasGenerator(); | ||
AtlasGenerator(int width, int height); | ||
/// Generates bitmap representation for the supplied array of glyphs | ||
void generate(const GlyphGeometry *glyphs, int count); | ||
/// Resizes the atlas and rearranges the generated pixels according to the remapping array | ||
void rearrange(int width, int height, const Remap *remapping, int count); | ||
/// Resizes the atlas and keeps the generated pixels in place | ||
void resize(int width, int height); | ||
|
||
}; | ||
|
||
} | ||
|
||
/// Configuration of signed distance field generator | ||
struct GeneratorAttributes { | ||
msdfgen::MSDFGeneratorConfig config; | ||
bool scanlinePass = false; | ||
}; | ||
|
||
/// A function that generates the bitmap for a single glyph | ||
template <typename T, int N> | ||
using GeneratorFunction = void (*)(const msdfgen::BitmapRef<T, N> &, const GlyphGeometry &, const GeneratorAttributes &); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
#pragma once | ||
|
||
#include <msdfgen.h> | ||
#include "Remap.h" | ||
|
||
namespace msdf_atlas { | ||
|
||
namespace { | ||
|
||
/** Prototype of an atlas storage class. | ||
* An atlas storage physically holds the pixels of the atlas | ||
* and allows to read and write subsections represented as bitmaps. | ||
* Can be implemented using a simple bitmap (BitmapAtlasStorage), | ||
* as texture memory, or any other way. | ||
*/ | ||
class AtlasStorage { | ||
|
||
public: | ||
AtlasStorage(); | ||
AtlasStorage(int width, int height); | ||
/// Creates a copy with different dimensions | ||
AtlasStorage(const AtlasStorage &orig, int width, int height); | ||
/// Creates a copy with different dimensions and rearranges the pixels according to the remapping array | ||
AtlasStorage(const AtlasStorage &orig, int width, int height, const Remap *remapping, int count); | ||
/// Stores a subsection at x, y into the atlas storage. May be implemented for only some T, N | ||
template <typename T, int N> | ||
void put(int x, int y, const msdfgen::BitmapConstRef<T, N> &subBitmap); | ||
/// Retrieves a subsection at x, y from the atlas storage. May be implemented for only some T, N | ||
template <typename T, int N> | ||
void get(int x, int y, const msdfgen::BitmapRef<T, N> &subBitmap) const; | ||
|
||
}; | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
Dependencies/msdf-atlas-gen/msdf-atlas-gen/BitmapAtlasStorage.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
#pragma once | ||
|
||
#include "AtlasStorage.h" | ||
|
||
namespace msdf_atlas { | ||
|
||
/// An implementation of AtlasStorage represented by a bitmap in memory (msdfgen::Bitmap) | ||
template <typename T, int N> | ||
class BitmapAtlasStorage { | ||
|
||
public: | ||
BitmapAtlasStorage(); | ||
BitmapAtlasStorage(int width, int height); | ||
explicit BitmapAtlasStorage(const msdfgen::BitmapConstRef<T, N> &bitmap); | ||
explicit BitmapAtlasStorage(msdfgen::Bitmap<T, N> &&bitmap); | ||
BitmapAtlasStorage(const BitmapAtlasStorage<T, N> &orig, int width, int height); | ||
BitmapAtlasStorage(const BitmapAtlasStorage<T, N> &orig, int width, int height, const Remap *remapping, int count); | ||
operator msdfgen::BitmapConstRef<T, N>() const; | ||
operator msdfgen::BitmapRef<T, N>(); | ||
operator msdfgen::Bitmap<T, N>() &&; | ||
template <typename S> | ||
void put(int x, int y, const msdfgen::BitmapConstRef<S, N> &subBitmap); | ||
void get(int x, int y, const msdfgen::BitmapRef<T, N> &subBitmap) const; | ||
|
||
private: | ||
msdfgen::Bitmap<T, N> bitmap; | ||
|
||
}; | ||
|
||
} | ||
|
||
#include "BitmapAtlasStorage.hpp" |
65 changes: 65 additions & 0 deletions
65
Dependencies/msdf-atlas-gen/msdf-atlas-gen/BitmapAtlasStorage.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
#include "BitmapAtlasStorage.h" | ||
|
||
#include <cstring> | ||
#include <algorithm> | ||
#include "bitmap-blit.h" | ||
|
||
namespace msdf_atlas { | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage() { } | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage(int width, int height) : bitmap(width, height) { | ||
memset((T *) bitmap, 0, sizeof(T)*N*width*height); | ||
} | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage(const msdfgen::BitmapConstRef<T, N> &bitmap) : bitmap(bitmap) { } | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage(msdfgen::Bitmap<T, N> &&bitmap) : bitmap((msdfgen::Bitmap<T, N> &&) bitmap) { } | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage(const BitmapAtlasStorage<T, N> &orig, int width, int height) : bitmap(width, height) { | ||
memset((T *) bitmap, 0, sizeof(T)*N*width*height); | ||
blit(bitmap, orig.bitmap, 0, 0, 0, 0, std::min(width, orig.bitmap.width()), std::min(height, orig.bitmap.height())); | ||
} | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::BitmapAtlasStorage(const BitmapAtlasStorage<T, N> &orig, int width, int height, const Remap *remapping, int count) : bitmap(width, height) { | ||
memset((T *) bitmap, 0, sizeof(T)*N*width*height); | ||
for (int i = 0; i < count; ++i) { | ||
const Remap &remap = remapping[i]; | ||
blit(bitmap, orig.bitmap, remap.target.x, remap.target.y, remap.source.x, remap.source.y, remap.width, remap.height); | ||
} | ||
} | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::operator msdfgen::BitmapConstRef<T, N>() const { | ||
return bitmap; | ||
} | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::operator msdfgen::BitmapRef<T, N>() { | ||
return bitmap; | ||
} | ||
|
||
template <typename T, int N> | ||
BitmapAtlasStorage<T, N>::operator msdfgen::Bitmap<T, N>() && { | ||
return (msdfgen::Bitmap<T, N> &&) bitmap; | ||
} | ||
|
||
template <typename T, int N> | ||
template <typename S> | ||
void BitmapAtlasStorage<T, N>::put(int x, int y, const msdfgen::BitmapConstRef<S, N> &subBitmap) { | ||
blit(bitmap, subBitmap, x, y, 0, 0, subBitmap.width, subBitmap.height); | ||
} | ||
|
||
template <typename T, int N> | ||
void BitmapAtlasStorage<T, N>::get(int x, int y, const msdfgen::BitmapRef<T, N> &subBitmap) const { | ||
blit(subBitmap, bitmap, 0, 0, x, y, subBitmap.width, subBitmap.height); | ||
} | ||
|
||
} |
Oops, something went wrong.