diff Framework/Radiography/RadiographyTextLayer.h @ 1220:9ee6b28f53e8

RadiographyTextLayer: support multiple fonts
author Alain Mazy <alain@mazy.be>
date Sat, 07 Dec 2019 17:47:23 +0100
parents ab958fd99b07
children 37bc7f115f81 1c7ae79c426d
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyTextLayer.h	Sat Dec 07 17:46:25 2019 +0100
+++ b/Framework/Radiography/RadiographyTextLayer.h	Sat Dec 07 17:47:23 2019 +0100
@@ -31,38 +31,42 @@
   {
   private:
     std::string                 text_;
+    std::string                 font_;
     unsigned int                fontSize_;
-    uint8_t                     foreground_;
+    uint8_t                     foregroundGreyLevel_;
 
-    static bool                                       fontHasBeenConfigured_;
-    static Orthanc::EmbeddedResources::FileResourceId fontResourceId_;
+    static std::map<std::string, Orthanc::EmbeddedResources::FileResourceId>  fonts_;
   public:
     RadiographyTextLayer(MessageBroker& broker, const RadiographyScene& scene) :
       RadiographyAlphaLayer(broker, scene)
     {
     }
 
-    void SetText(const std::string& utf8, unsigned int fontSize, uint8_t foreground);
+    void SetText(const std::string& utf8, const std::string& font, unsigned int fontSize, uint8_t foregroundGreyLevel);
 
     const std::string& GetText() const
     {
       return text_;
     }
 
+    const std::string& GetFont() const
+    {
+      return font_;
+    }
+
     unsigned int GetFontSize() const
     {
       return fontSize_;
     }
 
-    uint8_t GetForeground() const
+    uint8_t GetForegroundGreyLevel() const
     {
-      return foreground_;
+      return foregroundGreyLevel_;
     }
 
-    static void SetFont(Orthanc::EmbeddedResources::FileResourceId fontResourceId)
+    static void RegisterFont(const std::string& name, Orthanc::EmbeddedResources::FileResourceId fontResourceId)
     {
-      fontResourceId_ = fontResourceId;
-      fontHasBeenConfigured_ = true;
+      fonts_[name] = fontResourceId;
     }
   };
 }