diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-11-17 21:41:04 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-11-17 21:41:04 +0100 |
commit | e086ba408da281bbac5ac222371bf3b9626d6968 (patch) | |
tree | 93beace3dff603eb0166fb3e5ebd6b25b766fd87 /dw | |
parent | 27c5e68d73ba6ad4c65b21865fb1a5f6734a1a6c (diff) |
properly handle comma separated lists of font names in CSS
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkplatform.cc | 6 | ||||
-rw-r--r-- | dw/fltkplatform.hh | 1 | ||||
-rw-r--r-- | dw/layout.hh | 5 | ||||
-rw-r--r-- | dw/platform.hh | 2 | ||||
-rw-r--r-- | dw/style.cc | 38 | ||||
-rw-r--r-- | dw/style.hh | 3 |
6 files changed, 17 insertions, 38 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 56a73a19..b9aa6bd8 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -83,6 +83,12 @@ FltkFont::~FltkFont () fontsTable->remove (this); } +bool +FltkPlatform::fontExists (const char *name) +{ + return ::fltk::font(name) != NULL; +} + FltkFont* FltkFont::create (core::style::FontAttrs *attrs) { diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index dcb1a7ff..7415ac84 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -150,6 +150,7 @@ public: core::style::Font *createFont (core::style::FontAttrs *attrs, bool tryEverything); + bool fontExists (const char *name); core::style::Color *createColor (int color); core::style::Tooltip *createTooltip (const char *text); diff --git a/dw/layout.hh b/dw/layout.hh index 39311c38..304cf166 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -322,6 +322,11 @@ public: return platform->createFont (attrs, tryEverything); } + inline bool fontExists (const char *name) + { + return platform->fontExists (name); + } + inline style::Color *createColor (int color) { return platform->createColor (color); diff --git a/dw/platform.hh b/dw/platform.hh index 4b1acdb9..69d1feab 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -119,6 +119,8 @@ public: virtual style::Font *createFont (style::FontAttrs *attrs, bool tryEverything) = 0; + virtual bool fontExists (const char *name) = 0; + /** * \brief Create a color resource for a given 0xrrggbb value. */ diff --git a/dw/style.cc b/dw/style.cc index ed0850ba..d28d1389 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -296,43 +296,9 @@ Font *Font::create (Layout *layout, FontAttrs *attrs) return create0 (layout, attrs, false); } -Font *Font::createFromList (Layout *layout, FontAttrs *attrs, - char *defaultFamily) +bool Font::exists (Layout *layout, const char *name) { - Font *font = NULL; - FontAttrs attrs2; - char *comma, *list, *current; - - attrs2 = *attrs; - current = list = strdup (attrs->name); - - while (current && (font == NULL)) { - comma = strchr (current, ','); - if (comma) *comma = 0; - - attrs2.name = current; - font = create0 (layout, &attrs2, false); - if (font) - break; - - if (comma) { - current = comma + 1; - while (isspace (*current)) current++; - } else - current = NULL; - } - - delete list; - - if (font == NULL) { - attrs2.name = defaultFamily; - font = create0 (layout, &attrs2, true); - } - - if (font == NULL) - MSG_WARN("Could not find any font.\n"); - - return font; + return layout->fontExists (name); } // ---------------------------------------------------------------------- diff --git a/dw/style.hh b/dw/style.hh index c3e6a5ff..af6642f9 100644 --- a/dw/style.hh +++ b/dw/style.hh @@ -578,8 +578,7 @@ public: int xHeight; static Font *create (Layout *layout, FontAttrs *attrs); - static Font *createFromList (Layout *layout, FontAttrs *attrs, - char *defaultFamily); + static bool exists (Layout *layout, const char *name); inline void ref () { refCount++; } inline void unref () { if (--refCount == 0) delete this; } |