Mercurial > hg > orthanc-stone
diff Framework/Radiography/RadiographyTextLayer.cpp @ 1190:f417a0ae282b
wip: TextLayer with new fonts
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Tue, 26 Nov 2019 15:27:48 +0100 |
parents | b85f635f1eb5 |
children | a5f2a6b04a31 |
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyTextLayer.cpp Fri Nov 22 09:51:22 2019 +0100 +++ b/Framework/Radiography/RadiographyTextLayer.cpp Tue Nov 26 15:27:48 2019 +0100 @@ -18,19 +18,32 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ - #include "RadiographyTextLayer.h" +#include "Core/OrthancException.h" #include "RadiographyScene.h" +#include "Framework/Toolbox/TextRenderer.h" namespace OrthancStone { - void RadiographyTextLayer::LoadText(const Orthanc::Font& font, - const std::string& utf8) + bool RadiographyTextLayer::fontHasBeenConfigured_ = false; + Orthanc::EmbeddedResources::FileResourceId RadiographyTextLayer::fontResourceId_; + + void RadiographyTextLayer::LoadText(const std::string& utf8, + size_t fontSize, + uint8_t foreground) { + if (!fontHasBeenConfigured_) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls, "No font has been loaded"); + } + text_ = utf8; - fontName_ = font.GetName(); + fontSize_ = fontSize; + foreground_ = foreground; - SetAlpha(font.RenderAlpha(utf8)); + SetAlpha(TextRenderer::Render(fontResourceId_, + fontSize_, + text_)); } }