40#define CACHE_MIN_SIZE (100 * 1024)
42#define BOLD_WEIGHT 700
74#define FB_FACE_DEFAULT 0
84 FT_Pointer request_data,
93 NSLOG(netsurf, INFO,
"Could not find font (code %d)", error);
96 error = FT_Select_Charmap(*face, FT_ENCODING_UNICODE);
99 "Could not select charmap (code %d)", error);
101 for (cidx = 0; cidx < (*face)->num_charmaps; cidx++) {
102 if ((*face)->charmap == (*face)->charmaps[cidx]) {
103 fb_face->
cidx = cidx;
109 NSLOG(netsurf, INFO,
"Loaded face from %s", fb_face->
fontfile);
118fb_new_face(
const char *option,
const char *resname,
const char *fontname)
127 if (option != NULL) {
134 error = FTC_Manager_LookupFace(
ft_cmanager, (FTC_FaceID)newf, &aface);
136 NSLOG(netsurf, INFO,
"Could not find font face %s (code %d)",
150 FT_ULong max_cache_size;
151 FT_UInt max_faces = 6;
155 error = FT_Init_FreeType( &
library );
158 "Freetype could not initialised (code %d)", error);
163 max_cache_size =
nsoption_int(fb_font_cachesize) * 1024;
170 error = FTC_Manager_New(
library,
179 "Freetype could not initialise cache manager (code %d)",
194 NETSURF_FB_FONT_SANS_SERIF);
195 if (fb_face == NULL) {
197 NSLOG(netsurf, INFO,
"Could not find the default font");
207 "sans_serif_bold.ttf",
208 NETSURF_FB_FONT_SANS_SERIF_BOLD);
209 if (fb_face == NULL) {
218 "sans_serif_italic.ttf",
219 NETSURF_FB_FONT_SANS_SERIF_ITALIC);
220 if (fb_face == NULL) {
229 "sans_serif_italic_bold.ttf",
230 NETSURF_FB_FONT_SANS_SERIF_ITALIC_BOLD);
231 if (fb_face == NULL) {
241 NETSURF_FB_FONT_SERIF);
242 if (fb_face == NULL) {
252 NETSURF_FB_FONT_SERIF_BOLD);
253 if (fb_face == NULL) {
264 NETSURF_FB_FONT_MONOSPACE);
265 if (fb_face == NULL) {
274 "monospace_bold.ttf",
275 NETSURF_FB_FONT_MONOSPACE_BOLD);
276 if (fb_face == NULL) {
286 NETSURF_FB_FONT_CURSIVE);
287 if (fb_face == NULL) {
297 NETSURF_FB_FONT_FANTASY);
298 if (fb_face == NULL) {
393 srec->face_id = (FTC_FaceID)
fb_faces[selected_face];
414 glyph_index = FTC_CMapCache_Lookup(
ft_cmap_cache, srec.face_id,
415 fb_face->
cidx, ucs4);
420 FT_LOAD_FORCE_AUTOHINT |
435 const char *
string,
size_t length,
443 while (nxtchr < length) {
445 nxtchr =
utf8_next(
string, length, nxtchr);
451 *
width += glyph->advance.x >> 16;
460 const char *
string,
size_t length,
461 int x,
size_t *char_offset,
int *actual_x)
469 while (nxtchr < length) {
476 *actual_x += glyph->advance.x >> 16;
481 nxtchr =
utf8_next(
string, length, nxtchr);
485 if (abs(*actual_x - x) > abs(prev_x - x))
488 *char_offset = nxtchr;
517 const char *
string,
size_t length,
518 int x,
size_t *char_offset,
int *actual_x)
522 int last_space_x = 0;
523 int last_space_idx = 0;
527 while (nxtchr < length) {
535 last_space_x = *actual_x;
536 last_space_idx = nxtchr;
539 *actual_x += glyph->advance.x >> 16;
540 if (*actual_x > x && last_space_idx != 0) {
543 *actual_x = last_space_x;
544 *char_offset = last_space_idx;
548 nxtchr =
utf8_next(
string, length, nxtchr);
551 *char_offset = nxtchr;
nserror
Enumeration of error codes.
char * filepath_sfind(char **respathv, char *filepath, const char *filename)
Searches an array of resource paths for a file.
Utility routines to obtain paths to file resources.
char ** respaths
resource search path vector
static fb_faceid_t * fb_faces[FB_FACE_COUNT]
struct gui_utf8_table * framebuffer_utf8_table
@ FB_FACE_SANS_SERIF_ITALIC
@ FB_FACE_SANS_SERIF_ITALIC_BOLD
@ FB_FACE_SANS_SERIF_BOLD
static FTC_ImageCache ft_image_cache
bool fb_font_finalise(void)
Finalise framebuffer font handling.
bool fb_font_init(void)
Initialise framebuffer font handling.
static FT_Error ft_face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *face)
map cache manager handle to face id
struct gui_layout_table * framebuffer_layout_table
static FTC_CMapCache ft_cmap_cache
nserror fb_font_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
struct fb_faceid_s fb_faceid_t
static nserror fb_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.
static FT_Library library
static fb_faceid_t * fb_new_face(const char *option, const char *resname, const char *fontname)
create new framebuffer face and cause it to be loaded to check its ok
nserror fb_font_position(const plot_font_style_t *fstyle, const char *string, size_t length, int x, size_t *char_offset, int *actual_x)
static struct gui_layout_table layout_table
static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec)
fill freetype scalar
static FTC_Manager ft_cmanager
FT_Glyph fb_getglyph(const plot_font_style_t *fstyle, uint32_t ucs4)
int browser_get_dpi(void)
Get the browser DPI.
Interface to platform-specific layout operation table.
Interface to platform-specific utf8 operations.
Netsurf additional integer type formatting macros.
#define NSLOG(catname, level, logmsg, args...)
plotter style interfaces, generic styles and style colour helpers.
@ PLOT_FONT_FAMILY_CURSIVE
@ PLOT_FONT_FAMILY_SANS_SERIF
@ PLOT_FONT_FAMILY_FANTASY
@ PLOT_FONT_FAMILY_MONOSPACE
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
nserror(* width)(const struct plot_font_style *fstyle, const char *string, size_t length, int *width)
Measure the width of a string.
User interface utf8 characterset conversion routines.
plot_font_generic_family_t family
Generic family to plot with.
plot_font_flags_t flags
Font flags.
plot_style_fixed size
Font size, in pt.
int weight
Font weight: value in range [100,900] as per CSS.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_bool(OPTION)
Get the value of a boolean option.
uint32_t utf8_to_ucs4(const char *s_in, size_t l)
Convert a UTF-8 multibyte sequence into a single UCS4 character.
size_t utf8_next(const char *s, size_t l, size_t o)
Find next legal UTF-8 char in string.
UTF-8 manipulation functions (interface).