30#include <proto/bullet.h>
32#include <proto/diskfont.h>
34#include <proto/exec.h>
35#include <proto/intuition.h>
36#include <diskfont/diskfonttag.h>
37#include <diskfont/oterrors.h>
39#include <proto/window.h>
40#include <proto/layout.h>
41#include <proto/fuelgauge.h>
42#include <classes/window.h>
43#include <gadgets/fuelgauge.h>
44#include <gadgets/layout.h>
46#include <reaction/reaction_macros.h>
84 if(*code >= 0xd800 && *code <= 0xdbff) {
90 else return lwc_string_data(
glypharray[*code]);
104 if(fsw == NULL)
return NULL;
111 WA_Title, fsw->
title,
113 WA_DepthGadget, TRUE,
115 WA_CloseGadget, FALSE,
118 WA_BusyPointer, TRUE,
120 WINDOW_UserData, fsw,
121 WINDOW_IconifyGadget, FALSE,
122 WINDOW_Position, WPOS_CENTERSCREEN,
123 WINDOW_LockHeight, TRUE,
129 FUELGAUGE_Max, fonts,
132 FUELGAUGE_ShortTicks, TRUE,
133 FUELGAUGE_Percent, FALSE,
134 FUELGAUGE_Justification, FGJ_CENTER,
136 CHILD_NominalSize, TRUE,
137 CHILD_WeightedHeight, 0,
141 FUELGAUGE_Min, 0x0000,
142 FUELGAUGE_Max, 0xffff,
145 FUELGAUGE_ShortTicks, TRUE,
146 FUELGAUGE_Percent, FALSE,
147 FUELGAUGE_Justification, FGJ_CENTER,
149 CHILD_NominalSize, TRUE,
150 CHILD_WeightedHeight, 0,
168 ULONG font_num, ULONG glyphs)
175 FUELGAUGE_Level, font_num,
185 FUELGAUGE_VarArgs, va,
186 FUELGAUGE_Level, glyphs,
189 printf(
"Found %ld glyphs\n", glyphs);
190 printf(
"Scanning font #%ld (%s)...\n", font_num, font);
218 struct MinList *widthlist = NULL;
219 struct GlyphWidthEntry *gwnode;
220 ULONG foundglyphs = 0;
222 ULONG unicoderanges = 0;
229 struct BulletBase *BulletBase = ofont->
BulletBase;
233 OT_PointHeight, 10 * (1 << 16),
234 OT_GlyphCode, 0x0000,
235 OT_GlyphCode2, 0xffff,
236 TAG_END) == OTERR_Success)
239 OT_WidthList, &widthlist,
242 gwnode = (
struct GlyphWidthEntry *)
GetHead((
struct List *)widthlist);
244 if(gwnode && (
glypharray[gwnode->gwe_Code] == NULL)) {
245 lerror = lwc_intern_string(fontname, strlen(fontname), &
glypharray[gwnode->gwe_Code]);
246 if(lerror != lwc_error_ok)
continue;
249 }
while((gwnode = (
struct GlyphWidthEntry *)
GetSucc((
struct Node *)gwnode)));
251 OT_WidthList, widthlist,
257 if(unicoderanges & UCR_SURROGATES) {
258 NSLOG(netsurf, INFO,
"%s supports UTF-16 surrogates",
265 OT_UnicodeRanges, unicoderanges,
285 ULONG found, total = 0, font_num = 0;
299 NSLOG(netsurf, INFO,
"Found %ld new glyphs (total = %ld)",
302 }
while((node = nnode));
315 int afShortage, afSize = 100;
316 struct AvailFontsHeader *afh;
317 struct AvailFonts *af;
322 if((afh = (
struct AvailFontsHeader *)malloc(afSize))) {
323 if(((afShortage = AvailFonts((STRPTR)afh, afSize,
324 AFF_DISK |
AFF_OTAG | AFF_SCALED)))) {
326 afSize += afShortage;
332 }
while (afShortage);
335 af = (
struct AvailFonts *)&(afh[1]);
337 for(
int i = 0; i < afh->afh_NumEntries; i++) {
338 if(af[i].af_Attr.ta_Style == FS_NORMAL) {
339 if(af[i].af_Attr.ta_Name != NULL) {
341 if((p = strrchr(af[i].af_Attr.ta_Name,
'.'))) *p =
'\0';
343 af[i].af_Attr.ta_Name);
347 node->
dtz_Node.ln_Name = strdup(af[i].af_Attr.ta_Name);
351 af[i].af_Attr.ta_Name);
377 struct RDArgs *rargs = NULL;
378 CONST_STRPTR
template =
"CODE/A,FONT/A";
379 long rarray[] = {0,0};
386 rargs = AllocDosObjectTags(DOS_RDARGS, TAG_DONE);
388 if((fh =
FOpen(filename, MODE_OLDFILE, 0))) {
389 NSLOG(netsurf, INFO,
"Loading font glyph cache from %s",
392 while(FGets(fh, (STRPTR)&
buffer, 256) != 0)
394 rargs->RDA_Source.CS_Buffer = (
char *)&
buffer;
395 rargs->RDA_Source.CS_Length = 256;
396 rargs->RDA_Source.CS_CurChr = 0;
398 rargs->RDA_DAList = NULL;
399 rargs->RDA_Buffer = NULL;
400 rargs->RDA_BufSiz = 0;
401 rargs->RDA_ExtHelp = NULL;
402 rargs->RDA_Flags = 0;
404 if(ReadArgs(
template, rarray, rargs))
406 lerror = lwc_intern_string((
const char *)rarray[A_FONT],
407 strlen((
const char *)rarray[A_FONT]),
408 &
glypharray[strtoul((
const char *)rarray[A_CODE], NULL, 0)]);
409 if(lerror != lwc_error_ok)
continue;
430 if((fh =
FOpen(filename, MODE_NEWFILE, 0))) {
431 NSLOG(netsurf, INFO,
"Writing font glyph cache to %s",
433 FPrintf(fh,
"; This file is auto-generated. To re-create the cache, delete this file.\n");
434 FPrintf(fh,
"; This file is parsed using ReadArgs() with the following template:\n");
435 FPrintf(fh,
"; CODE/A,FONT/A\n;\n");
437 for(i=0x0000; i<=0xffff; i++)
440 FPrintf(fh,
"0x%04lx \"%s\"\n", i, lwc_string_data(
glypharray[i]));
456 for(i=0x0000; i<=0xffff; i++)
477 ULONG i, found = 0, entries = 0;
478 struct MinList *list;
484 for(i=0x0000; i<=0xffff; i++)
487 if(force_scan ==
false)
491 NSLOG(netsurf, INFO,
"Creating new font glyph cache");
500 while((p =
strsep(&csv,
","))) {
503 if(node) node->
dtz_Node.ln_Name = strdup(p);
513 NSLOG(netsurf, INFO,
"Found %ld fonts", entries);
526 NSLOG(netsurf, INFO,
"Initialised with %ld glyphs", found);
struct Screen * ami_gui_get_screen(void)
Get a pointer to the screen NetSurf is running on.
STRPTR ami_gui_get_screen_title(void)
Get the string for NetSurf's screen titlebar.
static osspriteop_area * buffer
The buffer characteristics.
static lwc_string * glypharray[0xffff+1]
static struct ami_font_scan_window * ami_font_scan_gui_open(int32 fonts)
Open GUI to show font scanning progress.
const char * ami_font_scan_lookup(const uint16 *code, lwc_string **glypharray)
Lookup a font that contains a UTF-16 codepoint.
static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
Scan a font for glyphs not present in glypharray.
void ami_font_scan_init(const char *filename, bool force_scan, bool save, lwc_string **glypharray)
Initialise the font glyph cache.
static ULONG ami_font_scan_load(const char *filename, lwc_string **glypharray)
Load a font glyph cache.
void ami_font_scan_save(const char *filename, lwc_string **glypharray)
Save a font glyph cache.
static void ami_font_scan_gui_update(struct ami_font_scan_window *fsw, const char *font, ULONG font_num, ULONG glyphs)
Update GUI showing font scanning progress.
static ULONG ami_font_scan_list(struct MinList *list)
Add OS fonts to a list.
void ami_font_scan_fini(lwc_string **glypharray)
Finalise the font glyph cache.
static ULONG ami_font_scan_fonts(struct MinList *list, struct ami_font_scan_window *win, lwc_string **glypharray)
Scan all fonts for glyphs.
static void ami_font_scan_gui_close(struct ami_font_scan_window *fsw)
Close GUI showing font scanning progress.
struct MinList * NewObjList(void)
void FreeObjList(struct MinList *objlist)
struct nsObject * AddObject(struct MinList *objlist, ULONG otype)
void ami_utf8_free(char *ptr)
char * ami_utf8_easy(const char *string)
Core mouse and pointer states.
Interface to platform-specific graphical user interface window operations.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
void CloseOutlineFont(struct OutlineFont *of, struct List *list)
struct OutlineFont * OpenOutlineFont(STRPTR fileName, struct List *list, ULONG flags)
char * strsep(char **s1, const char *s2)
struct Node * GetHead(struct List *list)
ULONG RefreshSetGadgetAttrs(struct Gadget *g, struct Window *w, struct Requester *r, Tag tag1,...)
struct Node * GetSucc(struct Node *node)
Minimal compatibility header for AmigaOS 3.
#define IsMinListEmpty(L)
Interface to utility string handling.
struct BulletBase * BulletBase
Object * objects[FS_GID_LAST]
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
#define nsoption_bool(OPTION)
Get the value of a boolean option.