mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-26 22:09:43 +03:00
[project @ 2004-04-09 21:06:10 by bursa]
Add FixFonts to attempt to fix common font problem. svn path=/import/netsurf/; revision=741
This commit is contained in:
parent
9de746e0a0
commit
e90e01cd49
147
!NetSurf/FixFonts,ffb
Normal file
147
!NetSurf/FixFonts,ffb
Normal file
@ -0,0 +1,147 @@
|
||||
REM Attempt to fix broken font installations which have non-Base0 copies of the
|
||||
REM ROM fonts in !Fonts on disc.
|
||||
|
||||
ON ERROR ON ERROR OFF: PRINT REPORT$ + " (at line " + STR$ERL + ")": END
|
||||
|
||||
DIM f$(11)
|
||||
f$() = "Corpus.Bold","Corpus.Bold.Oblique","Corpus.Medium","Corpus.Medium.Oblique","Homerton.Bold","Homerton.Bold.Oblique","Homerton.Medium","Homerton.Medium.Oblique","Trinity.Bold","Trinity.Bold.Italic","Trinity.Medium","Trinity.Medium.Italic"
|
||||
|
||||
PRINT "FONT INSTALLATION FIX"
|
||||
PRINT
|
||||
|
||||
PRINT "Checking ROM fonts"
|
||||
PRINT
|
||||
ok% = TRUE
|
||||
FOR f% = 0 TO 11
|
||||
PROCcheck_rom_font(f$(f%))
|
||||
NEXT
|
||||
PRINT
|
||||
IF NOT ok% THEN
|
||||
PRINT "One or more of the standard ROM fonts are missing!"
|
||||
PRINT "Please contact the developers stating your RISC OS version."
|
||||
END
|
||||
ENDIF
|
||||
|
||||
|
||||
PRINT "Searching for obsolete copies in Boot:Resources.!Fonts"
|
||||
PRINT
|
||||
ok% = TRUE
|
||||
FOR f% = 0 TO 11
|
||||
PROCcheck_disc_font(f$(f%))
|
||||
NEXT
|
||||
PRINT
|
||||
IF ok% THEN
|
||||
PRINT "No problems were found."
|
||||
END
|
||||
ENDIF
|
||||
|
||||
PRINT "One or more obsolete fonts were found in !Fonts."
|
||||
PRINT
|
||||
PRINT "Press Y to move these fonts to a new directory"
|
||||
PRINT "called 'ObsolFonts' and remove them from the"
|
||||
PRINT "font list ('Messages1'),"
|
||||
PRINT "or any other key to exit without changes."
|
||||
key$ = GET$
|
||||
IF INSTR("Yy", key$) = 0 THEN
|
||||
PRINT
|
||||
PRINT "Exiting without changes."
|
||||
END
|
||||
ENDIF
|
||||
PRINT
|
||||
|
||||
PRINT "Creating 'ObsolFonts' directory - ";
|
||||
SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts"
|
||||
PRINT "done"
|
||||
PRINT
|
||||
PRINT "Closing open files - ";
|
||||
SYS"OS_FSControl", 22
|
||||
PRINT "done"
|
||||
PRINT
|
||||
PRINT "Removing fonts from font list - ";
|
||||
file% = OPENIN "<Boot$Dir>.Resources.!Fonts.Messages1"
|
||||
IF file% THEN
|
||||
new% = OPENOUT "<Boot$Dir>.Resources.!Fonts.Messages_"
|
||||
IF new% = 0 THEN
|
||||
PRINT "Failed to open new font list"
|
||||
END
|
||||
ENDIF
|
||||
WHILE NOT EOF#file%
|
||||
line$ = GET$#file%
|
||||
ok% = TRUE
|
||||
FOR f% = 0 TO 11
|
||||
IF INSTR(line$, "Font_" + f$(f%) + ":") <> 0 THEN ok% = FALSE
|
||||
NEXT
|
||||
IF ok% THEN
|
||||
BPUT#new%, line$
|
||||
ENDIF
|
||||
ENDWHILE
|
||||
CLOSE#file%
|
||||
CLOSE#new%
|
||||
SYS"OS_File", 18, "<Boot$Dir>.Resources.!Fonts.Messages_", &fff
|
||||
SYS"XOS_FSControl", 27, "<Boot$Dir>.^.ObsolFonts.Messages1"
|
||||
SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages1", "<Boot$Dir>.^.ObsolFonts.Messages1"
|
||||
SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts.Messages_", "<Boot$Dir>.Resources.!Fonts.Messages1"
|
||||
ENDIF
|
||||
PRINT "done"
|
||||
PRINT
|
||||
PRINT "Moving away obsolete fonts"
|
||||
PRINT
|
||||
FOR f% = 0 TO 11
|
||||
PROCfix_font(f$(f%))
|
||||
NEXT
|
||||
PRINT
|
||||
PRINT "Finished"
|
||||
PRINT "Please restart your machine for the changes to take effect."
|
||||
|
||||
END
|
||||
|
||||
|
||||
|
||||
DEF PROCcheck_rom_font(f$)
|
||||
PRINT " "; f$;
|
||||
SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".Outlines0" TO t1%
|
||||
SYS"OS_File", 17, "Resources:$.Fonts." + f$ + ".IntMetric0" TO t2%
|
||||
IF t1% = 1 AND t2% = 1 THEN
|
||||
PRINT " - ok"
|
||||
ELSE
|
||||
PRINT " - MISSING"
|
||||
ok% = FALSE
|
||||
ENDIF
|
||||
ENDPROC
|
||||
|
||||
|
||||
|
||||
DEF PROCcheck_disc_font(f$)
|
||||
SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
|
||||
IF t% <> 0 THEN
|
||||
PRINT " "; f$
|
||||
ok% = FALSE
|
||||
ENDIF
|
||||
ENDPROC
|
||||
|
||||
|
||||
|
||||
DEF PROCfix_font(f$)
|
||||
SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines" TO t%
|
||||
IF t% = 0 THEN ENDPROC
|
||||
|
||||
PRINT " "; f$; " - ";
|
||||
i% = 0
|
||||
REPEAT
|
||||
i% = INSTR(f$, ".", i% + 1)
|
||||
IF i% <> 0 THEN
|
||||
SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + LEFT$(f$, i% - 1)
|
||||
ENDIF
|
||||
UNTIL i% = 0
|
||||
SYS"OS_File", 8, "<Boot$Dir>.^.ObsolFonts." + f$
|
||||
|
||||
SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".Outlines", "<Boot$Dir>.^.ObsolFonts." + f$ + ".Outlines"
|
||||
|
||||
SYS"OS_File", 17, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics" TO t%
|
||||
IF t% <> 0 THEN
|
||||
SYS"OS_FSControl", 25, "<Boot$Dir>.Resources.!Fonts." + f$ + ".IntMetrics", "<Boot$Dir>.^.ObsolFonts." + f$ + ".IntMetrics"
|
||||
ENDIF
|
||||
|
||||
PRINT "done"
|
||||
ENDPROC
|
||||
|
@ -49,6 +49,8 @@ ErrorPage:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T
|
||||
InvalidURL:The address <em>%s</em> could not be understood.
|
||||
|
||||
NoMemory:NetSurf is running out of memory. Please free some memory and try again.
|
||||
FontBadInst:An error occurred when initialising fonts due to the presence of obsolete copies of the ROM fonts on disc. NetSurf will exit and launch a program which will attempt to fix this.
|
||||
FontError:Failed to open font "Homerton.Medium" (%s).
|
||||
|
||||
Loading:Opening page...
|
||||
RecPercent:Received %lu of %lu bytes (%u%%)
|
||||
|
@ -49,6 +49,8 @@ ErrorPage:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/T
|
||||
InvalidURL:L'adresse <em>%s</em> est incomprise.
|
||||
|
||||
NoMemory:NetSurf a besoin de plus de mémoire. Veuillez libérer de la mémoire et réessayer.
|
||||
FontBadInst:An error occurred when initialising fonts due to the presence of obsolete copies of the ROM fonts on disc. NetSurf will exit and launch a program which will attempt to fix this.
|
||||
FontError:Failed to open font "Homerton.Medium" (%s).
|
||||
|
||||
Loading:Ouverture de la page...
|
||||
RecPercent:%lu reçus de %lu octès (%u%%)
|
||||
|
87
riscos/gui.c
87
riscos/gui.c
@ -15,6 +15,7 @@
|
||||
#include <time.h>
|
||||
#include <unixlib/features.h>
|
||||
#include <unixlib/local.h>
|
||||
#include "oslib/font.h"
|
||||
#include "oslib/hourglass.h"
|
||||
#include "oslib/inetsuite.h"
|
||||
#include "oslib/os.h"
|
||||
@ -111,7 +112,8 @@ struct ro_gui_poll_block *ro_gui_poll_queued_blocks = 0;
|
||||
|
||||
|
||||
static void ro_gui_choose_language(void);
|
||||
static void ro_gui_pointers_init(const char *filename);
|
||||
static void ro_gui_check_fonts(void);
|
||||
static void ro_gui_pointers_init(void);
|
||||
static void ro_gui_icon_bar_create(void);
|
||||
static void ro_gui_handle_event(wimp_event_no event, wimp_block *block);
|
||||
static void ro_gui_poll_queue(wimp_event_no event, wimp_block* block);
|
||||
@ -143,20 +145,15 @@ void gui_init(int argc, char** argv)
|
||||
|
||||
xhourglass_start(1);
|
||||
|
||||
LOG(("reading choices"));
|
||||
options_read("Choices:WWW.NetSurf.Choices");
|
||||
|
||||
LOG(("choosing language"));
|
||||
ro_gui_choose_language();
|
||||
|
||||
NETSURF_DIR = getenv("NetSurf$Dir");
|
||||
sprintf(path, "<NetSurf$Dir>.Resources.%s.Messages", option_language);
|
||||
LOG(("Loading messages from '%s'", path));
|
||||
messages_load(path);
|
||||
messages_load("<NetSurf$Dir>.Resources.LangNames");
|
||||
|
||||
LOG(("done"));
|
||||
|
||||
error = xwimp_initialise(wimp_VERSION_RO38, "NetSurf",
|
||||
(wimp_message_list*) &task_messages, 0,
|
||||
&task_handle);
|
||||
@ -166,6 +163,8 @@ void gui_init(int argc, char** argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ro_gui_check_fonts();
|
||||
|
||||
/* Issue a *Desktop to poke AcornURI into life */
|
||||
if (getenv("NetSurf$Start_URI_Handler"))
|
||||
xwimp_start_task("Desktop", 0);
|
||||
@ -199,7 +198,7 @@ void gui_init(int argc, char** argv)
|
||||
#endif
|
||||
ro_gui_history_init();
|
||||
wimp_close_template();
|
||||
ro_gui_pointers_init("<NetSurf$Dir>.Resources.Pointers");
|
||||
ro_gui_pointers_init();
|
||||
ro_gui_icon_bar_create();
|
||||
}
|
||||
|
||||
@ -258,21 +257,64 @@ void ro_gui_choose_language(void)
|
||||
option_accept_language = strdup(option_language);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise pointer sprite area
|
||||
* Check that at least Homerton.Medium is available.
|
||||
*/
|
||||
void ro_gui_pointers_init(const char *filename)
|
||||
|
||||
void ro_gui_check_fonts(void)
|
||||
{
|
||||
FILE *fp;
|
||||
unsigned int len;
|
||||
char s[252];
|
||||
font_f font;
|
||||
os_error *error;
|
||||
|
||||
error = xfont_find_font("Homerton.Medium\\ELatin1",
|
||||
160, 160, 0, 0, &font, 0, 0);
|
||||
if (error) {
|
||||
if (error->errnum == error_FILE_NOT_FOUND) {
|
||||
warn_user("FontBadInst");
|
||||
xwimp_start_task("TaskWindow -wimpslot 200K -quit "
|
||||
"<NetSurf$Dir>.FixFonts", 0);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
snprintf(s, sizeof s, messages_get("FontError"),
|
||||
error->errmess);
|
||||
die(s);
|
||||
}
|
||||
}
|
||||
|
||||
error = xfont_lose_font(font);
|
||||
if (error) {
|
||||
snprintf(s, sizeof s, messages_get("FontError"),
|
||||
error->errmess);
|
||||
die(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise pointer sprite area.
|
||||
*/
|
||||
|
||||
void ro_gui_pointers_init(void)
|
||||
{
|
||||
int len;
|
||||
fileswitch_object_type obj_type;
|
||||
os_error *e;
|
||||
|
||||
fp = fopen(filename, "rb");
|
||||
if (!fp) return;
|
||||
fseek(fp, 0, SEEK_END);
|
||||
len = ftell(fp);
|
||||
fclose(fp);
|
||||
pointers = xcalloc(len+4, sizeof(char));
|
||||
e = xosfile_read_stamped_no_path("<NetSurf$Dir>.Resources.Pointers",
|
||||
&obj_type, 0, 0, &len, 0, 0);
|
||||
if (e) {
|
||||
LOG(("xosfile_read_stamped_no_path: 0x%x: %s",
|
||||
e->errnum, e->errmess));
|
||||
die(e->errmess);
|
||||
}
|
||||
if (obj_type != fileswitch_IS_FILE)
|
||||
die("<NetSurf$Dir>.Resources.Pointers missing.");
|
||||
|
||||
pointers = malloc(len + 4);
|
||||
if (!pointers)
|
||||
die("NoMemory");
|
||||
|
||||
pointers->size = len+4;
|
||||
pointers->sprite_count = 0;
|
||||
@ -280,10 +322,15 @@ void ro_gui_pointers_init(const char *filename)
|
||||
pointers->used = 16;
|
||||
|
||||
e = xosspriteop_load_sprite_file(osspriteop_USER_AREA,
|
||||
pointers, filename);
|
||||
if (e) xfree(pointers);
|
||||
pointers, "<NetSurf$Dir>.Resources.Pointers");
|
||||
if (e) {
|
||||
LOG(("xosspriteop_load_sprite_file: 0x%x: %s",
|
||||
e->errnum, e->errmess));
|
||||
die(e->errmess);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an iconbar icon.
|
||||
*/
|
||||
@ -307,7 +354,7 @@ void ro_gui_icon_bar_create(void)
|
||||
void gui_quit(void)
|
||||
{
|
||||
ro_gui_history_quit();
|
||||
xfree(pointers);
|
||||
free(pointers);
|
||||
wimp_close_down(task_handle);
|
||||
xhourglass_off();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user