From d5608581b926a28d738451ed7617354cbdaf4f7e Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 5 May 2012 15:58:17 +0000 Subject: Integrate Unicode font scanner into NetSurf. NetSurf will now use any available font when trying to print characters that are missing from the current font. TODO: Preferred font list. svn path=/trunk/netsurf/; revision=13905 --- amiga/font_scan.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'amiga/font_scan.c') diff --git a/amiga/font_scan.c b/amiga/font_scan.c index e9b4c7711..d5e84e7be 100644 --- a/amiga/font_scan.c +++ b/amiga/font_scan.c @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -29,10 +30,22 @@ #include #include -#include - +#include "amiga/font_scan.h" #include "amiga/object.h" +/** + * Lookup a font that contains a UTF-16 codepoint + * + * \param code UTF-16 codepoint to lookup + * \param glypharray an array of 0xffff lwc_string pointers + * \return font name or NULL + */ +const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray) +{ + if(glypharray[code] == NULL) return NULL; + else return lwc_string_data(glypharray[code]); +} + /** * Scan a font for glyphs not present in glypharray. * @@ -51,7 +64,7 @@ ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray) ofont = OpenOutlineFont(fontname, NULL, OFF_OPEN); - if(!ofont) return; + if(!ofont) return 0; if(ESetInfo(&ofont->olf_EEngine, OT_PointHeight, 10 * (1 << 16), @@ -202,7 +215,7 @@ ULONG ami_font_scan_load(const char *filename, lwc_string **glypharray) { lerror = lwc_intern_string((const char *)rarray[A_FONT], strlen((const char *)rarray[A_FONT]), - &glypharray[strtoul(rarray[A_CODE], NULL, 0)]); + &glypharray[strtoul((const char *)rarray[A_CODE], NULL, 0)]); if(lerror != lwc_error_ok) continue; found++; } @@ -226,7 +239,7 @@ void ami_font_scan_save(const char *filename, lwc_string **glypharray) if(fh = FOpen(filename, MODE_NEWFILE, 0)) { printf("Writing %s\n", filename); - FPrintf(fh, "; This file is auto-generated. To recreate the cache, delete this file.\n"); + 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"); @@ -234,7 +247,6 @@ void ami_font_scan_save(const char *filename, lwc_string **glypharray) { if(glypharray[i]) { FPrintf(fh, "0x%04lx \"%s\"\n", i, lwc_string_data(glypharray[i])); - lwc_string_unref(glypharray[i]); } } FClose(fh); @@ -302,12 +314,11 @@ int main(int argc, char** argv) printf("%s\n",argv[1]); list = NewObjList(); - ami_font_scan_init(argv[1], list, glypharray); - ami_font_scan_fini(glypharray); - FreeObjList(list); + ami_font_scan_fini(glypharray); + return 0; } -- cgit v1.2.3