use text from layer for atlas

This commit is contained in:
jrkb 2023-03-29 20:47:48 +02:00
parent 9728c288b5
commit 94f0da2768

View file

@ -8,6 +8,7 @@ void LayerComposition::setup(){
ofxMsdfgen::AtlasSettings settings;
//settings.characters = "ABCDEFGHIJKL";
settings.scale = 64;
settings.characters = "";
//string fontName = "RobotoFlex.ttf";
//string fontPath = "data/fonts/" + fontName;
//string fontPath = "data/celines-fonts/testing2VF.ttf";
@ -15,10 +16,7 @@ void LayerComposition::setup(){
//string fontPath = "data/celines-fonts/Alfarn2.otf";
//string fontPath = "data/celines-fonts/Cottagecore.ttf";
atlas = make_shared <ofxMsdfgen::Atlas>();
atlas->setup(fontPath, settings);
atlasImage = make_shared <ofImage>(atlas->getAtlasImage());
glyphGeometries = atlas->getGlyphGeometries();
msdfShader = make_shared <ofShader>();
#ifdef TARGET_EMSCRIPTEN
msdfShader->load("ofxMsdfgen/shaders/unitRange/ES3/shader");
@ -32,8 +30,14 @@ void LayerComposition::setup(){
layer->setProps(Layer::Props());
settings.characters += layer->getProps().text;
layers.push_back(std::move(layer));
atlas->setup(fontPath, settings);
atlas->generate();
atlasImage = make_shared <ofImage>(atlas->getAtlasImage());
glyphGeometries = atlas->getGlyphGeometries();
}
void LayerComposition::update(){