summaryrefslogtreecommitdiff
path: root/amiga/font_scan.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2012-05-05 19:09:42 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2012-05-05 19:09:42 +0000
commit7003f6932efd8a118acbd30fba85e15bd76238dd (patch)
tree3fc9c5a8ee2828213249001ff953f2fea78c2391 /amiga/font_scan.c
parent2f7061b894af10797003eaa37a3fb8c3aeeaf079 (diff)
downloadnetsurf-7003f6932efd8a118acbd30fba85e15bd76238dd.tar.gz
netsurf-7003f6932efd8a118acbd30fba85e15bd76238dd.tar.bz2
Use font_unicode option as preferred (first scanned) font. Ideally need to
expand this so multiple fonts can be specified. Allow disabling of scanning other fonts. Add stubs for a scanning progress GUI. svn path=/trunk/netsurf/; revision=13907
Diffstat (limited to 'amiga/font_scan.c')
-rw-r--r--amiga/font_scan.c91
1 files changed, 80 insertions, 11 deletions
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index d5e84e7be..5ad0ea9d1 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -27,12 +27,36 @@
#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h>
+#include <proto/intuition.h>
#include <diskfont/diskfonttag.h>
#include <diskfont/oterrors.h>
+#include <proto/window.h>
+#include <proto/layout.h>
+#include <proto/fuelgauge.h>
+#include <classes/window.h>
+#include <gadgets/fuelgauge.h>
+#include <gadgets/layout.h>
+
#include "amiga/font_scan.h"
#include "amiga/object.h"
+#include "desktop/options.h"
+#include "utils/log.h"
+
+enum {
+ FS_OID_MAIN = 0,
+ FS_GID_MAIN,
+ FS_GID_FONTS,
+ FS_GID_GLYPHS,
+ FS_GID_LAST
+};
+
+struct ami_font_scan_window {
+ struct Window *win;
+ Object *objects[FS_GID_LAST];
+};
+
/**
* Lookup a font that contains a UTF-16 codepoint
*
@@ -47,6 +71,28 @@ const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray)
}
/**
+ * Open GUI to show font scanning progress
+ *
+ * \param fonts number of fonts that are being scanned
+ * \return pointer to a struct ami_font_scan_window
+ */
+struct ami_font_scan_window *ami_font_scan_gui_open(int32 fonts)
+{
+ return NULL;
+}
+
+/**
+ * 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);
+}
+
+/**
* Scan a font for glyphs not present in glypharray.
*
* \param fontname font to scan
@@ -130,7 +176,7 @@ ULONG ami_font_scan_list(struct MinList *list)
int afShortage, afSize = 100, i;
struct AvailFontsHeader *afh;
struct AvailFonts *af;
- ULONG found;
+ ULONG found = 0;
struct nsObject *node;
printf("Scanning fonts...\n");
@@ -197,7 +243,7 @@ ULONG ami_font_scan_load(const char *filename, lwc_string **glypharray)
rargs = AllocDosObjectTags(DOS_RDARGS, TAG_DONE);
if(fh = FOpen(filename, MODE_OLDFILE, 0)) {
- printf("Reading %s\n", filename);
+ LOG(("Loading font glyph cache from %s", filename));
while(FGets(fh, (UBYTE *)&buffer, 256) != 0)
{
@@ -238,7 +284,7 @@ void ami_font_scan_save(const char *filename, lwc_string **glypharray)
BPTR fh = 0;
if(fh = FOpen(filename, MODE_NEWFILE, 0)) {
- printf("Writing %s\n", filename);
+ LOG(("Writing font glyph cache to %s", filename));
FPrintf(fh, "; This file is auto-generated. To re-create the cache, delete this file.\n");
FPrintf(fh, "; This file is parsed using ReadArgs() with the following template:\n");
FPrintf(fh, "; CODE/A,FONT/A\n;\n");
@@ -276,26 +322,49 @@ void ami_font_scan_fini(lwc_string **glypharray)
* Reads an existing file or, if not present, generates a new cache.
*
* \param filename cache file to attempt to read
+ * \param entries number of entries in list
+ * \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, struct MinList *list, lwc_string **glypharray)
+void ami_font_scan_init(const char *filename, bool force_scan,
+ lwc_string **glypharray)
{
- ULONG i, found, ffound;
+ ULONG i, found = 0, entries = 0;
+ struct MinList *list;
+ struct nsObject *node;
+ char *unicode_font;
/* Ensure array zeroed */
for(i=0x0000; i<=0xffff; i++)
glypharray[i] = NULL;
- found = ami_font_scan_load(filename, glypharray);
+ if(force_scan == false)
+ found = ami_font_scan_load(filename, glypharray);
if(found == 0) {
- ffound = ami_font_scan_list(list);
- printf("Found %ld system fonts\n", ffound);
- found = ami_font_scan_fonts(list, glypharray);
- ami_font_scan_save(filename, glypharray);
+ if(list = NewObjList()) {
+
+ /* add preferred font */
+ asprintf(&unicode_font, "%s.font", nsoption_charp(font_unicode));
+ if(unicode_font != NULL) {
+ node = AddObject(list, AMINS_UNKNOWN);
+ if(node) node->dtz_Node.ln_Name = unicode_font;
+ entries = 1;
+ }
+
+ if(nsoption_bool(font_unicode_only) == false)
+ entries += ami_font_scan_list(list);
+
+ printf("Found %ld fonts\n", entries);
+
+ found = ami_font_scan_fonts(list, glypharray);
+ FreeObjList(list);
+
+ ami_font_scan_save(filename, glypharray);
+ }
}
- printf("Initialised with %ld glyphs\n", found);
+ LOG(("Initialised with %ld glyphs", found));
}
#ifdef AMI_FONT_SCAN_STANDALONE