NetSurf
Macros | Functions | Variables
font_diskfont.c File Reference
#include "amiga/os3support.h"
#include <stdlib.h>
#include <string.h>
#include <proto/diskfont.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/utility.h>
#include <graphics/rpattr.h>
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
#include "amiga/font.h"
#include "amiga/font_diskfont.h"
#include "amiga/gui.h"
#include "amiga/plotters.h"
#include "amiga/utf8.h"
Include dependency graph for font_diskfont.c:

Go to the source code of this file.

Macros

#define MAX_FONT_NAME_SIZE   33
 

Functions

static struct TextFont * ami_font_bm_open (struct RastPort *rp, const plot_font_style_t *fstyle)
 
static size_t ami_font_bm_convert_local_to_utf8_offset (const char *utf8string, size_t length, UWORD offset)
 
static nserror amiga_bm_nsfont_width (const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
 
static nserror amiga_bm_nsfont_position_in_string (const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
 Find the position in a string where an x coordinate falls. More...
 
static nserror amiga_bm_nsfont_split (const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
 Find where to split a string to make it fit a width. More...
 
static ULONG amiga_bm_nsfont_text (struct RastPort *rp, const char *string, ULONG length, const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
 
void ami_font_diskfont_init (void)
 
void ami_font_diskfont_fini (void)
 

Variables

static plot_font_style_tprev_fstyle = NULL
 
static struct TextFont * prev_font = NULL
 
static struct RastPort temp_rp
 
const struct ami_font_functions ami_font_diskfont_table
 

Macro Definition Documentation

◆ MAX_FONT_NAME_SIZE

#define MAX_FONT_NAME_SIZE   33

Definition at line 40 of file font_diskfont.c.

Function Documentation

◆ ami_font_bm_convert_local_to_utf8_offset()

static size_t ami_font_bm_convert_local_to_utf8_offset ( const char *  utf8string,
size_t  length,
UWORD  offset 
)
static

Definition at line 120 of file font_diskfont.c.

References utf8_next().

Referenced by amiga_bm_nsfont_position_in_string(), and amiga_bm_nsfont_split().

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

◆ ami_font_bm_open()

static struct TextFont * ami_font_bm_open ( struct RastPort *  rp,
const plot_font_style_t fstyle 
)
static

◆ ami_font_diskfont_fini()

void ami_font_diskfont_fini ( void  )

Definition at line 304 of file font_diskfont.c.

References prev_font, and prev_fstyle.

Referenced by ami_font_fini().

Here is the caller graph for this function:

◆ ami_font_diskfont_init()

void ami_font_diskfont_init ( void  )

Definition at line 292 of file font_diskfont.c.

References ami_font_diskfont_table, ami_nsfont, prev_fstyle, and temp_rp.

Referenced by ami_font_init().

Here is the caller graph for this function:

◆ amiga_bm_nsfont_position_in_string()

static nserror amiga_bm_nsfont_position_in_string ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int  x,
size_t *  char_offset,
int *  actual_x 
)
static

Find the position in a string where an x coordinate falls.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string
xx coordinate to search for
char_offsetupdated to offset in string of actual_x, [0..length]
actual_xupdated to x coordinate of character closest to x
Returns
true on success, false on error and error reported

Definition at line 166 of file font_diskfont.c.

References ami_font_bm_convert_local_to_utf8_offset(), ami_font_bm_open(), NSERROR_INVALID, NSERROR_OK, temp_rp, and utf8_to_local_encoding().

Here is the call graph for this function:

◆ amiga_bm_nsfont_split()

static nserror amiga_bm_nsfont_split ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int  x,
size_t *  char_offset,
int *  actual_x 
)
static

Find where to split a string to make it fit a width.

Parameters
fstylestyle for this text
stringUTF-8 string to measure
lengthlength of string
xwidth available
char_offsetupdated to offset in string of actual_x, [1..length]
actual_xupdated to x coordinate of character closest to x
Returns
true on success, false on error and error reported

On exit, char_offset indicates first character after split point.

Note: char_offset of 0 should never be returned.

Returns: char_offset giving split point closest to x, where actual_x <= x else char_offset giving split point closest to x, where actual_x > x

Returning char_offset == length means no split possible

Definition at line 216 of file font_diskfont.c.

References ami_font_bm_convert_local_to_utf8_offset(), ami_font_bm_open(), NSERROR_INVALID, NSERROR_OK, temp_rp, and utf8_to_local_encoding().

Here is the call graph for this function:

◆ amiga_bm_nsfont_text()

static ULONG amiga_bm_nsfont_text ( struct RastPort *  rp,
const char *  string,
ULONG  length,
const plot_font_style_t fstyle,
ULONG  dx,
ULONG  dy,
bool  aa 
)
static

Definition at line 266 of file font_diskfont.c.

References ami_font_bm_open(), NSERROR_OK, and utf8_to_local_encoding().

Here is the call graph for this function:

◆ amiga_bm_nsfont_width()

static nserror amiga_bm_nsfont_width ( const plot_font_style_t fstyle,
const char *  string,
size_t  length,
int *  width 
)
static

Definition at line 133 of file font_diskfont.c.

References ami_font_bm_open(), NSERROR_INVALID, NSERROR_OK, temp_rp, utf8_to_local_encoding(), and width.

Here is the call graph for this function:

Variable Documentation

◆ ami_font_diskfont_table

const struct ami_font_functions ami_font_diskfont_table
Initial value:
= {
}
static nserror amiga_bm_nsfont_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
static nserror amiga_bm_nsfont_split(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find where to split a string to make it fit a width.
static ULONG amiga_bm_nsfont_text(struct RastPort *rp, const char *string, ULONG length, const plot_font_style_t *fstyle, ULONG dx, ULONG dy, bool aa)
static nserror amiga_bm_nsfont_position_in_string(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
Find the position in a string where an x coordinate falls.

Definition at line 285 of file font_diskfont.c.

Referenced by ami_font_diskfont_init().

◆ prev_font

struct TextFont* prev_font = NULL
static

Definition at line 43 of file font_diskfont.c.

Referenced by ami_font_bm_open(), and ami_font_diskfont_fini().

◆ prev_fstyle

plot_font_style_t* prev_fstyle = NULL
static

◆ temp_rp

struct RastPort temp_rp
static