diff Framework/Radiography/RadiographySceneReader.cpp @ 1190:f417a0ae282b

wip: TextLayer with new fonts
author Alain Mazy <alain@mazy.be>
date Tue, 26 Nov 2019 15:27:48 +0100
parents 9889c819db01
children bdc6837d5917 9ee6b28f53e8
line wrap: on
line diff
--- a/Framework/Radiography/RadiographySceneReader.cpp	Fri Nov 22 09:51:22 2019 +0100
+++ b/Framework/Radiography/RadiographySceneReader.cpp	Tue Nov 26 15:27:48 2019 +0100
@@ -97,18 +97,8 @@
       }
       else if (jsonLayer["type"].asString() == "text")
       {
-        if (fontRegistry_ == NULL || fontRegistry_->GetSize() == 0)
-        {
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); // you must provide a FontRegistry if you need to re-create text layers.
-        }
-
         ReadLayerGeometry(geometry, jsonLayer);
-        const Orthanc::Font* font = fontRegistry_->FindFont(jsonLayer["fontName"].asString());
-        if (font == NULL) // if not found, take the first font in the registry
-        {
-          font = &(fontRegistry_->GetFont(0));
-        }
-        scene_.LoadText(*font, jsonLayer["text"].asString(), &geometry);
+        scene_.LoadText(jsonLayer["text"].asString(), jsonLayer["fontSize"].asUInt(), static_cast<uint8_t>(jsonLayer["foreground"].asUInt()), &geometry);
       }
       else if (jsonLayer["type"].asString() == "alpha")
       {
@@ -184,18 +174,8 @@
       }
       else if (jsonLayer["type"].asString() == "text")
       {
-        if (fontRegistry_ == NULL || fontRegistry_->GetSize() == 0)
-        {
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); // you must provide a FontRegistry if you need to re-create text layers.
-        }
-
         ReadLayerGeometry(geometry, jsonLayer);
-        const Orthanc::Font* font = fontRegistry_->FindFont(jsonLayer["fontName"].asString());
-        if (font == NULL) // if not found, take the first font in the registry
-        {
-          font = &(fontRegistry_->GetFont(0));
-        }
-        scene_.LoadText(*font, jsonLayer["text"].asString(), &geometry);
+        scene_.LoadText(jsonLayer["text"].asString(), jsonLayer["fontSize"].asUInt(), static_cast<uint8_t>(jsonLayer["foreground"].asUInt()), &geometry);
       }
       else if (jsonLayer["type"].asString() == "alpha")
       {