NetSurf
Data Structures | Enumerations | Functions
font_scan.c File Reference

Font glyph scanner for Unicode substitutions. More...

#include "amiga/os3support.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <proto/bullet.h>
#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 <reaction/reaction_macros.h>
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "netsurf/mouse.h"
#include "netsurf/window.h"
#include "amiga/font_scan.h"
#include "amiga/gui.h"
#include "amiga/libs.h"
#include "amiga/object.h"
#include "amiga/utf8.h"
Include dependency graph for font_scan.c:

Go to the source code of this file.

Data Structures

struct  ami_font_scan_window
 

Enumerations

enum  {
  FS_OID_MAIN = 0 , FS_GID_MAIN , FS_GID_FONTS , FS_GID_GLYPHS ,
  FS_GID_LAST
}
 

Functions

const char * ami_font_scan_lookup (const uint16 *code, lwc_string **glypharray)
 Lookup a font that contains a UTF-16 codepoint. More...
 
static struct ami_font_scan_windowami_font_scan_gui_open (int32 fonts)
 Open GUI to show font scanning progress. More...
 
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. More...
 
static void ami_font_scan_gui_close (struct ami_font_scan_window *fsw)
 Close GUI showing font scanning progress. More...
 
static ULONG ami_font_scan_font (const char *fontname, lwc_string **glypharray)
 Scan a font for glyphs not present in glypharray. More...
 
static ULONG ami_font_scan_fonts (struct MinList *list, struct ami_font_scan_window *win, lwc_string **glypharray)
 Scan all fonts for glyphs. More...
 
static ULONG ami_font_scan_list (struct MinList *list)
 Add OS fonts to a list. More...
 
static ULONG ami_font_scan_load (const char *filename, lwc_string **glypharray)
 Load a font glyph cache. More...
 
void ami_font_scan_save (const char *filename, lwc_string **glypharray)
 Save a font glyph cache. More...
 
void ami_font_scan_fini (lwc_string **glypharray)
 Finalise the font glyph cache. More...
 
void ami_font_scan_init (const char *filename, bool force_scan, bool save, lwc_string **glypharray)
 Initialise the font glyph cache. More...
 

Detailed Description

Font glyph scanner for Unicode substitutions.

Definition in file font_scan.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FS_OID_MAIN 
FS_GID_MAIN 
FS_GID_FONTS 
FS_GID_GLYPHS 
FS_GID_LAST 

Definition at line 60 of file font_scan.c.

Function Documentation

◆ ami_font_scan_fini()

void ami_font_scan_fini ( lwc_string **  glypharray)

Finalise the font glyph cache.

Parameters
glypharrayan array of 0xffff lwc_string pointers to free

Definition at line 452 of file font_scan.c.

References glypharray.

Referenced by ami_font_finiscanner().

Here is the caller graph for this function:

◆ ami_font_scan_font()

static ULONG ami_font_scan_font ( const char *  fontname,
lwc_string **  glypharray 
)
static

Scan a font for glyphs not present in glypharray.

Parameters
fontnamefont to scan
glypharrayan array of 0xffff lwc_string pointers
Returns
number of new glyphs found

Definition at line 215 of file font_scan.c.

References AMI_OFONT_ENGINE, OutlineFont::BulletBase, CloseOutlineFont(), EObtainInfo, EReleaseInfo, ESetInfo, GetHead(), GetSucc(), glypharray, NSLOG, nsoption_charp, nsoption_set_charp, OFF_OPEN, and OpenOutlineFont().

Referenced by ami_font_scan_fonts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_fonts()

static ULONG ami_font_scan_fonts ( struct MinList *  list,
struct ami_font_scan_window win,
lwc_string **  glypharray 
)
static

Scan all fonts for glyphs.

Parameters
listmin list
winscan window
glypharrayan array of 0xffff lwc_string pointers
Returns
number of glyphs found

Definition at line 282 of file font_scan.c.

References ami_font_scan_font(), ami_font_scan_gui_update(), nsObject::dtz_Node, GetHead(), GetSucc(), glypharray, IsMinListEmpty, and NSLOG.

Referenced by ami_font_scan_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_gui_close()

static void ami_font_scan_gui_close ( struct ami_font_scan_window fsw)
static

Close GUI showing font scanning progress.

Parameters
fswpointer to a struct ami_font_scan_window

Definition at line 199 of file font_scan.c.

References ami_utf8_free(), FS_OID_MAIN, ami_font_scan_window::objects, and ami_font_scan_window::title.

Referenced by ami_font_scan_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_gui_open()

static struct ami_font_scan_window * ami_font_scan_gui_open ( int32  fonts)
static

Open GUI to show font scanning progress.

Parameters
fontsnumber of fonts that are being scanned
Returns
pointer to a struct ami_font_scan_window

Definition at line 99 of file font_scan.c.

References ami_gui_get_screen(), ami_gui_get_screen_title(), ami_utf8_easy(), FS_GID_FONTS, FS_GID_GLYPHS, FS_GID_MAIN, FS_OID_MAIN, FuelGaugeObj, ami_font_scan_window::glyphtext, LayoutVObj, messages_get(), ami_font_scan_window::objects, ami_font_scan_window::title, ami_font_scan_window::win, and WindowObj.

Referenced by ami_font_scan_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_gui_update()

static void ami_font_scan_gui_update ( struct ami_font_scan_window fsw,
const char *  font,
ULONG  font_num,
ULONG  glyphs 
)
static

Update GUI showing font scanning progress.

Parameters
fswpointer to a struct ami_font_scan_window
fontcurrent font being scanned
font_numfont number being scanned
glyphsnumber of unique glyphs found

Definition at line 167 of file font_scan.c.

References FS_GID_FONTS, FS_GID_GLYPHS, ami_font_scan_window::glyphtext, ami_font_scan_window::objects, RefreshSetGadgetAttrs(), and ami_font_scan_window::win.

Referenced by ami_font_scan_fonts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_init()

void ami_font_scan_init ( const char *  filename,
bool  force_scan,
bool  save,
lwc_string **  glypharray 
)

Initialise the font glyph cache.

Reads an existing file or, if not present, generates a new cache.

Parameters
filenamecache file to attempt to read
force_scanforce re-creation of cache
savesave the cache
glypharrayan array of 0xffff lwc_string pointers

Definition at line 474 of file font_scan.c.

References AddObject(), ami_font_scan_fonts(), ami_font_scan_gui_close(), ami_font_scan_gui_open(), ami_font_scan_list(), ami_font_scan_load(), ami_font_scan_save(), AMINS_UNKNOWN, nsObject::dtz_Node, FreeObjList(), glypharray, NewObjList(), NSLOG, nsoption_bool, nsoption_charp, and strsep().

Referenced by ami_font_initscanner().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_list()

static ULONG ami_font_scan_list ( struct MinList *  list)
static

Add OS fonts to a list.

Parameters
listlist to add font names to
Returns
number of fonts found

Definition at line 313 of file font_scan.c.

References AddObject(), AFF_OTAG, AMINS_UNKNOWN, nsObject::dtz_Node, FindIName, and NSLOG.

Referenced by ami_font_scan_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ami_font_scan_load()

static ULONG ami_font_scan_load ( const char *  filename,
lwc_string **  glypharray 
)
static

Load a font glyph cache.

Parameters
filenamename of cache file to load
glypharrayan array of 0xffff lwc_string pointers
Returns
number of glyphs loaded

Definition at line 371 of file font_scan.c.

References buffer, FClose, FOpen, glypharray, and NSLOG.

Referenced by ami_font_scan_init().

Here is the caller graph for this function:

◆ ami_font_scan_lookup()

const char * ami_font_scan_lookup ( const uint16 code,
lwc_string **  glypharray 
)

Lookup a font that contains a UTF-16 codepoint.

Parameters
codeUTF-16 codepoint to lookup
glypharrayan array of 0xffff lwc_string pointers
Returns
font name or NULL

Definition at line 82 of file font_scan.c.

References glypharray.

Referenced by ami_open_outline_font().

Here is the caller graph for this function:

◆ ami_font_scan_save()

void ami_font_scan_save ( const char *  filename,
lwc_string **  glypharray 
)

Save a font glyph cache.

Parameters
filenamename of cache file to save
glypharrayan array of 0xffff lwc_string pointers

Definition at line 425 of file font_scan.c.

References FClose, FOpen, glypharray, and NSLOG.

Referenced by ami_font_savescanner(), and ami_font_scan_init().

Here is the caller graph for this function: