Re: Font size.
"corvid" <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <20111123110508.GA27799@local> |
Дмитрий wrote: > How to change font and font size for dillo interface? Currently, the user interface uses the font_sans_serif preference from dillorc, and the size cannot be adjusted. But perhaps we could add something like the attached... _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
ui_font.patch
(text/plain, 8.2 KB)
diff -r 929b584ad3ac dillorc
--- a/dillorc Thu Nov 17 07:57:01 2011 +0000
+++ b/dillorc Wed Nov 23 10:56:23 2011 +0000
@@ -209,6 +209,10 @@
#small_icons=NO
+# UI font. See rendering section for more information on fonts.
+#font_ui="DejaVu Sans"
+#font_factor_ui=1.0
+
# Here you can choose to hide some widgets of the dillo panel...
#show_back=YES
#show_forw=YES
diff -r 929b584ad3ac dw/fltkplatform.cc
--- a/dw/fltkplatform.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/dw/fltkplatform.cc Wed Nov 23 10:56:23 2011 +0000
@@ -307,7 +307,6 @@
b->color(fl_color_cube(FL_NUM_RED-1, FL_NUM_GREEN-1, FL_NUM_BLUE-2));
b->labelcolor(FL_BLACK);
b->labelfont(FL_HELVETICA);
- b->labelsize(14);
b->align(FL_ALIGN_WRAP|FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
tt_window->resizable(b);
tt_window->end();
diff -r 929b584ad3ac src/dialog.cc
--- a/src/dialog.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/src/dialog.cc Wed Nov 23 10:56:23 2011 +0000
@@ -166,12 +166,9 @@
Fl_Box *box = new Fl_Box(ih+2*gap,gap,ww-(ih+3*gap),ih/2, msg);
box->labelfont(FL_HELVETICA);
- box->labelsize(14);
box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_WRAP);
CustInput3 *c_inp = new CustInput3(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
- c_inp->labelsize(14);
- c_inp->textsize(14);
CustChoice *ch = new CustChoice(1*gap,ih+3*gap,180,24);
if (!pm) {
@@ -294,7 +291,6 @@
buf->text(txt);
Fl_Text_Display *td = new Fl_Text_Display(0,0,ww, wh-bh);
td->buffer(buf);
- td->textsize((int) rint(14.0 * prefs.font_factor));
/* enable wrapping lines; text uses entire width of window */
td->wrap_mode(true, false);
@@ -364,7 +360,6 @@
Fl_Box *box = new Fl_Box(60,0,ww-60,wh-bh, QuestionTxt);
box->labelfont(FL_HELVETICA);
- box->labelsize(14);
box->align(FL_ALIGN_WRAP);
Fl_Button *b;
@@ -420,7 +415,6 @@
Fl_Box *msg = new Fl_Box(20, y, msg_w, 100); /* resized below */
msg->label(message);
msg->labelfont(FL_HELVETICA);
- msg->labelsize(14);
msg->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT | FL_ALIGN_WRAP);
fl_font(msg->labelfont(), msg->labelsize());
@@ -432,27 +426,21 @@
/* inputs */
y += msg_h + 20;
Fl_Input *user_input = new Fl_Input(input_x, y, input_w, input_h, "User");
- user_input->labelsize(14);
- user_input->textsize(14);
window->add(user_input);
y += input_h + 10;
Fl_Secret_Input *password_input =
new Fl_Secret_Input(input_x, y, input_w, input_h, "Password");
- password_input->labelsize(14);
- password_input->textsize(14);
window->add(password_input);
/* "OK" button */
y += input_h + 20;
Fl_Button *ok_button = new EnterButton(200, y, 50, button_h, "OK");
- ok_button->labelsize(14);
ok_button->callback(Dialog_user_password_cb);
window->add(ok_button);
/* "Cancel" button */
Fl_Button *cancel_button =
new EnterButton(50, y, 100, button_h, "Cancel");
- cancel_button->labelsize(14);
cancel_button->callback(Dialog_user_password_cb);
window->add(cancel_button);
diff -r 929b584ad3ac src/dillo.cc
--- a/src/dillo.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/src/dillo.cc Wed Nov 23 10:56:23 2011 +0000
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <math.h>
#include <time.h>
#include <signal.h>
#include <locale.h>
@@ -381,11 +382,13 @@
checkPreferredFonts();
/* use preferred font for UI */
- Fl_Font defaultFont = dw::fltk::FltkFont::get (prefs.font_sans_serif, 0);
+ Fl_Font defaultFont = dw::fltk::FltkFont::get (prefs.font_ui, 0);
Fl::set_font(FL_HELVETICA, defaultFont); // this seems to be the
// only way to set the
// default font in fltk1.3
+ FL_NORMAL_SIZE = (Fl_Fontsize) rint(FL_NORMAL_SIZE * prefs.font_factor_ui);
+
// Create a new UI/bw pair
BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, xid, NULL);
diff -r 929b584ad3ac src/prefs.c
--- a/src/prefs.c Thu Nov 17 07:57:01 2011 +0000
+++ b/src/prefs.c Wed Nov 23 10:56:23 2011 +0000
@@ -18,6 +18,7 @@
#define PREFS_FONT_CURSIVE "URW Chancery L"
#define PREFS_FONT_FANTASY "DejaVu Sans" /* TODO: find good default */
#define PREFS_FONT_MONOSPACE "DejaVu Sans Mono"
+#define PREFS_FONT_UI "DejaVu Sans"
#define PREFS_SEARCH_URL "http://duckduckgo.com/lite/?kp=-1&q=%s"
#define PREFS_NO_PROXY "localhost 127.0.0.1"
#define PREFS_SAVE_DIR "/tmp/"
@@ -45,12 +46,14 @@
prefs.focus_new_tab = TRUE;
prefs.font_cursive = dStrdup(PREFS_FONT_CURSIVE);
prefs.font_factor = 1.0;
+ prefs.font_factor_ui = 1.0;
prefs.font_max_size = 100;
prefs.font_min_size = 6;
prefs.font_fantasy = dStrdup(PREFS_FONT_FANTASY);
prefs.font_monospace = dStrdup(PREFS_FONT_MONOSPACE);
prefs.font_sans_serif = dStrdup(PREFS_FONT_SANS_SERIF);
prefs.font_serif = dStrdup(PREFS_FONT_SERIF);
+ prefs.font_ui = dStrdup(PREFS_FONT_UI);
prefs.fullwindow_start = FALSE;
/* these four constitute the geometry */
@@ -117,6 +120,7 @@
dFree(prefs.font_monospace);
dFree(prefs.font_sans_serif);
dFree(prefs.font_serif);
+ dFree(prefs.font_ui);
a_Url_free(prefs.home);
dFree(prefs.http_language);
a_Url_free(prefs.http_proxy);
diff -r 929b584ad3ac src/prefs.h
--- a/src/prefs.h Thu Nov 17 07:57:01 2011 +0000
+++ b/src/prefs.h Wed Nov 23 10:56:23 2011 +0000
@@ -56,6 +56,7 @@
bool_t w3c_plus_heuristics;
bool_t focus_new_tab;
double font_factor;
+ double font_factor_ui;
int32_t font_max_size;
int32_t font_min_size;
bool_t show_back;
@@ -84,6 +85,7 @@
char *font_cursive;
char *font_fantasy;
char *font_monospace;
+ char *font_ui;
bool_t enterpress_forces_submit;
bool_t middle_click_opens_new_tab;
bool_t right_click_closes_tab;
diff -r 929b584ad3ac src/prefsparser.cc
--- a/src/prefsparser.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/src/prefsparser.cc Wed Nov 23 10:56:23 2011 +0000
@@ -60,12 +60,14 @@
{ "focus_new_tab", &prefs.focus_new_tab, PREFS_BOOL },
{ "font_cursive", &prefs.font_cursive, PREFS_STRING },
{ "font_factor", &prefs.font_factor, PREFS_DOUBLE },
+ { "font_factor_ui", &prefs.font_factor_ui, PREFS_DOUBLE },
{ "font_fantasy", &prefs.font_fantasy, PREFS_STRING },
{ "font_max_size", &prefs.font_max_size, PREFS_INT32 },
{ "font_min_size", &prefs.font_min_size, PREFS_INT32 },
{ "font_monospace", &prefs.font_monospace, PREFS_STRING },
{ "font_sans_serif", &prefs.font_sans_serif, PREFS_STRING },
{ "font_serif", &prefs.font_serif, PREFS_STRING },
+ { "font_ui", &prefs.font_ui, PREFS_STRING },
{ "fullwindow_start", &prefs.fullwindow_start, PREFS_BOOL },
{ "geometry", NULL, PREFS_GEOMETRY },
{ "home", &prefs.home, PREFS_URL },
diff -r 929b584ad3ac src/ui.cc
--- a/src/ui.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/src/ui.cc Wed Nov 23 10:56:23 2011 +0000
@@ -13,6 +13,7 @@
#include <unistd.h>
#include <stdio.h>
+#include <math.h>
#include "keys.hh"
#include "ui.hh"
@@ -468,14 +469,14 @@
{
// Images
IProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
- IProg->labelsize(12);
+ IProg->labelsize(rint(0.85 * FL_NORMAL_SIZE));
IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
IProg->labelcolor(FL_GRAY_RAMP + 2);
IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0");
p_xpos += pw;
// Page
PProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
- PProg->labelsize(12);
+ PProg->labelsize(rint(0.85 * FL_NORMAL_SIZE));
PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
PProg->labelcolor(FL_GRAY_RAMP + 2);
PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB");
diff -r 929b584ad3ac test/dw_ui_test.cc
--- a/test/dw_ui_test.cc Thu Nov 17 07:57:01 2011 +0000
+++ b/test/dw_ui_test.cc Wed Nov 23 10:56:23 2011 +0000
@@ -40,6 +40,8 @@
int main(int argc, char **argv)
{
+ FL_NORMAL_SIZE = 18;
+
FltkPlatform *platform = new FltkPlatform ();
Layout *layout = new Layout (platform);
@@ -58,7 +60,7 @@
FontAttrs fontAttrs;
fontAttrs.name = "Helvetica";
- fontAttrs.size = 14;
+ fontAttrs.size = FL_NORMAL_SIZE;
fontAttrs.weight = 400;
fontAttrs.style = FONT_STYLE_NORMAL;
fontAttrs.letterSpacing = 0;