summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-07-18 20:52:00 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-07-18 20:52:00 +0200
commit74177a9f71b9f78ebdf4fcce2bf548c68f5d8258 (patch)
tree8fbe3e08630fa7e84788d8044a487620c59207f4
parentfa8b2f7a2a05de229819a9743c1fc67dca3ae8e9 (diff)
prefer fontFamily over fontStyle should a desired font not exist
This fixes missing characters on chinese websites if there specfied font has no italic variant.
-rw-r--r--dw/fltkplatform.cc25
-rw-r--r--dw/fltkplatform.hh3
2 files changed, 19 insertions, 9 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 50d239ce..d28dbdea 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -63,14 +63,18 @@ container::typed::HashTable <lout::object::ConstString,
FltkFont::FontFamily> *FltkFont::systemFonts =
NULL;
-FltkFont::FontFamily FltkFont::standardFontFamily;
+FltkFont::FontFamily FltkFont::standardFontFamily (FL_HELVETICA,
+ FL_HELVETICA_BOLD,
+ FL_HELVETICA_ITALIC,
+ FL_HELVETICA_BOLD_ITALIC);
-FltkFont::FontFamily::FontFamily ()
+FltkFont::FontFamily::FontFamily (Fl_Font fontNormal, Fl_Font fontBold,
+ Fl_Font fontItalic, Fl_Font fontBoldItalic)
{
- font[0] = FL_HELVETICA;
- font[1] = FL_HELVETICA_BOLD;
- font[2] = FL_HELVETICA_ITALIC;
- font[3] = FL_HELVETICA_BOLD_ITALIC;
+ font[0] = fontNormal;
+ font[1] = fontBold;
+ font[2] = fontItalic;
+ font[3] = fontBoldItalic;
}
void FltkFont::FontFamily::set (Fl_Font f, int attrs)
@@ -90,7 +94,10 @@ Fl_Font FltkFont::FontFamily::get (int attrs)
idx += 1;
if (attrs & FL_ITALIC)
idx += 2;
- return font[idx];
+
+ // should the desired font style not exist, we
+ // return the normal font of the fontFamily
+ return font[idx] >= 0 ? font[idx] : font[0];
}
@@ -163,7 +170,9 @@ void FltkFont::initSystemFonts ()
family->set ((Fl_Font) i, t);
delete familyName;
} else {
- family = new FontFamily ();
+ // set first font of family also as normal font in case there
+ // is no normal (non-bold, non-italic) font
+ family = new FontFamily ((Fl_Font) i, -1, -1, -1);
family->set ((Fl_Font) i, t);
systemFonts->put (familyName, family);
}
diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh
index 7c8bd366..db4bc794 100644
--- a/dw/fltkplatform.hh
+++ b/dw/fltkplatform.hh
@@ -17,7 +17,8 @@ class FltkFont: public core::style::Font
class FontFamily: public lout::object::Object {
Fl_Font font[4];
public:
- FontFamily ();
+ FontFamily (Fl_Font fontNormal, Fl_Font fontBold,
+ Fl_Font fontItalic, Fl_Font fontBoldItalic);
void set (Fl_Font, int attrs);
Fl_Font get (int attrs);
};