changeset 2913:058851941abe

Font::LoadFromResource()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 31 Oct 2018 14:41:51 +0100
parents ab03dae59d6e
children 15b517659a74
files Core/Images/Font.cpp Core/Images/Font.h
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/Font.cpp	Wed Oct 31 14:14:16 2018 +0100
+++ b/Core/Images/Font.cpp	Wed Oct 31 14:41:51 2018 +0100
@@ -153,6 +153,16 @@
 #endif
 
 
+#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1
+  void Font::LoadFromResource(EmbeddedResources::FileResourceId resource)
+  {
+    std::string content;
+    EmbeddedResources::GetFileResource(content, resource);
+    LoadFromMemory(content);
+  }
+#endif
+
+
   static unsigned int MyMin(unsigned int a, 
                             unsigned int b)
   {
--- a/Core/Images/Font.h	Wed Oct 31 14:14:16 2018 +0100
+++ b/Core/Images/Font.h	Wed Oct 31 14:41:51 2018 +0100
@@ -33,6 +33,14 @@
 
 #pragma once
 
+#if !defined(ORTHANC_HAS_EMBEDDED_RESOURCES)
+#  error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined
+#endif
+
+#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1
+#  include <EmbeddedResources.h>   // Autogenerated file
+#endif
+
 #include "ImageAccessor.h"
 
 #include <stdint.h>
@@ -88,6 +96,10 @@
     void LoadFromFile(const std::string& path);
 #endif
 
+#if ORTHANC_HAS_EMBEDDED_RESOURCES == 1
+    void LoadFromResource(EmbeddedResources::FileResourceId resource);
+#endif
+
     const std::string& GetName() const
     {
       return name_;