changeset 2225:a943ce01ce0a

added GlyphBitmapAlphabet::RenderText(font, utf8)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Apr 2025 18:11:55 +0200 (8 weeks ago)
parents e928629d7df0
children 639b4960bb51
files OrthancStone/Sources/Fonts/GlyphAlphabet.cpp OrthancStone/Sources/Fonts/GlyphAlphabet.h OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.cpp OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.h
diffstat 4 files changed, 36 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancStone/Sources/Fonts/GlyphAlphabet.cpp	Wed Apr 23 17:52:01 2025 +0200
+++ b/OrthancStone/Sources/Fonts/GlyphAlphabet.cpp	Thu Apr 24 18:11:55 2025 +0200
@@ -76,6 +76,27 @@
   }
     
 
+  void GlyphAlphabet::Register(FontRenderer& renderer,
+                               const std::string& utf8)
+  {
+    size_t pos = 0;
+    while (pos < utf8.size())
+    {
+      uint32_t unicode;
+      size_t size;
+      Orthanc::Toolbox::Utf8ToUnicodeCharacter(unicode, size, utf8, pos);
+
+      if (unicode != '\r' &&
+          unicode != '\n')
+      {
+        Register(renderer, unicode);
+      }
+
+      pos += size;
+    }
+  }
+
+
 #if ORTHANC_ENABLE_LOCALE == 1
   bool GlyphAlphabet::GetUnicodeFromCodepage(uint32_t& unicode,
                                              unsigned int index,
--- a/OrthancStone/Sources/Fonts/GlyphAlphabet.h	Wed Apr 23 17:52:01 2025 +0200
+++ b/OrthancStone/Sources/Fonts/GlyphAlphabet.h	Thu Apr 24 18:11:55 2025 +0200
@@ -88,6 +88,9 @@
     void Register(FontRenderer& renderer,
                   uint32_t unicode);
 
+    void Register(FontRenderer& renderer,
+                  const std::string& utf8);
+
 #if ORTHANC_ENABLE_LOCALE == 1
     static bool GetUnicodeFromCodepage(uint32_t& unicode,
                                        unsigned int index,
--- a/OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.cpp	Wed Apr 23 17:52:01 2025 +0200
+++ b/OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.cpp	Thu Apr 24 18:11:55 2025 +0200
@@ -112,4 +112,12 @@
 
     return bitmap.release();
   }
+
+
+  Orthanc::ImageAccessor* GlyphBitmapAlphabet::RenderText(FontRenderer& font,
+                                                          const std::string& utf8)
+  {
+    alphabet_.Register(font, utf8);
+    return RenderText(utf8);
+  }
 }
--- a/OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.h	Wed Apr 23 17:52:01 2025 +0200
+++ b/OrthancStone/Sources/Fonts/GlyphBitmapAlphabet.h	Thu Apr 24 18:11:55 2025 +0200
@@ -53,8 +53,10 @@
     void LoadCodepage(FontRenderer& renderer,
                       Orthanc::Encoding codepage);
 #endif
-    
-    
+
     Orthanc::ImageAccessor* RenderText(const std::string& utf8) const;
+
+    Orthanc::ImageAccessor* RenderText(FontRenderer& font,
+                                       const std::string& utf8);
   };
 }