mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-02-08 18:44:28 +03:00
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
This commit is contained in:
parent
2f7061b894
commit
7003f6932e
11
amiga/font.c
11
amiga/font.c
@ -416,8 +416,8 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
|
|||||||
break;
|
break;
|
||||||
case NSA_UNICODE_FONT:
|
case NSA_UNICODE_FONT:
|
||||||
default:
|
default:
|
||||||
fontname = ami_font_scan_lookup(codepoint, glypharray);
|
fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
|
||||||
printf("FONT::: %s\n", fontname);
|
if(fontname == NULL) return NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,13 +784,8 @@ ULONG ami_unicode_text(struct RastPort *rp,const char *string,ULONG length,const
|
|||||||
|
|
||||||
void ami_init_fonts(void)
|
void ami_init_fonts(void)
|
||||||
{
|
{
|
||||||
struct MinList *list;
|
|
||||||
|
|
||||||
/* Initialise Unicode font scanner */
|
/* Initialise Unicode font scanner */
|
||||||
list = NewObjList();
|
ami_font_scan_init(nsoption_charp(font_unicode_file), false, glypharray);
|
||||||
/** TODO: add font_unicode and other preferred fonts to the list here */
|
|
||||||
ami_font_scan_init(nsoption_charp(font_unicode_file), list, glypharray);
|
|
||||||
FreeObjList(list);
|
|
||||||
|
|
||||||
/* Initialise font caching etc lists */
|
/* Initialise font caching etc lists */
|
||||||
ami_font_list = NewObjList();
|
ami_font_list = NewObjList();
|
||||||
|
@ -27,12 +27,36 @@
|
|||||||
#include <proto/diskfont.h>
|
#include <proto/diskfont.h>
|
||||||
#include <proto/dos.h>
|
#include <proto/dos.h>
|
||||||
#include <proto/exec.h>
|
#include <proto/exec.h>
|
||||||
|
#include <proto/intuition.h>
|
||||||
#include <diskfont/diskfonttag.h>
|
#include <diskfont/diskfonttag.h>
|
||||||
#include <diskfont/oterrors.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/font_scan.h"
|
||||||
#include "amiga/object.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
|
* Lookup a font that contains a UTF-16 codepoint
|
||||||
*
|
*
|
||||||
@ -46,6 +70,28 @@ const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray)
|
|||||||
else return lwc_string_data(glypharray[code]);
|
else return lwc_string_data(glypharray[code]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Scan a font for glyphs not present in glypharray.
|
||||||
*
|
*
|
||||||
@ -130,7 +176,7 @@ ULONG ami_font_scan_list(struct MinList *list)
|
|||||||
int afShortage, afSize = 100, i;
|
int afShortage, afSize = 100, i;
|
||||||
struct AvailFontsHeader *afh;
|
struct AvailFontsHeader *afh;
|
||||||
struct AvailFonts *af;
|
struct AvailFonts *af;
|
||||||
ULONG found;
|
ULONG found = 0;
|
||||||
struct nsObject *node;
|
struct nsObject *node;
|
||||||
|
|
||||||
printf("Scanning fonts...\n");
|
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);
|
rargs = AllocDosObjectTags(DOS_RDARGS, TAG_DONE);
|
||||||
|
|
||||||
if(fh = FOpen(filename, MODE_OLDFILE, 0)) {
|
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)
|
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;
|
BPTR fh = 0;
|
||||||
|
|
||||||
if(fh = FOpen(filename, MODE_NEWFILE, 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 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, "; This file is parsed using ReadArgs() with the following template:\n");
|
||||||
FPrintf(fh, "; CODE/A,FONT/A\n;\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.
|
* Reads an existing file or, if not present, generates a new cache.
|
||||||
*
|
*
|
||||||
* \param filename cache file to attempt to read
|
* \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
|
* \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 */
|
/* Ensure array zeroed */
|
||||||
for(i=0x0000; i<=0xffff; i++)
|
for(i=0x0000; i<=0xffff; i++)
|
||||||
glypharray[i] = NULL;
|
glypharray[i] = NULL;
|
||||||
|
|
||||||
found = ami_font_scan_load(filename, glypharray);
|
if(force_scan == false)
|
||||||
|
found = ami_font_scan_load(filename, glypharray);
|
||||||
|
|
||||||
if(found == 0) {
|
if(found == 0) {
|
||||||
ffound = ami_font_scan_list(list);
|
if(list = NewObjList()) {
|
||||||
printf("Found %ld system fonts\n", ffound);
|
|
||||||
found = ami_font_scan_fonts(list, glypharray);
|
/* add preferred font */
|
||||||
ami_font_scan_save(filename, glypharray);
|
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
|
#ifdef AMI_FONT_SCAN_STANDALONE
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <libwapcaplet/libwapcaplet.h>
|
#include <libwapcaplet/libwapcaplet.h>
|
||||||
|
|
||||||
void ami_font_scan_init(const char *filename, struct MinList *list,
|
void ami_font_scan_init(const char *filename, bool force_scan,
|
||||||
lwc_string **glypharray);
|
lwc_string **glypharray);
|
||||||
void ami_font_scan_fini(lwc_string **glypharray);
|
void ami_font_scan_fini(lwc_string **glypharray);
|
||||||
const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray);
|
const char *ami_font_scan_lookup(uint16 code, lwc_string **glypharray);
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
bool close_no_quit; \
|
bool close_no_quit; \
|
||||||
bool hide_docky_icon; \
|
bool hide_docky_icon; \
|
||||||
char *font_unicode; \
|
char *font_unicode; \
|
||||||
char *font_unicode_file; \
|
char *font_unicode_file; \
|
||||||
|
bool font_unicode_only; \
|
||||||
bool drag_save_icons; \
|
bool drag_save_icons; \
|
||||||
int hotlist_window_xpos; \
|
int hotlist_window_xpos; \
|
||||||
int hotlist_window_ypos; \
|
int hotlist_window_ypos; \
|
||||||
@ -113,6 +114,7 @@
|
|||||||
.hide_docky_icon = false, \
|
.hide_docky_icon = false, \
|
||||||
.font_unicode = NULL, \
|
.font_unicode = NULL, \
|
||||||
.font_unicode_file = NULL, \
|
.font_unicode_file = NULL, \
|
||||||
|
.font_unicode_only = false, \
|
||||||
.drag_save_icons = true, \
|
.drag_save_icons = true, \
|
||||||
.hotlist_window_xpos = 0, \
|
.hotlist_window_xpos = 0, \
|
||||||
.hotlist_window_ypos = 0, \
|
.hotlist_window_ypos = 0, \
|
||||||
@ -169,6 +171,7 @@
|
|||||||
{ "hide_docky_icon", OPTION_BOOL, &nsoptions.hide_docky_icon}, \
|
{ "hide_docky_icon", OPTION_BOOL, &nsoptions.hide_docky_icon}, \
|
||||||
{ "font_unicode", OPTION_STRING, &nsoptions.font_unicode }, \
|
{ "font_unicode", OPTION_STRING, &nsoptions.font_unicode }, \
|
||||||
{ "font_unicode_file", OPTION_STRING, &nsoptions.font_unicode_file }, \
|
{ "font_unicode_file", OPTION_STRING, &nsoptions.font_unicode_file }, \
|
||||||
|
{ "font_unicode_only", OPTION_BOOL, &nsoptions.font_unicode_only }, \
|
||||||
{ "drag_save_icons", OPTION_BOOL, &nsoptions.drag_save_icons}, \
|
{ "drag_save_icons", OPTION_BOOL, &nsoptions.drag_save_icons}, \
|
||||||
{ "hotlist_window_xpos", OPTION_INTEGER, &nsoptions.hotlist_window_xpos}, \
|
{ "hotlist_window_xpos", OPTION_INTEGER, &nsoptions.hotlist_window_xpos}, \
|
||||||
{ "hotlist_window_ypos", OPTION_INTEGER, &nsoptions.hotlist_window_ypos}, \
|
{ "hotlist_window_ypos", OPTION_INTEGER, &nsoptions.hotlist_window_ypos}, \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user