[project @ 2004-11-03 02:29:01 by rjw]

Changing screenmodes causes font handles to be refound.

svn path=/import/netsurf/; revision=1338
This commit is contained in:
Richard Wilson 2004-11-03 02:29:01 +00:00
parent ce0fc3daf7
commit 3276fe3ed8
6 changed files with 103 additions and 8 deletions

View File

@ -49,5 +49,6 @@ void nsfont_txtenum(struct font_data *font, const char *text,
size_t *rolength,
size_t *consumed);
void nsfont_fill_nametable(bool force_rescan);
void nsfont_reopen_set(struct font_set *fonts);
#endif

View File

@ -1,7 +1,7 @@
/*
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
* http://www.opensource.org/licenses/gpl-license
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
@ -30,7 +30,7 @@
#define FONT_MAX_NAME 128 /* max length of a font name */
#define FONT_FAMILIES 6 /* Number of families */
#define FONT_FACES 4 /* Number of faces per family */
#define FONT_FACES 4 /* Number of faces per family */
/* Font Variants */
#define FONT_SMALLCAPS 4
@ -40,12 +40,12 @@
#define FONT_SLANTED 1
/* Font families */
#define FONT_DEFAULT (0 * FONT_FACES)
#define FONT_DEFAULT (0 * FONT_FACES)
#define FONT_SANS_SERIF (1 * FONT_FACES)
#define FONT_SERIF (2 * FONT_FACES)
#define FONT_SERIF (2 * FONT_FACES)
#define FONT_MONOSPACE (3 * FONT_FACES)
#define FONT_CURSIVE (4 * FONT_FACES)
#define FONT_FANTASY (5 * 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 */
struct font_set {
@ -1180,3 +1180,70 @@ char *nsfont_create_font_name(char *base, int id)
free(created);
return NULL;
}
/**
* Reopens all font handles to the current screen resolution
*/
void nsfont_reopen_set(struct font_set *fonts) {
os_error *error;
char fontName1[FONT_MAX_NAME+10];
char fontName2[FONT_MAX_NAME+10];
struct font_data *f;
bool using_fb;
for (int i = 0; i < (FONT_FAMILIES * FONT_FACES); i++) {
for (f = fonts->font[i]; f; f = f->next) {
switch (f->ftype) {
case FONTTYPE_UFONT:
error = xufont_lose_font((ufont_f)f->handle);
if (error) {
LOG(("xufont_lose_font: 0x%x: %s",
error->errnum, error->errmess));
}
error = nsfont_open_ufont(fontName1, fontName2, (int)f->size,
&f->handle, &using_fb, true);
if (error) {
LOG(("nsfont_open_standard: 0x%x: %s",
error->errnum, error->errmess));
}
break;
case FONTTYPE_STANDARD_LATIN1:
error = xfont_lose_font((font_f)f->handle);
if (error) {
LOG(("xfont_lose_font: 0x%x: %s",
error->errnum, error->errmess));
}
strcpy(fontName1, font_table[f->id]);
strcat(fontName1, "\\ELatin1");
strcpy(fontName2, font_table[f->id % 4]);
strcat(fontName2, "\\ELatin1");
error = nsfont_open_standard(fontName1, fontName2, (int)f->size,
&f->handle, &using_fb, true);
if (error) {
LOG(("nsfont_open_standard: 0x%x: %s",
error->errnum, error->errmess));
}
break;
case FONTTYPE_STANDARD_UTF8ENC:
error = xfont_lose_font((font_f)f->handle);
if (error) {
LOG(("xfont_lose_font: 0x%x: %s",
error->errnum, error->errmess));
}
strcpy(fontName1, font_table[f->id]);
strcat(fontName1, "\\EUTF8");
strcpy(fontName2, font_table[f->id % 4]);
strcat(fontName2, "\\EUTF8");
error = nsfont_open_standard(fontName1, fontName2, (int)f->size,
&f->handle, &using_fb, true);
if (error) {
LOG(("nsfont_open_standard: 0x%x: %s",
error->errnum, error->errmess));
}
break;
}
f->space_width = nsfont_width(f, " ", sizeof(" ")-1);
}
}
}

View File

@ -87,7 +87,7 @@ static clock_t gui_last_poll; /**< Time of last wimp_poll. */
osspriteop_area *gui_sprites; /**< Sprite area containing pointer and hotlist sprites */
/** Accepted wimp user messages. */
static wimp_MESSAGE_LIST(33) task_messages = { {
static wimp_MESSAGE_LIST(34) task_messages = { {
message_HELP_REQUEST,
message_DATA_SAVE,
message_DATA_SAVE_ACK,
@ -96,6 +96,7 @@ static wimp_MESSAGE_LIST(33) task_messages = { {
message_DATA_OPEN,
message_MENU_WARNING,
message_MENUS_DELETED,
message_MODE_CHANGE,
#ifdef WITH_URI
message_URI_PROCESS,
message_URI_RETURN_RESULT,
@ -996,6 +997,7 @@ void ro_gui_keypress(wimp_key *key)
void ro_gui_user_message(wimp_event_no event, wimp_message *message)
{
struct content *c;
switch (message->action) {
case message_HELP_REQUEST:
ro_gui_interactive_help_request(message);
@ -1036,6 +1038,14 @@ void ro_gui_user_message(wimp_event_no event, wimp_message *message)
ro_gui_hotlist_menu_closed();
}
break;
case message_MODE_CHANGE:
ro_gui_history_mode_change();
for (c = content_list; c; c = c->next) {
if ((c->type == CONTENT_HTML) &&
(c->data.html.fonts))
nsfont_reopen_set(c->data.html.fonts);
}
break;
#ifdef WITH_URI
case message_URI_PROCESS:

View File

@ -194,6 +194,7 @@ void ro_gui_window_redraw_all(void);
/* in history.c */
void ro_gui_history_init(void);
void ro_gui_history_quit(void);
void ro_gui_history_mode_change(void);
void ro_gui_history_open(struct browser_window *bw,
struct history *history, int wx, int wy);
void ro_gui_history_redraw(wimp_draw *redraw);

View File

@ -272,6 +272,15 @@ void ro_gui_history_quit(void)
}
/**
* Update resources folowing a mode change
*/
void ro_gui_history_mode_change(void)
{
font_lose_font(history_font);
history_font = font_find_font("Homerton.Medium", 112, 128, 0, 0, 0, 0);
}
/**
* Open history window.
*/
@ -415,7 +424,7 @@ void ro_gui_history_redraw_tree(struct history_entry *he,
(char *)(header),
x0 + he->x * FULL_WIDTH + MARGIN,
y0 - he->y * FULL_HEIGHT - FULL_HEIGHT + MARGIN,
tinct_ERROR_DIFFUSE);
tinct_ERROR_DIFFUSE | tinct_BILINEAR_FILTER);
} else {
unsigned int size;
os_factors factors;

View File

@ -20,6 +20,7 @@
#include "oslib/osspriteop.h"
#include "netsurf/content/content.h"
#include "netsurf/desktop/plotters.h"
#include "netsurf/render/font.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/thumbnail.h"
@ -106,9 +107,15 @@ void thumbnail_create(struct content *content, osspriteop_area *area,
colourtrans_set_gcol(os_COLOUR_WHITE, colourtrans_SET_BG,
os_ACTION_OVERWRITE, 0);
os_clg();
if ((content->type == CONTENT_HTML) &&
(content->data.html.fonts))
nsfont_reopen_set(content->data.html.fonts);
content_redraw(content, 0, 0, width, height,
0, 0, width, height, scale, 0xFFFFFF);
thumbnail_restore_output(save_area);
if ((content->type == CONTENT_HTML) &&
(content->data.html.fonts))
nsfont_reopen_set(content->data.html.fonts);
/* Go back from 32bpp to [n]bpp if we should.
*/