summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-06-06 21:04:05 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-06-06 21:04:05 +0200
commitd0731e9ff6d6b8ce395605f9a01fb723073fc7ce (patch)
treee03d0babaa78fe5848997017abbfc53471d51ff5
parented854c3ebe04ef4a18db337fb97dd2511d3b9d91 (diff)
port preferred font code to fltk-1.3
-rw-r--r--dw/fltkplatform.cc52
-rw-r--r--dw/fltkplatform.hh2
-rw-r--r--src/dillo.cc21
3 files changed, 41 insertions, 34 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 6d0b2ec4..2a04985a 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -75,30 +75,12 @@ Fl_Font FltkFont::FontFamily::get (int attrs)
return font[idx];
}
+
+
FltkFont::FltkFont (core::style::FontAttrs *attrs)
{
- if (!systemFonts) {
- systemFonts = new container::typed::HashTable
- <lout::object::ConstString, FontFamily> (true, true);
-
- int k = Fl::set_fonts ("-*");
- for (int i = 0; i < k; i++) {
- int t;
- Fl::get_font_name ((Fl_Font) i, &t);
- const char *name = Fl::get_font ((Fl_Font) i);
- object::String *familyName = new object::String(name + 1);
- FontFamily *family = systemFonts->get (familyName);
-
- if (family) {
- family->set ((Fl_Font) i, t);
- delete familyName;
- } else {
- family = new FontFamily ();
- family->set ((Fl_Font) i, t);
- systemFonts->put (familyName, family);
- }
- }
- }
+ if (!systemFonts)
+ initSystemFonts ();
copyAttrs (attrs);
@@ -129,9 +111,35 @@ FltkFont::~FltkFont ()
fontsTable->remove (this);
}
+void FltkFont::initSystemFonts ()
+{
+ systemFonts = new container::typed::HashTable
+ <lout::object::ConstString, FontFamily> (true, true);
+
+ int k = Fl::set_fonts ("-*");
+ for (int i = 0; i < k; i++) {
+ int t;
+ Fl::get_font_name ((Fl_Font) i, &t);
+ const char *name = Fl::get_font ((Fl_Font) i);
+ object::String *familyName = new object::String(name + 1);
+ FontFamily *family = systemFonts->get (familyName);
+
+ if (family) {
+ family->set ((Fl_Font) i, t);
+ delete familyName;
+ } else {
+ family = new FontFamily ();
+ family->set ((Fl_Font) i, t);
+ systemFonts->put (familyName, family);
+ }
+ }
+}
+
bool
FltkFont::fontExists (const char *name)
{
+ if (!systemFonts)
+ initSystemFonts ();
object::ConstString familyName (name);
return systemFonts->get (&familyName) != NULL;
}
diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh
index 134b5c54..637c29ac 100644
--- a/dw/fltkplatform.hh
+++ b/dw/fltkplatform.hh
@@ -32,6 +32,8 @@ class FltkFont: public core::style::Font
FltkFont (core::style::FontAttrs *attrs);
~FltkFont ();
+ static void initSystemFonts ();
+
public:
Fl_Font font;
diff --git a/src/dillo.cc b/src/dillo.cc
index 937385cb..dad778d3 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -48,6 +48,8 @@
#include "cookies.h"
#include "auth.h"
+#include "dw/fltkcore.hh"
+
/*
* Command line options structure
*/
@@ -213,14 +215,12 @@ static void custMenuLabelMeasure(const Fl_Label* o, int& W, int& H)
fl_measure(o->value, W, H, interpret_symbols);
}
-#if 0
-PORT1.3
/*
* Tell the user if default/pref fonts can't be found.
*/
static void checkFont(const char *name, const char *type)
{
- if (::fltk::font(name) == NULL)
+ if (! dw::fltk::FltkFont::fontExists(name))
MSG_WARN("preferred %s font \"%s\" not found.\n", type, name);
}
@@ -232,7 +232,7 @@ static void checkPreferredFonts()
checkFont(prefs.font_cursive, "cursive");
checkFont(prefs.font_fantasy, "fantasy");
}
-#endif
+
/*
* Given a command line argument, build a DilloUrl for it.
*/
@@ -371,16 +371,13 @@ int main(int argc, char **argv)
// Use to permit '&' interpretation.
Fl::set_labeltype(FL_FREE_LABELTYPE,custMenuLabelDraw,custMenuLabelMeasure);
-#if 0
-PORT1.3
checkPreferredFonts();
+
/* use preferred font for UI */
- fltk::Font *dfont = fltk::font(prefs.font_sans_serif, 0);
- if (dfont) {
- fltk::Widget::default_style->textfont(dfont);
- fltk::Widget::default_style->labelfont(dfont);
- }
-#endif
+ Fl::set_font(FL_HELVETICA, prefs.font_sans_serif); // this seems to be the
+ // only way to set the
+ // default font in fltk1.3
+
// Create a new UI/bw pair
BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, xid, NULL);