changeset 1878:d9895c8b8247

some font handling
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Mon, 24 Jan 2011 23:01:14 +0100
parents b0ffc141dcc2
children a9543fe6ba9f
files dw/fltkplatform.cc dw/fltkplatform.hh
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkplatform.cc	Mon Jan 24 16:34:06 2011 +0000
+++ b/dw/fltkplatform.cc	Mon Jan 24 23:01:14 2011 +0100
@@ -41,8 +41,24 @@
    new container::typed::HashTable <dw::core::style::FontAttrs,
                                     FltkFont> (false, false);
 
+container::typed::HashTable <lout::object::ConstString,
+                             lout::object::Integer> *FltkFont::systemFonts = NULL;
+
 FltkFont::FltkFont (core::style::FontAttrs *attrs)
 {
+   if (!systemFonts) {
+      systemFonts = new container::typed::HashTable
+         <lout::object::ConstString, lout::object::Integer> (true, true);
+
+      int k = Fl::set_fonts ("-*");
+      for (int i = 0; i < k; i++) {
+         int t;
+         const char *name = Fl::get_font_name ((Fl_Font) i, &t);
+         systemFonts->put(new object::ConstString (name),
+                          new object::Integer (i));
+      }
+   }
+
    copyAttrs (attrs);
 
    int fa = 0;
@@ -61,7 +77,14 @@
       font = FL_HELVETICA->plus (fa);
    }
 #else
-   font = FL_HELVETICA;
+   object::ConstString *nameString = new object::ConstString (name);
+   object::Integer *fontIndex = systemFonts->get(nameString);
+   delete nameString;
+   if (fontIndex) {
+      font = fontIndex->getValue ();
+   } else {
+      font = FL_HELVETICA;
+   }
 #endif
 
    fl_font(font, size);
--- a/dw/fltkplatform.hh	Mon Jan 24 16:34:06 2011 +0000
+++ b/dw/fltkplatform.hh	Mon Jan 24 23:01:14 2011 +0100
@@ -14,6 +14,8 @@
 
 class FltkFont: public core::style::Font
 {
+   static lout::container::typed::HashTable <lout::object::ConstString,
+                                       lout::object::Integer> *systemFonts;
    static lout::container::typed::HashTable <dw::core::style::FontAttrs,
                                        FltkFont> *fontsTable;