[project @ 2004-09-13 23:56:18 by jmb]

Make fonts user-configurable.
This loses font-style support, though it shouldn't be hard to put it back again.

svn path=/import/netsurf/; revision=1274
This commit is contained in:
John Mark Bell 2004-09-13 23:56:18 +00:00
parent 8e0b3d8136
commit c358b80cc5
10 changed files with 526 additions and 139 deletions

Binary file not shown.

Binary file not shown.

View File

@ -136,7 +136,7 @@ const struct css_style css_base_style = {
CSS_DISPLAY_BLOCK, CSS_DISPLAY_BLOCK,
CSS_EMPTY_CELLS_SHOW, CSS_EMPTY_CELLS_SHOW,
CSS_FLOAT_NONE, CSS_FLOAT_NONE,
CSS_FONT_FAMILY_SANS_SERIF, CSS_FONT_FAMILY_INHERIT, /* Default font is user-defined */
{ CSS_FONT_SIZE_LENGTH, { { 10, CSS_UNIT_PT } } }, { CSS_FONT_SIZE_LENGTH, { { 10, CSS_UNIT_PT } } },
CSS_FONT_STYLE_NORMAL, CSS_FONT_STYLE_NORMAL,
CSS_FONT_VARIANT_NORMAL, CSS_FONT_VARIANT_NORMAL,

View File

@ -48,5 +48,6 @@ void nsfont_txtenum(struct font_data *font, const char *text,
const char **rotext, const char **rotext,
size_t *rolength, size_t *rolength,
size_t *consumed); size_t *consumed);
void nsfont_fill_nametable(void);
#endif #endif

View File

@ -20,6 +20,7 @@
#include "oslib/wimp.h" #include "oslib/wimp.h"
#include "netsurf/utils/config.h" #include "netsurf/utils/config.h"
#include "netsurf/desktop/netsurf.h" #include "netsurf/desktop/netsurf.h"
#include "netsurf/render/font.h"
#include "netsurf/riscos/gui.h" #include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h" #include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h" #include "netsurf/riscos/theme.h"
@ -41,10 +42,12 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
#endif #endif
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip, dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
dialog_warning, dialog_config_th_pane, dialog_debug, dialog_warning, dialog_config_th_pane, dialog_debug,
dialog_folder, dialog_entry, dialog_search, dialog_print; dialog_folder, dialog_entry, dialog_search, dialog_print,
dialog_config_font;
static int ro_gui_choices_font_size; static int ro_gui_choices_font_size;
static int ro_gui_choices_font_min_size; static int ro_gui_choices_font_min_size;
static int config_font_icon = -1;
static bool ro_gui_choices_http_proxy; static bool ro_gui_choices_http_proxy;
static int ro_gui_choices_http_proxy_auth; static int ro_gui_choices_http_proxy_auth;
static int config_br_icon = -1; static int config_br_icon = -1;
@ -84,11 +87,12 @@ static void ro_gui_dialog_config_prepare(void);
static void ro_gui_dialog_config_set(void); static void ro_gui_dialog_config_set(void);
static void ro_gui_dialog_click_config(wimp_pointer *pointer); static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer); static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
static void ro_gui_dialog_update_config_br(void);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer); static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
static void ro_gui_dialog_config_proxy_update(void); static void ro_gui_dialog_config_proxy_update(void);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer); static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer); static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
static void ro_gui_dialog_update_config_font(void);
static void ro_gui_dialog_click_config_font(wimp_pointer *pointer);
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer); static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
static void ro_gui_dialog_reset_zoom(void); static void ro_gui_dialog_reset_zoom(void);
static void ro_gui_dialog_click_warning(wimp_pointer *pointer); static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
@ -124,6 +128,7 @@ void ro_gui_dialog_init(void)
dialog_entry = ro_gui_dialog_create("new_entry"); dialog_entry = ro_gui_dialog_create("new_entry");
dialog_search = ro_gui_dialog_create("search"); dialog_search = ro_gui_dialog_create("search");
dialog_print = ro_gui_dialog_create("print"); dialog_print = ro_gui_dialog_create("print");
dialog_config_font = ro_gui_dialog_create("config_font");
} }
@ -436,6 +441,8 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
else if (pointer->w == dialog_print) else if (pointer->w == dialog_print)
ro_gui_print_click(pointer); ro_gui_print_click(pointer);
#endif #endif
else if (pointer->w == dialog_config_font)
ro_gui_dialog_click_config_font(pointer);
} }
@ -452,6 +459,8 @@ void ro_gui_dialog_open_config(void)
false); false);
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_THEME, ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_THEME,
false); false);
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_FONT,
false);
ro_gui_dialog_open(dialog_config); ro_gui_dialog_open(dialog_config);
ro_gui_open_pane(dialog_config, dialog_config_br, 0); ro_gui_open_pane(dialog_config, dialog_config_br, 0);
} }
@ -464,9 +473,6 @@ void ro_gui_dialog_open_config(void)
void ro_gui_dialog_config_prepare(void) void ro_gui_dialog_config_prepare(void)
{ {
/* browser pane */ /* browser pane */
ro_gui_choices_font_size = option_font_size;
ro_gui_choices_font_min_size = option_font_min_size;
ro_gui_dialog_update_config_br();
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG, ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
language_name(option_language ? language_name(option_language ?
option_language : "en")); option_language : "en"));
@ -478,6 +484,12 @@ void ro_gui_dialog_config_prepare(void)
ro_gui_set_icon_selected_state(dialog_config_br, ro_gui_set_icon_selected_state(dialog_config_br,
ICON_CONFIG_BR_OPENBROWSER, ICON_CONFIG_BR_OPENBROWSER,
option_open_browser_at_startup); option_open_browser_at_startup);
ro_gui_set_icon_selected_state(dialog_config_br,
ICON_CONFIG_BR_BLOCKADS,
option_block_ads);
ro_gui_set_icon_selected_state(dialog_config_br,
ICON_CONFIG_BR_PLUGINS,
option_no_plugins);
/* proxy pane */ /* proxy pane */
ro_gui_choices_http_proxy = option_http_proxy; ro_gui_choices_http_proxy = option_http_proxy;
@ -504,6 +516,31 @@ void ro_gui_dialog_config_prepare(void)
/* themes pane */ /* themes pane */
ro_gui_dialog_load_themes(); ro_gui_dialog_load_themes();
theme_choice = ro_gui_theme_find(option_theme); theme_choice = ro_gui_theme_find(option_theme);
/* font pane */
ro_gui_choices_font_size = option_font_size;
ro_gui_choices_font_min_size = option_font_min_size;
ro_gui_dialog_update_config_font();
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SANS,
option_font_sans ? option_font_sans :
"Homerton.Medium");
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SERIF,
option_font_serif ? option_font_serif :
"Trinity.Medium");
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_MONO,
option_font_mono ? option_font_mono :
"Corpus.Medium");
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_CURS,
option_font_cursive ? option_font_cursive :
"Homerton.Medium");
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_FANT,
option_font_fantasy ? option_font_fantasy :
"Homerton.Medium");
ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_DEF,
option_font_default ? option_font_default :
"Homerton.Medium");
ro_gui_set_icon_selected_state(dialog_config_font,
ICON_CONFIG_FONT_USE_UFONT, option_font_ufont);
} }
@ -513,13 +550,19 @@ void ro_gui_dialog_config_prepare(void)
void ro_gui_dialog_config_set(void) { void ro_gui_dialog_config_set(void) {
/* browser pane */ /* browser pane */
option_font_size = ro_gui_choices_font_size; if (option_homepage_url)
option_font_min_size = ro_gui_choices_font_min_size; free(option_homepage_url);
option_homepage_url = strdup(ro_gui_get_icon_string(dialog_config_br, option_homepage_url = strdup(ro_gui_get_icon_string(dialog_config_br,
ICON_CONFIG_BR_HOMEPAGE)); ICON_CONFIG_BR_HOMEPAGE));
option_open_browser_at_startup = ro_gui_get_icon_selected_state( option_open_browser_at_startup = ro_gui_get_icon_selected_state(
dialog_config_br, dialog_config_br,
ICON_CONFIG_BR_OPENBROWSER); ICON_CONFIG_BR_OPENBROWSER);
option_block_ads = ro_gui_get_icon_selected_state(
dialog_config_br,
ICON_CONFIG_BR_BLOCKADS);
option_no_plugins = ro_gui_get_icon_selected_state(
dialog_config_br,
ICON_CONFIG_BR_PLUGINS);
if (ro_gui_choices_lang) { if (ro_gui_choices_lang) {
free(option_language); free(option_language);
option_language = strdup(ro_gui_choices_lang); option_language = strdup(ro_gui_choices_lang);
@ -533,6 +576,7 @@ void ro_gui_dialog_config_set(void) {
/* proxy pane */ /* proxy pane */
option_http_proxy = ro_gui_choices_http_proxy; option_http_proxy = ro_gui_choices_http_proxy;
if (option_http_proxy_host)
free(option_http_proxy_host); free(option_http_proxy_host);
option_http_proxy_host = strdup(ro_gui_get_icon_string( option_http_proxy_host = strdup(ro_gui_get_icon_string(
dialog_config_prox, dialog_config_prox,
@ -540,10 +584,12 @@ void ro_gui_dialog_config_set(void) {
option_http_proxy_port = atoi(ro_gui_get_icon_string(dialog_config_prox, option_http_proxy_port = atoi(ro_gui_get_icon_string(dialog_config_prox,
ICON_CONFIG_PROX_HTTPPORT)); ICON_CONFIG_PROX_HTTPPORT));
option_http_proxy_auth = ro_gui_choices_http_proxy_auth; option_http_proxy_auth = ro_gui_choices_http_proxy_auth;
if (option_http_proxy_auth_user)
free(option_http_proxy_auth_user); free(option_http_proxy_auth_user);
option_http_proxy_auth_user = strdup(ro_gui_get_icon_string( option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(
dialog_config_prox, dialog_config_prox,
ICON_CONFIG_PROX_AUTHUSER)); ICON_CONFIG_PROX_AUTHUSER));
if (option_http_proxy_auth_pass)
free(option_http_proxy_auth_pass); free(option_http_proxy_auth_pass);
option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string( option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(
dialog_config_prox, dialog_config_prox,
@ -558,6 +604,36 @@ void ro_gui_dialog_config_set(void) {
option_theme = strdup(theme_choice->filename); option_theme = strdup(theme_choice->filename);
ro_gui_theme_apply(theme_choice); ro_gui_theme_apply(theme_choice);
} }
/* font pane */
option_font_size = ro_gui_choices_font_size;
option_font_min_size = ro_gui_choices_font_min_size;
if (option_font_sans)
free(option_font_sans);
option_font_sans = strdup(ro_gui_get_icon_string(dialog_config_font,
ICON_CONFIG_FONT_SANS));
if (option_font_serif)
free(option_font_serif);
option_font_serif = strdup(ro_gui_get_icon_string(dialog_config_font,
ICON_CONFIG_FONT_SERIF));
if (option_font_mono)
free(option_font_mono);
option_font_mono = strdup(ro_gui_get_icon_string(dialog_config_font,
ICON_CONFIG_FONT_MONO));
if (option_font_cursive)
free(option_font_cursive);
option_font_cursive = strdup(ro_gui_get_icon_string(
dialog_config_font, ICON_CONFIG_FONT_CURS));
if (option_font_fantasy)
free(option_font_fantasy);
option_font_fantasy = strdup(ro_gui_get_icon_string(
dialog_config_font, ICON_CONFIG_FONT_FANT));
if (option_font_default)
free(option_font_default);
option_font_default = strdup(ro_gui_get_icon_string(
dialog_config_font, ICON_CONFIG_FONT_DEF));
option_font_ufont = ro_gui_get_icon_selected_state(
dialog_config_font, ICON_CONFIG_FONT_USE_UFONT);
} }
@ -625,6 +701,12 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
<< wimp_CHILD_TS_EDGE_SHIFT); << wimp_CHILD_TS_EDGE_SHIFT);
break; break;
case ICON_CONFIG_FONT:
if (pointer->buttons == wimp_CLICK_ADJUST)
ro_gui_set_icon_selected_state(dialog_config,
ICON_CONFIG_FONT, true);
ro_gui_open_pane(dialog_config, dialog_config_font, 0);
break;
} }
} }
@ -635,6 +717,7 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
void ro_gui_save_options(void) void ro_gui_save_options(void)
{ {
nsfont_fill_nametable();
/* NCOS doesnt have the fancy Universal Boot vars; so select /* NCOS doesnt have the fancy Universal Boot vars; so select
* the path to the choices file based on the build options */ * the path to the choices file based on the build options */
#ifndef NCOS #ifndef NCOS
@ -655,54 +738,7 @@ void ro_gui_save_options(void)
void ro_gui_dialog_click_config_br(wimp_pointer *pointer) void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
{ {
int stepping = 1;
if (pointer->buttons == wimp_CLICK_ADJUST)
stepping = -stepping;
switch (pointer->i) { switch (pointer->i) {
case ICON_CONFIG_BR_FONTSIZE_DEC:
ro_gui_choices_font_size -= stepping;
if (ro_gui_choices_font_size < 50)
ro_gui_choices_font_size = 50;
if (ro_gui_choices_font_size > 1000)
ro_gui_choices_font_size = 1000;
if (ro_gui_choices_font_size <
ro_gui_choices_font_min_size)
ro_gui_choices_font_min_size =
ro_gui_choices_font_size;
ro_gui_dialog_update_config_br();
break;
case ICON_CONFIG_BR_FONTSIZE_INC:
ro_gui_choices_font_size += stepping;
if (ro_gui_choices_font_size < 50)
ro_gui_choices_font_size = 50;
if (ro_gui_choices_font_size > 1000)
ro_gui_choices_font_size = 1000;
ro_gui_dialog_update_config_br();
break;
case ICON_CONFIG_BR_MINSIZE_DEC:
ro_gui_choices_font_min_size -= stepping;
if (ro_gui_choices_font_min_size < 10)
ro_gui_choices_font_min_size = 10;
if (ro_gui_choices_font_min_size > 500)
ro_gui_choices_font_min_size = 500;
ro_gui_dialog_update_config_br();
break;
case ICON_CONFIG_BR_MINSIZE_INC:
ro_gui_choices_font_min_size += stepping;
if (ro_gui_choices_font_min_size < 10)
ro_gui_choices_font_min_size = 10;
if (ro_gui_choices_font_min_size > 500)
ro_gui_choices_font_min_size = 500;
if (ro_gui_choices_font_size <
ro_gui_choices_font_min_size)
ro_gui_choices_font_size =
ro_gui_choices_font_min_size;
ro_gui_dialog_update_config_br();
break;
case ICON_CONFIG_BR_LANG_PICK: case ICON_CONFIG_BR_LANG_PICK:
/* drop through */ /* drop through */
case ICON_CONFIG_BR_ALANG_PICK: case ICON_CONFIG_BR_ALANG_PICK:
@ -746,23 +782,6 @@ void ro_gui_dialog_languages_menu_selection(char *lang)
/* invalidate icon number and update window */ /* invalidate icon number and update window */
config_br_icon = -1; config_br_icon = -1;
ro_gui_dialog_update_config_br();
}
/**
* Update font size icons in browser choices pane.
*/
void ro_gui_dialog_update_config_br(void)
{
char s[10];
sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
ro_gui_choices_font_size % 10);
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s);
sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
ro_gui_choices_font_min_size % 10);
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s);
} }
@ -868,6 +887,162 @@ void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer) {
} }
} }
/**
* Update font size icons in font choices pane.
*/
void ro_gui_dialog_update_config_font(void)
{
char s[10];
sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
ro_gui_choices_font_size % 10);
ro_gui_set_icon_string(dialog_config_font,
ICON_CONFIG_FONT_FONTSIZE, s);
sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
ro_gui_choices_font_min_size % 10);
ro_gui_set_icon_string(dialog_config_font,
ICON_CONFIG_FONT_MINSIZE, s);
}
/**
* Handle clicks in the font choices pane
*/
void ro_gui_dialog_click_config_font(wimp_pointer *pointer)
{
int stepping = 1;
if (pointer->buttons == wimp_CLICK_ADJUST)
stepping = -stepping;
switch (pointer->i) {
case ICON_CONFIG_FONT_FONTSIZE_DEC:
ro_gui_choices_font_size -= stepping;
if (ro_gui_choices_font_size < 50)
ro_gui_choices_font_size = 50;
if (ro_gui_choices_font_size > 1000)
ro_gui_choices_font_size = 1000;
if (ro_gui_choices_font_size <
ro_gui_choices_font_min_size)
ro_gui_choices_font_min_size =
ro_gui_choices_font_size;
ro_gui_dialog_update_config_font();
break;
case ICON_CONFIG_FONT_FONTSIZE_INC:
ro_gui_choices_font_size += stepping;
if (ro_gui_choices_font_size < 50)
ro_gui_choices_font_size = 50;
if (ro_gui_choices_font_size > 1000)
ro_gui_choices_font_size = 1000;
ro_gui_dialog_update_config_font();
break;
case ICON_CONFIG_FONT_MINSIZE_DEC:
ro_gui_choices_font_min_size -= stepping;
if (ro_gui_choices_font_min_size < 10)
ro_gui_choices_font_min_size = 10;
if (ro_gui_choices_font_min_size > 500)
ro_gui_choices_font_min_size = 500;
ro_gui_dialog_update_config_font();
break;
case ICON_CONFIG_FONT_MINSIZE_INC:
ro_gui_choices_font_min_size += stepping;
if (ro_gui_choices_font_min_size < 10)
ro_gui_choices_font_min_size = 10;
if (ro_gui_choices_font_min_size > 500)
ro_gui_choices_font_min_size = 500;
if (ro_gui_choices_font_size <
ro_gui_choices_font_min_size)
ro_gui_choices_font_size =
ro_gui_choices_font_min_size;
ro_gui_dialog_update_config_font();
break;
case ICON_CONFIG_FONT_SANS_PICK:
case ICON_CONFIG_FONT_SERIF_PICK:
case ICON_CONFIG_FONT_MONO_PICK:
case ICON_CONFIG_FONT_CURS_PICK:
case ICON_CONFIG_FONT_FANT_PICK:
case ICON_CONFIG_FONT_DEF_PICK:
config_font_icon = pointer->i - 1;
ro_gui_display_font_menu(ro_gui_get_icon_string(
dialog_config_font, pointer->i - 1),
dialog_config_font, pointer->i);
break;
}
}
/**
* Handle font menu selections
*/
void ro_gui_dialog_font_menu_selection(char *name)
{
char *n, *fn;
int len;
if (strlen(name) <= 3 || config_font_icon < 0)
return;
n = name + 2; /* \F */
len = strcspn(n, "\\");
fn = calloc(len+1, sizeof(char));
if (!fn) {
LOG(("malloc failed"));
return;
}
strncpy(fn, n, len);
switch (config_font_icon) {
case ICON_CONFIG_FONT_SANS:
if (option_font_sans)
free(option_font_sans);
option_font_sans = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
case ICON_CONFIG_FONT_SERIF:
if (option_font_serif)
free(option_font_serif);
option_font_serif = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
case ICON_CONFIG_FONT_MONO:
if (option_font_mono)
free(option_font_mono);
option_font_mono = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
case ICON_CONFIG_FONT_CURS:
if (option_font_cursive)
free(option_font_cursive);
option_font_cursive = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
case ICON_CONFIG_FONT_FANT:
if (option_font_fantasy)
free(option_font_fantasy);
option_font_fantasy = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
case ICON_CONFIG_FONT_DEF:
if (option_font_default)
free(option_font_default);
option_font_default = strdup(fn);
ro_gui_set_icon_string(dialog_config_font,
config_font_icon, fn);
break;
}
free(fn);
config_font_icon = -1;
}
/** /**
* Handle clicks in the Scale view dialog. * Handle clicks in the Scale view dialog.

View File

@ -26,7 +26,9 @@
#include "netsurf/utils/log.h" #include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h" #include "netsurf/utils/utils.h"
#define FONT_FAMILIES 5 /* Number of families */ #define FONT_MAX_NAME 128 /* max length of a font name */
#define FONT_FAMILIES 6 /* Number of families */
#define FONT_FACES 8 /* Number of faces */ #define FONT_FACES 8 /* Number of faces */
/* Font Variants */ /* Font Variants */
@ -37,11 +39,12 @@
#define FONT_SLANTED 1 #define FONT_SLANTED 1
/* Font families */ /* Font families */
#define FONT_SANS_SERIF (0 * FONT_FACES) #define FONT_DEFAULT (0 * FONT_FACES)
#define FONT_SERIF (1 * FONT_FACES) #define FONT_SANS_SERIF (1 * FONT_FACES)
#define FONT_MONOSPACE (2 * FONT_FACES) #define FONT_SERIF (2 * FONT_FACES)
#define FONT_CURSIVE (3 * FONT_FACES) #define FONT_MONOSPACE (3 * FONT_FACES)
#define FONT_FANTASY (4 * FONT_FACES) #define FONT_CURSIVE (4 * FONT_FACES)
#define FONT_FANTASY (5 * FONT_FACES)
/* a font_set is just a linked list of font_data for each face for now */ /* a font_set is just a linked list of font_data for each face for now */
struct font_set { struct font_set {
@ -55,59 +58,69 @@ static os_error *nsfont_open_standard(const char *fontNameP, const char *fbFontN
* *
* font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted * font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted
* *
* font family: 0 = sans-serif, 1 = serif, 2 = monospace, 3 = cursive, * font family: 1 = sans-serif, 2 = serif, 3 = monospace, 4 = cursive,
* 4 = fantasy. * 5 = fantasy.
* Font family 0 must be available as it is the replacement font when * Font family 0 must be available as it is the replacement font when
* the other font families can not be found. * the other font families can not be found.
*/ */
static const char * const ufont_table[FONT_FAMILIES * FONT_FACES] = { static char ufont_table[FONT_FAMILIES * FONT_FACES][FONT_MAX_NAME] = {
/* sans-serif */ /* default */
/*0*/ "Homerton.Medium", /*0*/ "Homerton.Medium",
/*1*/ "Homerton.Medium.Oblique", /*1*/ "Homerton.Medium.Oblique",
/*2*/ "Homerton.Bold", /*2*/ "Homerton.Bold",
/*3*/ "Homerton.Bold.Oblique", /*3*/ "Homerton.Bold.Oblique",
"Homerton.Medium.SmallCaps",
"Homerton.Medium.Oblique.SmallCaps",
"Homerton.Bold.SmallCaps",
"Homerton.Bold.Oblique.SmallCaps",
/* sans-serif */
/*8*/ "Homerton.Medium",
/*9*/ "Homerton.Medium.Oblique",
/*10*/ "Homerton.Bold",
/*11*/ "Homerton.Bold.Oblique",
"Homerton.Medium.SmallCaps", "Homerton.Medium.SmallCaps",
"Homerton.Medium.Oblique.SmallCaps", "Homerton.Medium.Oblique.SmallCaps",
"Homerton.Bold.SmallCaps", "Homerton.Bold.SmallCaps",
"Homerton.Bold.Oblique.SmallCaps", "Homerton.Bold.Oblique.SmallCaps",
/* serif */ /* serif */
/*8*/ "Trinity.Medium", /*16*/ "Trinity.Medium",
/*9*/ "Trinity.Medium.Italic", /*17*/ "Trinity.Medium.Italic",
/*10*/ "Trinity.Bold", /*18*/ "Trinity.Bold",
/*11*/ "Trinity.Bold.Italic", /*19*/ "Trinity.Bold.Italic",
"Trinity.Medium.SmallCaps", "Trinity.Medium.SmallCaps",
"Trinity.Medium.Italic.SmallCaps", "Trinity.Medium.Italic.SmallCaps",
"Trinity.Bold.SmallCaps", "Trinity.Bold.SmallCaps",
"Trinity.Bold.Italic.SmallCaps", "Trinity.Bold.Italic.SmallCaps",
/* monospace */ /* monospace */
/*16*/ "Corpus.Medium", /*24*/ "Corpus.Medium",
/*17*/ "Corpus.Medium.Oblique", /*25*/ "Corpus.Medium.Oblique",
/*18*/ "Corpus.Bold", /*26*/ "Corpus.Bold",
/*19*/ "Corpus.Bold.Oblique", /*27*/ "Corpus.Bold.Oblique",
"Corpus.Medium.SmallCaps", "Corpus.Medium.SmallCaps",
"Corpus.Medium.Oblique.SmallCaps", "Corpus.Medium.Oblique.SmallCaps",
"Corpus.Bold.SmallCaps", "Corpus.Bold.SmallCaps",
"Corpus.Bold.Oblique.SmallCaps", "Corpus.Bold.Oblique.SmallCaps",
/* cursive */ /* cursive */
/*24*/ "Churchill.Medium", /*32*/ "Churchill.Medium",
/*25*/ "Churchill.Medium.Oblique", /*33*/ "Churchill.Medium.Oblique",
/*26*/ "Churchill.Bold", /*34*/ "Churchill.Bold",
/*27*/ "Churchill.Bold.Oblique", /*35*/ "Churchill.Bold.Oblique",
"Churchill.Medium.SmallCaps", "Churchill.Medium.SmallCaps",
"Churchill.Medium.Oblique.SmallCaps", "Churchill.Medium.Oblique.SmallCaps",
"Churchill.Bold.SmallCaps", "Churchill.Bold.SmallCaps",
"Churchill.Bold.Oblique.SmallCaps", "Churchill.Bold.Oblique.SmallCaps",
/* fantasy */ /* fantasy */
/*32*/ "Sassoon.Primary", /*40*/ "Sassoon.Primary",
/*33*/ "Sassoon.Primary.Oblique", /*41*/ "Sassoon.Primary.Oblique",
/*34*/ "Sassoon.Primary.Bold", /*42*/ "Sassoon.Primary.Bold",
/*35*/ "Sassoon.Primary.Bold.Oblique", /*43*/ "Sassoon.Primary.Bold.Oblique",
"Sassoon.Primary.SmallCaps", "Sassoon.Primary.SmallCaps",
"Sassoon.Primary.Oblique.SmallCaps", "Sassoon.Primary.Oblique.SmallCaps",
"Sassoon.Primary.Bold.SmallCaps", "Sassoon.Primary.Bold.SmallCaps",
"Sassoon.Primary.Bold.Oblique.SmallCaps", "Sassoon.Primary.Bold.Oblique.SmallCaps",
}; };
#if 0
/** Table of Latin1 encoded font names for a pre-UTF-8 capable FontManager. /** Table of Latin1 encoded font names for a pre-UTF-8 capable FontManager.
* *
* font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted * font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted
@ -164,6 +177,7 @@ static const char * const font_table[FONT_FAMILIES * FONT_FACES] = {
"Sassoon.Primary.Bold.SmallCaps\\ELatin1", "Sassoon.Primary.Bold.SmallCaps\\ELatin1",
"Sassoon.Primary.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0", "Sassoon.Primary.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
}; };
#endif
/** /**
* Create an empty font_set. * Create an empty font_set.
@ -279,8 +293,9 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
* If this still fails, we repeat the previous step but now using * If this still fails, we repeat the previous step but now using
* the Latin 1 encoding. * the Latin 1 encoding.
*/ */
if ((error = nsfont_open_ufont(ufont_table[f], ufont_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) { if (!option_font_ufont || (error = nsfont_open_ufont(ufont_table[f], ufont_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) {
char fontName1[128], fontName2[128]; char fontName1[FONT_MAX_NAME+10];
char fontName2[FONT_MAX_NAME+10];
/* Go for the UTF-8 encoding with standard FontManager */ /* Go for the UTF-8 encoding with standard FontManager */
strcpy(fontName1, ufont_table[f]); strcpy(fontName1, ufont_table[f]);
strcat(fontName1, "\\EUTF8"); strcat(fontName1, "\\EUTF8");
@ -288,7 +303,11 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
strcat(fontName2, "\\EUTF8"); strcat(fontName2, "\\EUTF8");
if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb)) != NULL) { if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb)) != NULL) {
/* All UTF-8 font methods failed, only support Latin 1 */ /* All UTF-8 font methods failed, only support Latin 1 */
if ((error = nsfont_open_standard(font_table[f], font_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) { strcpy(fontName1, ufont_table[f]);
strcat(fontName1, "\\ELatin1");
strcpy(fontName2, ufont_table[f % 4]);
strcat(fontName2, "\\ELatin1");
if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb)) != NULL) {
LOG(("(u)font_find_font failed : %s\n", error->errmess)); LOG(("(u)font_find_font failed : %s\n", error->errmess));
die("(u)font_find_font failed"); die("(u)font_find_font failed");
} }
@ -465,7 +484,7 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
break; break;
} }
if (error != NULL) { if (error != NULL) {
LOG(("(u)font_scan_string failed : %s\n", error->errmess)); LOG(("(u)font_scan_string failed : %s", error->errmess));
die("nsfont_width: (u)font_scan_string failed"); die("nsfont_width: (u)font_scan_string failed");
} }
@ -635,7 +654,7 @@ char *nsfont_split(struct font_data *font, const char *text,
die("nsfont_split: (u)font_scan_string failed"); die("nsfont_split: (u)font_scan_string failed");
} }
assert(split == &text[length] || *split == ' '); assert(split == &text[length] || *split == ' ' || *split == '\t');
*used_width = *used_width / 2 / 400; *used_width = *used_width / 2 / 400;
@ -739,6 +758,8 @@ void nsfont_txtenum(struct font_data *font, const char *text,
size_t *rolength, size_t *rolength,
size_t *consumed) size_t *consumed)
{ {
static char *fontname[FONT_MAX_NAME]; /** /todo: not nice */
assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL); assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL);
*rotext = *rofontname = NULL; *rotext = *rofontname = NULL;
@ -763,7 +784,6 @@ void nsfont_txtenum(struct font_data *font, const char *text,
*width /= 800; *width /= 800;
break; break;
case FONTTYPE_STANDARD_UTF8ENC: { case FONTTYPE_STANDARD_UTF8ENC: {
static char *fontname[128]; /** /todo: not nice */
int rowidth; int rowidth;
os_error *error; os_error *error;
@ -809,7 +829,9 @@ void nsfont_txtenum(struct font_data *font, const char *text,
return; return;
} }
*rolength = strlen(*rotext); *rolength = strlen(*rotext);
*rofontname = font_table[font->id]; strcpy(fontname, ufont_table[font->id]);
strcat(fontname, "\\ELatin1");
*rofontname = fontname;
*consumed = length; *consumed = length;
*width = (unsigned int)rowidth / 800; *width = (unsigned int)rowidth / 800;
break; break;
@ -819,3 +841,40 @@ void nsfont_txtenum(struct font_data *font, const char *text,
break; break;
} }
} }
/**
* Fill in the font_table, based on the user's options
*/
void nsfont_fill_nametable(void)
{
int i, j;
char *name = NULL;
for (i = 0; i != FONT_FAMILIES; i++) {
switch (i) {
case FONT_DEFAULT/FONT_FACES:
name = option_font_default;
break;
case FONT_SANS_SERIF/FONT_FACES:
name = option_font_sans;
break;
case FONT_SERIF/FONT_FACES:
name = option_font_serif;
break;
case FONT_MONOSPACE/FONT_FACES:
name = option_font_mono;
break;
case FONT_CURSIVE/FONT_FACES:
name = option_font_cursive;
break;
case FONT_FANTASY/FONT_FACES:
name = option_font_fantasy;
break;
}
for (j = 0; j != FONT_FACES; j++) {
/**\todo Bold, italic, smallcaps */
strncpy(ufont_table[FONT_FACES*i+j],
name, FONT_MAX_NAME);
}
}
}

View File

@ -176,7 +176,9 @@ void gui_init(int argc, char** argv)
xhourglass_start(1); xhourglass_start(1);
#ifdef WITH_SAVE_COMPLETE
save_complete_init(); save_complete_init();
#endif
/* We don't have the universal boot sequence on NCOS */ /* We don't have the universal boot sequence on NCOS */
#ifndef ncos #ifndef ncos
@ -215,6 +217,8 @@ void gui_init(int argc, char** argv)
#ifndef ncos #ifndef ncos
ro_gui_check_fonts(); ro_gui_check_fonts();
#endif #endif
nsfont_fill_nametable();
/* Issue a *Desktop to poke AcornURI into life */ /* Issue a *Desktop to poke AcornURI into life */
if (getenv("NetSurf$Start_URI_Handler")) if (getenv("NetSurf$Start_URI_Handler"))
xwimp_start_task("Desktop", 0); xwimp_start_task("Desktop", 0);
@ -1434,8 +1438,10 @@ void ro_gui_view_source(struct content *content)
void gui_launch_url(const char *url) void gui_launch_url(const char *url)
{ {
#ifdef WITH_URL
/* Try ant broadcast first */ /* Try ant broadcast first */
ro_url_broadcast(url); ro_url_broadcast(url);
#endif
} }

View File

@ -26,8 +26,9 @@ struct toolbar;
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br, extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo, dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
dialog_objinfo, dialog_tooltip, dialog_warning, dialog_config_th_pane, dialog_objinfo, dialog_tooltip, dialog_warning,
dialog_debug, dialog_folder, dialog_entry, dialog_search, dialog_print; dialog_config_th_pane, dialog_debug, dialog_folder, dialog_entry,
dialog_search, dialog_print, dialog_config_font;
extern wimp_w history_window; extern wimp_w history_window;
extern wimp_w hotlist_window; extern wimp_w hotlist_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu, extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu,
@ -117,6 +118,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning);
void ro_gui_prepare_navigate(struct gui_window *gui); void ro_gui_prepare_navigate(struct gui_window *gui);
void ro_gui_menu_prepare_scale(void); void ro_gui_menu_prepare_scale(void);
void ro_gui_menu_prepare_pageinfo(void); void ro_gui_menu_prepare_pageinfo(void);
void ro_gui_display_font_menu(const char *tick, wimp_w w, wimp_i i);
/* in dialog.c */ /* in dialog.c */
void ro_gui_dialog_init(void); void ro_gui_dialog_init(void);
@ -133,6 +135,7 @@ void ro_gui_menu_prepare_hotlist(void);
void ro_gui_dialog_open_config(void); void ro_gui_dialog_open_config(void);
void ro_gui_dialog_proxyauth_menu_selection(int item); void ro_gui_dialog_proxyauth_menu_selection(int item);
void ro_gui_dialog_languages_menu_selection(char *lang); void ro_gui_dialog_languages_menu_selection(char *lang);
void ro_gui_dialog_font_menu_selection(char *name);
/* in download.c */ /* in download.c */
void ro_gui_download_init(void); void ro_gui_download_init(void);
@ -284,19 +287,16 @@ bool ro_gui_print_keypress(wimp_key *key);
#define ICON_CONFIG_BROWSER 3 #define ICON_CONFIG_BROWSER 3
#define ICON_CONFIG_PROXY 4 #define ICON_CONFIG_PROXY 4
#define ICON_CONFIG_THEME 5 #define ICON_CONFIG_THEME 5
#define ICON_CONFIG_FONT 7
#define ICON_CONFIG_BR_FONTSIZE 1 #define ICON_CONFIG_BR_LANG 1
#define ICON_CONFIG_BR_FONTSIZE_DEC 2 #define ICON_CONFIG_BR_LANG_PICK 2
#define ICON_CONFIG_BR_FONTSIZE_INC 3 #define ICON_CONFIG_BR_ALANG 5
#define ICON_CONFIG_BR_MINSIZE 5 #define ICON_CONFIG_BR_ALANG_PICK 6
#define ICON_CONFIG_BR_MINSIZE_DEC 6 #define ICON_CONFIG_BR_HOMEPAGE 8
#define ICON_CONFIG_BR_MINSIZE_INC 7 #define ICON_CONFIG_BR_OPENBROWSER 9
#define ICON_CONFIG_BR_LANG 9 #define ICON_CONFIG_BR_BLOCKADS 10
#define ICON_CONFIG_BR_LANG_PICK 10 #define ICON_CONFIG_BR_PLUGINS 11
#define ICON_CONFIG_BR_ALANG 13
#define ICON_CONFIG_BR_ALANG_PICK 14
#define ICON_CONFIG_BR_HOMEPAGE 16
#define ICON_CONFIG_BR_OPENBROWSER 17
#define ICON_CONFIG_PROX_HTTP 0 #define ICON_CONFIG_PROX_HTTP 0
#define ICON_CONFIG_PROX_HTTPHOST 1 #define ICON_CONFIG_PROX_HTTPHOST 1
@ -309,6 +309,30 @@ bool ro_gui_print_keypress(wimp_key *key);
#define ICON_CONFIG_TH_GET 0 #define ICON_CONFIG_TH_GET 0
#define ICON_CONFIG_TH_MANAGE 1 #define ICON_CONFIG_TH_MANAGE 1
/* Note: The display icon numbers for font names *must* be ONE less
* than the icon number of the corresponding pick icon.
* This is assumed by ro_gui_dialog_click_font.
*/
#define ICON_CONFIG_FONT_SANS 2
#define ICON_CONFIG_FONT_SANS_PICK 3
#define ICON_CONFIG_FONT_SERIF 4
#define ICON_CONFIG_FONT_SERIF_PICK 5
#define ICON_CONFIG_FONT_MONO 6
#define ICON_CONFIG_FONT_MONO_PICK 7
#define ICON_CONFIG_FONT_CURS 8
#define ICON_CONFIG_FONT_CURS_PICK 9
#define ICON_CONFIG_FONT_FANT 10
#define ICON_CONFIG_FONT_FANT_PICK 11
#define ICON_CONFIG_FONT_DEF 12
#define ICON_CONFIG_FONT_DEF_PICK 13
#define ICON_CONFIG_FONT_FONTSIZE 14
#define ICON_CONFIG_FONT_FONTSIZE_DEC 15
#define ICON_CONFIG_FONT_FONTSIZE_INC 16
#define ICON_CONFIG_FONT_MINSIZE 17
#define ICON_CONFIG_FONT_MINSIZE_DEC 18
#define ICON_CONFIG_FONT_MINSIZE_INC 19
#define ICON_CONFIG_FONT_USE_UFONT 20
#define ICON_DOWNLOAD_ICON 0 #define ICON_DOWNLOAD_ICON 0
#define ICON_DOWNLOAD_URL 1 #define ICON_DOWNLOAD_URL 1
#define ICON_DOWNLOAD_PATH 2 #define ICON_DOWNLOAD_PATH 2

View File

@ -14,6 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "oslib/font.h"
#include "oslib/os.h" #include "oslib/os.h"
#include "oslib/osgbpb.h" #include "oslib/osgbpb.h"
#include "oslib/wimp.h" #include "oslib/wimp.h"
@ -55,6 +56,7 @@ static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
static void ro_gui_menu_object_reload(void); static void ro_gui_menu_object_reload(void);
static void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning); static void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning);
static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning); static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning);
static void ro_gui_font_menu_selection(wimp_selection *selection);
struct gui_window *current_gui; struct gui_window *current_gui;
wimp_menu *current_menu; wimp_menu *current_menu;
@ -402,6 +404,11 @@ wimp_menu *proxyauth_menu = (wimp_menu *) &proxy_menu;
*/ */
wimp_menu *languages_menu = NULL; wimp_menu *languages_menu = NULL;
/* Font popup menu (used in font choices dialog)
*/
static wimp_menu *font_menu = NULL;
static byte *font_menu_data = NULL;
static wimp_menu *browser_page_menu = (wimp_menu *)&page_menu; static wimp_menu *browser_page_menu = (wimp_menu *)&page_menu;
static wimp_menu *browser_export_menu = (wimp_menu *)&export_menu; static wimp_menu *browser_export_menu = (wimp_menu *)&export_menu;
static wimp_menu *browser_object_menu = (wimp_menu *)&object_menu; static wimp_menu *browser_object_menu = (wimp_menu *)&object_menu;
@ -975,6 +982,8 @@ void ro_gui_menu_selection(wimp_selection *selection)
} else if (current_menu == languages_menu) { } else if (current_menu == languages_menu) {
ro_gui_dialog_languages_menu_selection(languages_menu->entries[selection->items[0]].data.indirected_text.text); ro_gui_dialog_languages_menu_selection(languages_menu->entries[selection->items[0]].data.indirected_text.text);
} else if (current_menu == font_menu) {
ro_gui_font_menu_selection(selection);
} }
if (pointer.buttons == wimp_CLICK_ADJUST) { if (pointer.buttons == wimp_CLICK_ADJUST) {
@ -1077,8 +1086,10 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
break; break;
case 5: /* Print -> */ case 5: /* Print -> */
#ifdef WITH_PRINT
ro_gui_print_open(current_gui, warning->pos.x, ro_gui_print_open(current_gui, warning->pos.x,
warning->pos.y, true, false); warning->pos.y, true, false);
#endif
break; break;
} }
break; break;
@ -1193,11 +1204,13 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
warning->pos.x, warning->pos.y); warning->pos.x, warning->pos.y);
break; break;
case 2: /* Find text -> */ case 2: /* Find text -> */
#ifdef WITH_SEARCH
ro_gui_search_open(current_gui, ro_gui_search_open(current_gui,
warning->pos.x, warning->pos.x,
warning->pos.y, warning->pos.y,
true, true,
false); false);
#endif
break; break;
} }
break; break;
@ -1792,3 +1805,90 @@ void gui_create_form_select_menu(struct browser_window *bw,
ro_gui_create_menu(gui_form_select_menu, ro_gui_create_menu(gui_form_select_menu,
pointer.pos.x, pointer.pos.y, bw->window); pointer.pos.x, pointer.pos.y, bw->window);
} }
/**
* Create and display a menu listing all fonts present in the system.
*
* \param tick The name of the currently selected font
* \param w The dialog containing the clicked icon
* \param i The clicked icon.
*/
void ro_gui_display_font_menu(const char *tick, wimp_w w, wimp_i i)
{
int size1, size2;
os_error *error;
error = xfont_list_fonts(0, font_RETURN_FONT_MENU | font_GIVEN_TICK,
0, 0, 0, tick, 0, &size1, &size2);
if (error) {
LOG(("xfont_list_fonts: 0x%x: %s",
error->errnum, error->errmess));
return;
}
/* free previous menu */
if (font_menu)
free(font_menu);
if (font_menu_data)
free(font_menu_data);
font_menu = calloc(size1, sizeof(byte));
if (!font_menu) {
LOG(("malloc failed"));
return;
}
font_menu_data = calloc(size2, sizeof(byte));
if (!font_menu_data) {
LOG(("malloc failed"));
return;
}
error = xfont_list_fonts((byte*)font_menu,
font_RETURN_FONT_MENU | font_GIVEN_TICK,
size1, font_menu_data, size2, tick, 0, 0, 0);
if (error) {
LOG(("xfont_list_fonts: 0x%x: %s",
error->errnum, error->errmess));
return;
}
ro_gui_popup_menu(font_menu, w, i);
}
/**
* Handle a selection in the font menu
*
* \param selection The selection block
*/
void ro_gui_font_menu_selection(wimp_selection *selection)
{
int buf_size;
char *buf;
os_error *error;
error = xfont_decode_menu(0, (byte*)font_menu, (byte*)selection,
0, 0, 0, &buf_size);
if (error) {
LOG(("xfont_decode_menu: 0x%x: %s",
error->errnum, error->errmess));
return;
}
buf = calloc(buf_size, sizeof(char));
if (!buf) {
LOG(("malloc failed"));
return;
}
error = xfont_decode_menu(0, (byte*)font_menu, (byte*)selection,
buf, buf_size, 0, 0);
if (error) {
LOG(("xfont_decode_menu: 0x%x: %s",
error->errnum, error->errmess));
return;
}
ro_gui_dialog_font_menu_selection(buf);
free(buf);
}

View File

@ -47,7 +47,14 @@ extern bool option_buffer_animations;
extern bool option_buffer_everything; extern bool option_buffer_everything;
extern char *option_homepage_url; extern char *option_homepage_url;
extern bool option_open_browser_at_startup; extern bool option_open_browser_at_startup;
extern bool option_plugins; extern bool option_no_plugins;
extern char *option_font_sans;
extern char *option_font_serif;
extern char *option_font_mono;
extern char *option_font_cursive;
extern char *option_font_fantasy;
extern char *option_font_default;
extern bool option_font_ufont;
#define EXTRA_OPTION_DEFINE \ #define EXTRA_OPTION_DEFINE \
bool option_use_mouse_gestures = false;\ bool option_use_mouse_gestures = false;\
@ -81,7 +88,14 @@ bool option_buffer_animations = true; \
bool option_buffer_everything = false; \ bool option_buffer_everything = false; \
char *option_homepage_url = 0; \ char *option_homepage_url = 0; \
bool option_open_browser_at_startup = false; \ bool option_open_browser_at_startup = false; \
bool option_plugins = false; bool option_no_plugins = true; \
char *option_font_sans = 0; \
char *option_font_serif = 0; \
char *option_font_mono = 0; \
char *option_font_cursive = 0; \
char *option_font_fantasy = 0; \
char *option_font_default = 0; \
bool option_font_ufont = false;
#define EXTRA_OPTION_TABLE \ #define EXTRA_OPTION_TABLE \
{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\ { "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
@ -115,5 +129,13 @@ bool option_plugins = false;
{ "buffer_everything", OPTION_BOOL, &option_buffer_everything }, \ { "buffer_everything", OPTION_BOOL, &option_buffer_everything }, \
{ "homepage_url", OPTION_STRING, &option_homepage_url }, \ { "homepage_url", OPTION_STRING, &option_homepage_url }, \
{ "open_browser_at_startup",OPTION_BOOL, &option_open_browser_at_startup }, \ { "open_browser_at_startup",OPTION_BOOL, &option_open_browser_at_startup }, \
{ "plugins", OPTION_BOOL, &option_plugins } { "no_plugins", OPTION_BOOL, &option_no_plugins }, \
{ "font_sans", OPTION_STRING, &option_font_sans }, \
{ "font_serif", OPTION_STRING, &option_font_serif }, \
{ "font_mono", OPTION_STRING, &option_font_mono }, \
{ "font_cursive", OPTION_STRING, &option_font_cursive }, \
{ "font_fantasy", OPTION_STRING, &option_font_fantasy }, \
{ "font_default", OPTION_STRING, &option_font_default }, \
{ "font_ufont", OPTION_BOOL, &option_font_ufont}
#endif #endif