NetSurf
|
RISC OS implementation of Font handling. More...
#include "utils/config.h"
#include <assert.h>
#include <string.h>
#include <oslib/wimp.h>
#include <oslib/wimpreadsysinfo.h>
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "netsurf/layout.h"
#include "netsurf/plot_style.h"
#include "riscos/gui.h"
#include "riscos/font.h"
Go to the source code of this file.
Functions | |
static void | nsfont_check_fonts (void) |
Check that at least Homerton.Medium is available. More... | |
static void | nsfont_check_option (char **option, const char *family, const char *fallback) |
Check that a font option is valid, and fix it if not. More... | |
void | nsfont_init (void) |
Initialize font handling. More... | |
const char * | nsfont_fallback_font (void) |
Retrieve the fallback font name. More... | |
static int | nsfont_list_cmp (const void *keyval, const void *datum) |
bsearch comparison routine More... | |
bool | nsfont_exists (const char *font_family) |
Check if a font family is available. More... | |
static nserror | ro_font_width (const plot_font_style_t *fstyle, const char *string, size_t length, int *width) |
Measure the width of a string. More... | |
static nserror | ro_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 | ro_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... | |
bool | nsfont_paint (const plot_font_style_t *fstyle, const char *string, size_t length, int x, int y) |
Paint a string. More... | |
void | nsfont_read_style (const plot_font_style_t *fstyle, const char **font_family, unsigned int *font_size, rufl_style *font_style) |
Convert a font style to a font family, size and rufl_style. More... | |
static void | ro_gui_wimp_desktop_font (char *family, size_t family_size, int *psize, rufl_style *pstyle) |
Looks up the current desktop font and converts that to a family name, font size and style flags suitable for passing directly to rufl. More... | |
void | ro_gui_wimp_get_desktop_font (void) |
Retrieve the current desktop font family, size and style from the WindowManager in a form suitable for passing to rufl. More... | |
Variables | |
char | ro_gui_desktop_font_family [80] |
desktop font, size and style being used More... | |
int | ro_gui_desktop_font_size = 12 |
rufl_style | ro_gui_desktop_font_style = rufl_WEIGHT_400 |
bool | no_font_blending = false |
static struct gui_layout_table | layout_table |
struct gui_layout_table * | riscos_layout_table = &layout_table |
RISC OS implementation of Font handling.
The RUfl is used to handle and render fonts.
Definition in file font.c.
|
static |
Check that at least Homerton.Medium is available.
Definition at line 54 of file font.c.
References die(), messages_get(), and NSLOG.
Referenced by nsfont_init().
|
static |
Check that a font option is valid, and fix it if not.
option | pointer to option, as used by options.[ch] |
family | font family to use if option is not set, or the set family is not available |
fallback | font family to use if family is not available either |
Definition at line 95 of file font.c.
References nsfont_exists().
Referenced by nsfont_init().
bool nsfont_exists | ( | const char * | font_family | ) |
Check if a font family is available.
font_family | name of font family |
Definition at line 199 of file font.c.
References nsfont_list_cmp().
Referenced by nsfont_check_option(), nsfont_fallback_font(), and ro_gui_options_fonts_default().
const char * nsfont_fallback_font | ( | void | ) |
Retrieve the fallback font name.
Definition at line 165 of file font.c.
References nsfont_exists(), and NSLOG.
Referenced by nsfont_init(), and ro_gui_options_fonts_default().
void nsfont_init | ( | void | ) |
Initialize font handling.
Exits through die() on error.
Definition at line 116 of file font.c.
References die(), nsfont_check_fonts(), nsfont_check_option(), nsfont_fallback_font(), NSLOG, nsoption_charp, nsoption_int, nsoption_set_int, PLOT_FONT_FAMILY_CURSIVE, PLOT_FONT_FAMILY_FANTASY, PLOT_FONT_FAMILY_MONOSPACE, PLOT_FONT_FAMILY_SANS_SERIF, and PLOT_FONT_FAMILY_SERIF.
Referenced by gui_init().
|
static |
bsearch comparison routine
Definition at line 185 of file font.c.
Referenced by nsfont_exists().
bool nsfont_paint | ( | const plot_font_style_t * | fstyle, |
const char * | string, | ||
size_t | length, | ||
int | x, | ||
int | y | ||
) |
Paint a string.
Render a string.
fstyle | plot style for this text |
string | UTF-8 string to measure |
length | length of string |
x | x coordinate |
y | y coordinate |
Definition at line 415 of file font.c.
References no_font_blending, nsfont_read_style(), NSLOG, and print_active.
void nsfont_read_style | ( | const plot_font_style_t * | fstyle, |
const char ** | font_family, | ||
unsigned int * | font_size, | ||
rufl_style * | font_style | ||
) |
Convert a font style to a font family, size and rufl_style.
fstyle | plot style for this text |
font_family | updated to font family |
font_size | updated to font size |
font_style | updated to font style |
Definition at line 456 of file font.c.
References plot_font_style::family, plot_font_style::flags, FONTF_ITALIC, FONTF_OBLIQUE, nsoption_charp, PLOT_FONT_FAMILY_CURSIVE, PLOT_FONT_FAMILY_FANTASY, PLOT_FONT_FAMILY_MONOSPACE, PLOT_FONT_FAMILY_SANS_SERIF, PLOT_FONT_FAMILY_SERIF, PLOT_STYLE_SCALE, plot_font_style::size, and plot_font_style::weight.
Referenced by nsfont_paint(), print_fonts_plot_text(), ro_font_position(), ro_font_split(), and ro_font_width().
|
static |
Find the position in a string where an x coordinate falls.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string |
x | x coordinate to search for |
char_offset | updated to offset in string of actual_x, [0..length] |
actual_x | updated to x coordinate of character closest to x |
Definition at line 267 of file font.c.
References NSERROR_INVALID, NSERROR_OK, nsfont_read_style(), and NSLOG.
|
static |
Find where to split a string to make it fit a width.
fstyle | style for this text |
string | UTF-8 string to measure |
length | length of string, in bytes |
x | width available |
char_offset | updated to offset in string of actual_x, [1..length] |
actual_x | updated to x coordinate of character closest to x |
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 329 of file font.c.
References NSERROR_INVALID, NSERROR_OK, nsfont_read_style(), and NSLOG.
|
static |
Measure the width of a string.
fstyle | plot style for this text |
string | UTF-8 string to measure |
length | length of string |
width | updated to width of string[0..length) |
Definition at line 219 of file font.c.
References NSERROR_INVALID, NSERROR_OK, nsfont_read_style(), NSLOG, and width.
|
static |
Looks up the current desktop font and converts that to a family name, font size and style flags suitable for passing directly to rufl.
family | buffer to receive font family |
family_size | buffer size |
psize | receives the font size in 1/16 points |
pstyle | receives the style settings to be passed to rufl |
Definition at line 517 of file font.c.
References max, NSLOG, ro_warn_user(), and strcasestr().
Referenced by ro_gui_wimp_get_desktop_font().
void ro_gui_wimp_get_desktop_font | ( | void | ) |
Retrieve the current desktop font family, size and style from the WindowManager in a form suitable for passing to rufl.
Definition at line 607 of file font.c.
References ro_gui_desktop_font_family, ro_gui_desktop_font_size, ro_gui_desktop_font_style, and ro_gui_wimp_desktop_font().
Referenced by gui_init(), and ro_gui_user_message().
|
static |
bool no_font_blending = false |
Definition at line 48 of file font.c.
Referenced by cookie_draw(), global_history_draw(), hotlist_draw(), nsfont_paint(), ro_local_history_draw(), and ro_pageinfo_draw().
struct gui_layout_table* riscos_layout_table = &layout_table |
char ro_gui_desktop_font_family[80] |
desktop font, size and style being used
Definition at line 45 of file font.c.
Referenced by ro_gui_status_bar_redraw(), and ro_gui_wimp_get_desktop_font().
int ro_gui_desktop_font_size = 12 |
Definition at line 46 of file font.c.
Referenced by ro_gui_status_bar_redraw(), and ro_gui_wimp_get_desktop_font().
rufl_style ro_gui_desktop_font_style = rufl_WEIGHT_400 |
Definition at line 47 of file font.c.
Referenced by ro_gui_status_bar_redraw(), and ro_gui_wimp_get_desktop_font().