]> git.sesse.net Git - casparcg/commitdiff
* fixed fontname-to-file mapping
authorniklaspandersson <niklas.p.andersson@svt.se>
Wed, 7 Aug 2013 14:35:51 +0000 (16:35 +0200)
committerniklaspandersson <niklas.p.andersson@svt.se>
Wed, 7 Aug 2013 14:35:51 +0000 (16:35 +0200)
common/os/windows/system_info.h
core/producer/text/text_producer.cpp
core/producer/text/text_producer.h
shell/server.cpp

index 54c19c7bfba491f4f798281c43f206bce5d0f80d..4079fffc96b23a976fa9d6f4f1f43f938f307bd2 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <string>
 #include <sstream>
+#include <map>
 
 namespace caspar {
        
@@ -78,5 +79,41 @@ static std::wstring system_product_name()
        return system_product_name;
 }
 
+static std::map<std::wstring, std::wstring> enumerate_fonts()
+{
+       std::map<std::wstring, std::wstring> result;
+       const DWORD max_str_length = 32766;
+
+       HKEY hkey; 
+       if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS)
+       {
+               int index = 0;
+               do
+               {
+                       DWORD name_length = max_str_length;
+                       wchar_t name[max_str_length];
+
+                       DWORD value_length = max_str_length;
+                       wchar_t value[max_str_length];
+
+                       long code = RegEnumValueW(hkey, index, name, &name_length, NULL, NULL, (PBYTE)value, &value_length);
+                       if(code == ERROR_SUCCESS)
+                       {
+                               std::wstring name_str(name);
+                               name_str = name_str.substr(0, name_str.find_last_of(L' '));     //the font names are formated like this: "AGaramondPro-Italic (OpenType)". We need to strip away the '(OpenType)'-part
+                               result.insert(std::pair<std::wstring, std::wstring>(name_str, std::wstring(value)));
+                       }
+                       else if(code == ERROR_NO_MORE_ITEMS)
+                               break;
+               }
+               while(++index);
+               //if(RegQueryValueEx(hkey, TEXT("SystemProductName"), NULL, &dwType, (PBYTE)&p_name_str, &dwSize) == ERROR_SUCCESS)             
+               //      system_product_name = p_name_str;               
+                
+               RegCloseKey(hkey);
+       }
+
+       return result;
+}
 
 }
\ No newline at end of file
index e7830262fb6584d04b1856c20146aaa656a06da0..d3fbe32e4859a31c379c191ae9f895bfb6f37c53 100644 (file)
@@ -27,6 +27,7 @@
 #include <core/frame/geometry.h>
 #include <core/frame/frame.h>
 #include <core/frame/draw_frame.h>
+
 #include <core/frame/frame_factory.h>
 #include <core/frame/pixel_format.h>
 #include <core/monitor/monitor.h>
index afbbc71aa9c360320184405a381abf141a31e9df..db81aca05560dfd461b7ceeb7950731334b2c720 100644 (file)
@@ -35,6 +35,8 @@
 namespace caspar { namespace core {
        namespace text 
        {
+               void init();
+
                struct text_info
                {
                        std::wstring font;
index 3d6926cd6777630efd2ca870d126f0564414d577..627164b87087957887ab237ca3bbfb531708e544 100644 (file)
@@ -104,6 +104,8 @@ struct server::impl : boost::noncopyable
                psd::init();              
                CASPAR_LOG(info) << L"Initialized psd module.";
 
+               core::text::init();
+
                register_producer_factory(&core::scene::create_dummy_scene_producer);
                register_producer_factory(&core::create_text_producer);