NetSurf
Functions | Variables
font.c File Reference
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include "netsurf/inttypes.h"
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "netsurf/layout.h"
#include "netsurf/mouse.h"
#include "netsurf/plotters.h"
#include "atari/gui.h"
#include "atari/plot/fontplot.h"
#include "atari/plot/plot.h"
#include "atari/findfile.h"
#include "atari/font.h"
Include dependency graph for font.c:

Go to the source code of this file.

Functions

static nserror atari_font_position (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 atari_font_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 nserror atari_font_width (const plot_font_style_t *fstyle, const char *str, size_t length, int *width)
 Measure the width of a string. More...
 

Variables

FONT_PLOTTER fplotter
 
static struct gui_layout_table layout_table
 
struct gui_layout_tableatari_layout_table = &layout_table
 

Function Documentation

◆ atari_font_position()

static nserror atari_font_position ( 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
[in]fstylestyle for this text
[in]stringUTF-8 string to measure
[in]lengthlength of string, in bytes
[in]xcoordinate to search for
[out]char_offsetupdated to offset in string of actual_x, [0..length]
[out]actual_xupdated to x coordinate of character closest to x
Returns
NSERROR_OK and char_offset and actual_x updated or appropriate error code on faliure

Definition at line 52 of file font.c.

References fplotter, NSERROR_OK, s_font_plotter::pixel_pos, plot_get_scale(), and plot_font_style::size.

Here is the call graph for this function:

◆ atari_font_split()

static nserror atari_font_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
[in]fstylestyle for this text
[in]stringUTF-8 string to measure
[in]lengthlength of string, in bytes
[in]xwidth available
[out]char_offsetupdated to offset in string of actual_x, [1..length]
[out]actual_xupdated to x coordinate of character closest to x
Returns
NSERROR_OK or appropriate error code on faliure

On exit, char_offset indicates first character after split point.

Note
char_offset of 0 must 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 98 of file font.c.

References fplotter, NSERROR_OK, plot_get_scale(), plot_font_style::size, and s_font_plotter::str_split.

Here is the call graph for this function:

◆ atari_font_width()

static nserror atari_font_width ( const plot_font_style_t fstyle,
const char *  str,
size_t  length,
int *  width 
)
static

Measure the width of a string.

Parameters
[in]fstyleplot style for this text
[in]strUTF-8 string to measure
[in]lengthlength of string, in bytes
[out]widthupdated to width of string[0..length)
Returns
NSERROR_OK and width updated or appropriate error code on faliure

Definition at line 131 of file font.c.

References fplotter, NSERROR_OK, plot_get_scale(), plot_font_style::size, s_font_plotter::str_width, and width.

Here is the call graph for this function:

Variable Documentation

◆ atari_layout_table

struct gui_layout_table* atari_layout_table = &layout_table

Definition at line 156 of file font.c.

Referenced by main().

◆ fplotter

FONT_PLOTTER fplotter
extern

◆ layout_table

struct gui_layout_table layout_table
static
Initial value:
= {
.width = atari_font_width,
.position = atari_font_position,
.split = atari_font_split,
}
static nserror atari_font_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.
Definition: font.c:98
static nserror atari_font_position(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: font.c:52
static nserror atari_font_width(const plot_font_style_t *fstyle, const char *str, size_t length, int *width)
Measure the width of a string.
Definition: font.c:131

Definition at line 150 of file font.c.