-
First of all i want to thank you for making this great library publicly available. I was wondering if someone could roughly point out the steps one would need to do to create and use the dynamic atlas implementation? Right now im creating a DynamicAtlas object, loading a font and a FontGeometry object using the ASCII charset and then adding the loaded glyphs via dynamicAtlas.add(...). However there does not seem to be any data in the BitmapAtlasStorage object and also all glyphs still have rectangle dimensions and positions of 0. Im using
to create my DynamicAtlas instance. Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is kind of an overlooked feature, I hadn't even noticed that because of some old leftover code it wasn't even compatible with the immediate generator, so I've fixed that now. In any case, I believe the missing step is #include <msdf-atlas-gen/msdf-atlas-gen.h>
using namespace msdf_atlas;
int main() {
msdfgen::FreetypeHandle *ft = msdfgen::initializeFreetype();
msdfgen::FontHandle *font = msdfgen::loadFont(ft, "C:/Windows/Fonts/arial.ttf");
std::vector<GlyphGeometry> glyphs;
FontGeometry fontGeometry(&glyphs);
fontGeometry.loadCharset(font, 1, Charset::ASCII);
for (GlyphGeometry &glyph : glyphs) {
glyph.wrapBox(32., 4/32., 1.); // important
glyph.edgeColoring(msdfgen::edgeColoringSimple, 3, 0);
}
DynamicAtlas<ImmediateAtlasGenerator<float, 3, msdfGenerator, BitmapAtlasStorage<byte, 3> > > dynamicAtlas;
dynamicAtlas.add(glyphs.data(), glyphs.size());
msdfgen::savePng(dynamicAtlas.atlasGenerator().atlasStorage(), "C:/Temp/dynamic-atlas-test.png");
msdfgen::destroyFont(font);
msdfgen::deinitializeFreetype(ft);
return 0;
} |
Beta Was this translation helpful? Give feedback.
This is kind of an overlooked feature, I hadn't even noticed that because of some old leftover code it wasn't even compatible with the immediate generator, so I've fixed that now.
In any case, I believe the missing step is
GlyphGeometry::wrapBox
which is required to determine the actual resolution of the glyphs (and range). Sorry for not mentioning this anywhere. For MSDF,GlyphGeometry::edgeColoring
is also something that the immediate generator doesn't do by itself. Here is an example that should work as of b5d54f3: