summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--amiga/font.c19
-rwxr-xr-xamiga/font.h7
-rw-r--r--amiga/font_scan.c50
-rwxr-xr-xamiga/font_scan.h3
-rwxr-xr-xamiga/gui_options.c34
5 files changed, 90 insertions, 23 deletions
diff --git a/amiga/font.c b/amiga/font.c
index 877093b4c..8be407612 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -782,10 +782,25 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
return x;
}
+void ami_font_initscanner(bool force, bool save)
+{
+ ami_font_scan_init(nsoption_charp(font_unicode_file), force, save, glypharray);
+}
+
+void ami_font_finiscanner(void)
+{
+ ami_font_scan_fini(glypharray);
+}
+
+void ami_font_savescanner(void)
+{
+ ami_font_scan_save(nsoption_charp(font_unicode_file), glypharray);
+}
+
void ami_init_fonts(void)
{
/* Initialise Unicode font scanner */
- ami_font_scan_init(nsoption_charp(font_unicode_file), false, glypharray);
+ ami_font_initscanner(false, true);
/* Initialise font caching etc lists */
ami_font_list = NewObjList();
@@ -800,7 +815,7 @@ void ami_close_fonts(void)
LOG(("Cleaning up font cache"));
FreeObjList(ami_font_list);
ami_font_list = NULL;
- ami_font_scan_fini(glypharray);
+ ami_font_finiscanner();
}
void ami_font_close(struct ami_font_node *node)
diff --git a/amiga/font.h b/amiga/font.h
index da1e68044..36bdbf9ef 100755
--- a/amiga/font.h
+++ b/amiga/font.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2008,2009 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2008, 2009, 2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -32,6 +32,11 @@ void ami_init_fonts(void);
void ami_close_fonts(void);
void ami_font_close(struct ami_font_node *node);
+/* Alternate entry points into font_scan */
+void ami_font_initscanner(bool force, bool save);
+void ami_font_finiscanner(void);
+void ami_font_savescanner(void);
+
/* Simple diskfont functions for graphics.library use (not page rendering) */
struct TextFont *ami_font_open_disk_font(struct TextAttr *tattr);
void ami_font_close_disk_font(struct TextFont *tfont);
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index 5ad0ea9d1..8b919b18f 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -82,14 +82,35 @@ struct ami_font_scan_window *ami_font_scan_gui_open(int32 fonts)
}
/**
+ * Update GUI showing font scanning progress
+ *
+ * \param win pointer to a struct ami_font_scan_window
+ * \param font current font being scanned
+ * \param font_num font number being scanned
+ * \param glyphs number of unique glyphs found
+ */
+void ami_font_scan_gui_update(struct ami_font_scan_window *win, const char *font,
+ ULONG font_num, ULONG glyphs)
+{
+ if(win) {
+ // RefreshSetGadgetAttrs() etc
+ } else {
+ printf("Found %ld glyphs\n", glyphs);
+ printf("Scanning font #%ld (%s)...\n", font_num, font);
+ }
+}
+
+/**
* Close GUI showing font scanning progress
*
* \param win pointer to a struct ami_font_scan_window
*/
void ami_font_scan_gui_close(struct ami_font_scan_window *win)
{
- DisposeObject(win->objects[FS_OID_MAIN]);
- FreeVec(win);
+ if(win) {
+ DisposeObject(win->objects[FS_OID_MAIN]);
+ FreeVec(win);
+ }
}
/**
@@ -143,9 +164,10 @@ ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
* \param glypharray an array of 0xffff lwc_string pointers
* \return number of glyphs found
*/
-ULONG ami_font_scan_fonts(struct MinList *list, lwc_string **glypharray)
+ULONG ami_font_scan_fonts(struct MinList *list,
+ struct ami_font_scan_window *win, lwc_string **glypharray)
{
- ULONG found, total = 0;
+ ULONG found, total = 0, font_num = 0;
struct nsObject *node;
struct nsObject *nnode;
@@ -155,16 +177,16 @@ ULONG ami_font_scan_fonts(struct MinList *list, lwc_string **glypharray)
do {
nnode = (struct nsObject *)GetSucc((struct Node *)node);
- printf("Scanning %s...\n", node->dtz_Node.ln_Name);
+ ami_font_scan_gui_update(win, node->dtz_Node.ln_Name, font_num, total);
+ LOG(("Scanning %s\n", node->dtz_Node.ln_Name));
found = ami_font_scan_font(node->dtz_Node.ln_Name, glypharray);
total += found;
- printf("Found %ld new glyphs (total = %ld)\n", found, total);
+ LOG(("Found %ld new glyphs (total = %ld)\n", found, total));
} while(node = nnode);
return total;
}
-
/**
* Add OS fonts to a list.
*
@@ -179,7 +201,6 @@ ULONG ami_font_scan_list(struct MinList *list)
ULONG found = 0;
struct nsObject *node;
- printf("Scanning fonts...\n");
do {
if(afh = (struct AvailFontsHeader *)AllocVec(afSize, MEMF_PRIVATE)) {
if(afShortage = AvailFonts(afh, afSize, AFF_DISK | AFF_OTAG | AFF_SCALED)) {
@@ -194,7 +215,6 @@ ULONG ami_font_scan_list(struct MinList *list)
if(afh) {
af = (struct AvailFonts *)&(afh[1]);
-printf("af = %lx entries = %ld\n", af, afh->afh_NumEntries);
for(i = 0; i < afh->afh_NumEntries; i++) {
if(af[i].af_Attr.ta_Style == FS_NORMAL) {
@@ -205,7 +225,7 @@ printf("af = %lx entries = %ld\n", af, afh->afh_NumEntries);
if(node) {
node->dtz_Node.ln_Name = strdup(af[i].af_Attr.ta_Name);
found++;
- printf("Added %s\n", af[i].af_Attr.ta_Name);
+ LOG(("Added %s\n", af[i].af_Attr.ta_Name));
}
}
}
@@ -326,13 +346,14 @@ void ami_font_scan_fini(lwc_string **glypharray)
* \param force_scan force re-creation of cache
* \param glypharray an array of 0xffff lwc_string pointers
*/
-void ami_font_scan_init(const char *filename, bool force_scan,
+void ami_font_scan_init(const char *filename, bool force_scan, bool save,
lwc_string **glypharray)
{
ULONG i, found = 0, entries = 0;
struct MinList *list;
struct nsObject *node;
char *unicode_font;
+ struct ami_font_scan_window *win = NULL;
/* Ensure array zeroed */
for(i=0x0000; i<=0xffff; i++)
@@ -355,12 +376,13 @@ void ami_font_scan_init(const char *filename, bool force_scan,
if(nsoption_bool(font_unicode_only) == false)
entries += ami_font_scan_list(list);
- printf("Found %ld fonts\n", entries);
+ LOG(("Found %ld fonts\n", entries));
- found = ami_font_scan_fonts(list, glypharray);
+ found = ami_font_scan_fonts(list, win, glypharray);
FreeObjList(list);
- ami_font_scan_save(filename, glypharray);
+ if(save == true)
+ ami_font_scan_save(filename, glypharray);
}
}
diff --git a/amiga/font_scan.h b/amiga/font_scan.h
index 62dfced2e..24649854c 100755
--- a/amiga/font_scan.h
+++ b/amiga/font_scan.h
@@ -21,9 +21,10 @@
#include <libwapcaplet/libwapcaplet.h>
-void ami_font_scan_init(const char *filename, bool force_scan,
+void ami_font_scan_init(const char *filename, bool force_scan, bool save,
lwc_string **glypharray);
void ami_font_scan_fini(lwc_string **glypharray);
+void ami_font_scan_save(const char *filename, lwc_string **glypharray);
const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray);
#endif
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index cdaa04912..ee973fd48 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 - 2011 Chris Young <chris@unsatisfactorysoftware.co.uk>
+ * Copyright 2009 - 2012 Chris Young <chris@unsatisfactorysoftware.co.uk>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -1404,12 +1404,18 @@ void ami_gui_opts_open(void)
}
}
-void ami_gui_opts_use(void)
+void ami_gui_opts_use(bool save)
{
ULONG data, id = 0;
float animspeed;
struct TextAttr *tattr;
char *dot;
+ bool rescan_fonts = false;
+
+ SetWindowPointer(gow->win,
+ WA_BusyPointer, TRUE,
+ WA_PointerDelay, TRUE,
+ TAG_DONE);
GetAttr(STRINGA_TextVal,gow->objects[GID_OPTS_HOMEPAGE],(ULONG *)&data);
nsoption_set_charp(homepage_url, (char *)strdup((char *)data));
@@ -1572,6 +1578,11 @@ void ami_gui_opts_use(void)
tattr = (struct TextAttr *)data;
if(dot = strrchr(tattr->ta_Name,'.')) *dot = '\0';
+
+ if(strcmp(tattr->ta_Name, nsoption_charp(font_unicode)) != 0) {
+ rescan_fonts = true;
+ }
+
nsoption_set_charp(font_unicode, (char *)strdup((char *)tattr->ta_Name));
GetAttr(CHOOSER_Selected,gow->objects[GID_OPTS_FONT_DEFAULT],(ULONG *)&nsoption_int(font_default));
@@ -1709,6 +1720,20 @@ void ami_gui_opts_use(void)
} else {
nsoption_set_bool(enable_PDF_password, false);
}
+
+ if(rescan_fonts == true) {
+ ami_font_finiscanner();
+ ami_font_initscanner(true, false);
+ }
+
+ if(save == true) {
+ nsoption_write(current_user_options);
+ ami_font_savescanner(); /* just in case it has changed and been used only */
+ }
+
+ SetWindowPointer(gow->win,
+ WA_Pointer, NULL,
+ TAG_DONE);
}
void ami_gui_opts_close(void)
@@ -1739,14 +1764,13 @@ BOOL ami_gui_opts_event(void)
switch(result & WMHI_GADGETMASK)
{
case GID_OPTS_SAVE:
- ami_gui_opts_use();
- nsoption_write(current_user_options);
+ ami_gui_opts_use(true);
ami_gui_opts_close();
return TRUE;
break;
case GID_OPTS_USE:
- ami_gui_opts_use();
+ ami_gui_opts_use(false);
// fall through
case GID_OPTS_CANCEL: