NetSurf
|
#include <inttypes.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include "utils/nsoption.h"
#include "utils/utils.h"
#include "utils/utf8.h"
#include "netsurf/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/plot_style.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
#include <font-ns-sans.h>
Go to the source code of this file.
Macros | |
#define | GLYPH_LEN 16 |
#define | SEVEN_SET |
#define | THREE_SSS ((1 << 0) | (1 << 1) | (1 << 2)) |
#define | THREE_S_S ((1 << 0) | (1 << 2)) |
#define | THREE__SS ((1 << 0) | (1 << 1) ) |
#define | THREE_SS_ ( (1 << 1) | (1 << 2)) |
#define | THREE_S__ (1 << 2) |
#define | THREE__S_ (1 << 1) |
#define | THREE___S (1 << 0) |
Functions | |
static uint8_t * | get_codepoint (uint32_t id, bool italic) |
bool | fb_font_init (void) |
Initialise framebuffer font handling. More... | |
bool | fb_font_finalise (void) |
Finalise framebuffer font handling. More... | |
enum fb_font_style | fb_get_font_style (const plot_font_style_t *fstyle) |
int | fb_get_font_size (const plot_font_style_t *fstyle) |
static const uint8_t * | glyph_scale_2 (const uint8_t *glyph_data) |
const uint8_t * | fb_get_glyph (uint32_t ucs4, enum fb_font_style style, int scale) |
static nserror | utf8_to_local (const char *string, size_t len, char **result) |
static nserror | utf8_from_local (const char *string, size_t len, char **result) |
nserror | fb_font_width (const plot_font_style_t *fstyle, const char *string, size_t length, int *width) |
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 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. More... | |
Variables | |
uint8_t | code_point [GLYPH_LEN] |
uint8_t | glyph_x2 [GLYPH_LEN *4] |
uint8_t | frag [16][5] |
const uint8_t | glyph_lut [16] |
Lookup table to scale 4 bits to 8 bits, so e.g. More... | |
static struct gui_layout_table | layout_table |
struct gui_layout_table * | framebuffer_layout_table = &layout_table |
static struct gui_utf8_table | utf8_table |
struct gui_utf8_table * | framebuffer_utf8_table = &utf8_table |
#define GLYPH_LEN 16 |
Definition at line 37 of file font_internal.c.
#define SEVEN_SET |
Definition at line 42 of file font_internal.c.
#define THREE___S (1 << 0) |
Definition at line 51 of file font_internal.c.
#define THREE__S_ (1 << 1) |
Definition at line 50 of file font_internal.c.
#define THREE__SS ((1 << 0) | (1 << 1) ) |
Definition at line 47 of file font_internal.c.
#define THREE_S__ (1 << 2) |
Definition at line 49 of file font_internal.c.
#define THREE_S_S ((1 << 0) | (1 << 2)) |
Definition at line 46 of file font_internal.c.
#define THREE_SS_ ( (1 << 1) | (1 << 2)) |
Definition at line 48 of file font_internal.c.
#define THREE_SSS ((1 << 0) | (1 << 1) | (1 << 2)) |
Definition at line 45 of file font_internal.c.
bool fb_font_finalise | ( | void | ) |
Finalise framebuffer font handling.
Definition at line 193 of file font_internal.c.
References FB_FACE_COUNT, fb_faces, ft_cmanager, and library.
Referenced by main().
bool fb_font_init | ( | void | ) |
Initialise framebuffer font handling.
Definition at line 188 of file font_internal.c.
References CACHE_MIN_SIZE, FB_FACE_CURSIVE, FB_FACE_FANTASY, FB_FACE_MONOSPACE, FB_FACE_MONOSPACE_BOLD, FB_FACE_SANS_SERIF, FB_FACE_SANS_SERIF_BOLD, FB_FACE_SANS_SERIF_ITALIC, FB_FACE_SANS_SERIF_ITALIC_BOLD, FB_FACE_SERIF, FB_FACE_SERIF_BOLD, fb_faces, fb_new_face(), ft_cmanager, ft_cmap_cache, ft_face_requester(), ft_image_cache, ft_load_type, library, NSLOG, nsoption_bool, nsoption_charp, and nsoption_int.
Referenced by main().
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 | ||
) |
Definition at line 383 of file font_internal.c.
References codepoint_displayable, FB_FONT_WIDTH, fb_get_font_size(), NSERROR_OK, utf8_next(), utf8_to_ucs4(), and width.
|
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 437 of file font_internal.c.
References codepoint_displayable, FB_FONT_WIDTH, fb_get_font_size(), NSERROR_OK, utf8_next(), utf8_to_ucs4(), and width.
nserror fb_font_width | ( | const plot_font_style_t * | fstyle, |
const char * | string, | ||
size_t | length, | ||
int * | width | ||
) |
Definition at line 358 of file font_internal.c.
References codepoint_displayable, FB_FONT_WIDTH, fb_get_font_size(), NSERROR_OK, utf8_next(), utf8_to_ucs4(), and width.
int fb_get_font_size | ( | const plot_font_style_t * | fstyle | ) |
Definition at line 212 of file font_internal.c.
References nsoption_int, PLOT_STYLE_SCALE, and plot_font_style::size.
Referenced by fb_font_position(), fb_font_split(), fb_font_width(), and framebuffer_plot_text().
enum fb_font_style fb_get_font_style | ( | const plot_font_style_t * | fstyle | ) |
Definition at line 199 of file font_internal.c.
References FB_BOLD, FB_ITALIC, FB_REGULAR, plot_font_style::flags, FONTF_ITALIC, FONTF_OBLIQUE, and plot_font_style::weight.
Referenced by framebuffer_plot_text().
const uint8_t * fb_get_glyph | ( | uint32_t | ucs4, |
enum fb_font_style | style, | ||
int | scale | ||
) |
Definition at line 250 of file font_internal.c.
References fallthrough, FB_BOLD, FB_BOLD_ITALIC, FB_ITALIC, FB_REGULAR, get_codepoint(), and glyph_scale_2().
Referenced by framebuffer_plot_text().
|
static |
Definition at line 151 of file font_internal.c.
References code_point, frag, and SEVEN_SET.
Referenced by fb_get_glyph().
|
static |
Definition at line 234 of file font_internal.c.
References GLYPH_LEN, glyph_lut, and glyph_x2.
Referenced by fb_get_glyph().
|
static |
Definition at line 339 of file font_internal.c.
References NSERROR_NOMEM, NSERROR_OK, and result.
|
static |
Definition at line 331 of file font_internal.c.
References result, and utf8_to_enc().
uint8_t code_point[GLYPH_LEN] |
Definition at line 39 of file font_internal.c.
Referenced by get_codepoint().
uint8_t frag[16][5] |
Definition at line 53 of file font_internal.c.
Referenced by get_codepoint().
struct gui_layout_table* framebuffer_layout_table = &layout_table |
Definition at line 486 of file font_internal.c.
Referenced by main().
struct gui_utf8_table* framebuffer_utf8_table = &utf8_table |
Definition at line 494 of file font_internal.c.
Referenced by main().
const uint8_t glyph_lut[16] |
Lookup table to scale 4 bits to 8 bits, so e.g.
0101 --> 00110011
Definition at line 226 of file font_internal.c.
Referenced by glyph_scale_2().
uint8_t glyph_x2[GLYPH_LEN *4] |
Definition at line 40 of file font_internal.c.
Referenced by glyph_scale_2().
|
static |
Definition at line 480 of file font_internal.c.
|
static |
Definition at line 489 of file font_internal.c.