From 94f0da27688739f8a6b0406d25b6a86f8a71965e Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Wed, 29 Mar 2023 20:47:48 +0200 Subject: [PATCH] use text from layer for atlas --- src/LayerComposition.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index 020414b..38b29af 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -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 (); - atlas->setup(fontPath, settings); - atlasImage = make_shared (atlas->getAtlasImage()); - glyphGeometries = atlas->getGlyphGeometries(); msdfShader = make_shared (); #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 (atlas->getAtlasImage()); + glyphGeometries = atlas->getGlyphGeometries(); + } void LayerComposition::update(){