35#include <font-ns-sans.h>
42#define SEVEN_SET ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | \
43 (1 << 4) | (1 << 5) | (1 << 6))
45#define THREE_SSS ((1 << 0) | (1 << 1) | (1 << 2))
46#define THREE_S_S ((1 << 0) | (1 << 2))
47#define THREE__SS ((1 << 0) | (1 << 1) )
48#define THREE_SS_ ( (1 << 1) | (1 << 2))
49#define THREE_S__ (1 << 2)
50#define THREE__S_ (1 << 1)
51#define THREE___S (1 << 0)
203 if (fstyle->
weight >= 700)
214 int size = fstyle->
size * 10 /
227 0x00, 0x03, 0x0c, 0x0f,
228 0x30, 0x33, 0x3c, 0x3f,
229 0xc0, 0xc3, 0xcc, 0xcf,
230 0xf0, 0xf3, 0xfc, 0xff
233static const uint8_t *
236 const uint8_t *glyph_max = glyph_data +
GLYPH_LEN;
244 }
while (++glyph_data < glyph_max);
252 const uint8_t *glyph_data;
253 unsigned int section;
265 section = fb_bold_italic_section_table[ucs4 / 256];
266 if (section != 0 || ucs4 / 256 == 0) {
267 offset = section * 256 + (ucs4 & 0xff);
268 g_offset = fb_bold_italic_sections[offset] * 16;
270 glyph_data = &font_glyph_data[g_offset];
277 section = fb_bold_section_table[ucs4 / 256];
278 if (section != 0 || ucs4 / 256 == 0) {
279 offset = section * 256 + (ucs4 & 0xff);
280 g_offset = fb_bold_sections[offset] * 16;
282 glyph_data = &font_glyph_data[g_offset];
289 section = fb_italic_section_table[ucs4 / 256];
290 if (section != 0 || ucs4 / 256 == 0) {
291 offset = section * 256 + (ucs4 & 0xff);
292 g_offset = fb_italic_sections[offset] * 16;
294 glyph_data = &font_glyph_data[g_offset];
301 section = fb_regular_section_table[ucs4 / 256];
302 if (section != 0 || ucs4 / 256 == 0) {
303 offset = section * 256 + (ucs4 & 0xff);
304 g_offset = fb_regular_sections[offset] * 16;
306 glyph_data = &font_glyph_data[g_offset];
324 assert(scale >= 1 && scale <= 2);
343 *
result = malloc(len + 1);
348 memcpy(*
result,
string, len);
350 (*result)[len] =
'\0';
366 while (nxtchr < length) {
373 nxtchr =
utf8_next(
string, length, nxtchr);
394 while (nxtchr < length) {
396 if (abs(x_pos - x) <= (
width / 2))
404 nxtchr =
utf8_next(
string, length, nxtchr);
409 *char_offset = nxtchr;
446 int last_space_x = 0;
447 int last_space_idx = 0;
450 while (nxtchr < length) {
453 if (
string[nxtchr] ==
' ') {
454 last_space_x = *actual_x;
455 last_space_idx = nxtchr;
463 if (*actual_x > x && last_space_idx != 0) {
466 *actual_x = last_space_x;
467 *char_offset = last_space_idx;
471 nxtchr =
utf8_next(
string, length, nxtchr);
474 *char_offset = nxtchr;
nserror
Enumeration of error codes.
@ NSERROR_NOMEM
Memory exhaustion.
const uint8_t * fb_get_glyph(uint32_t ucs4, enum fb_font_style style, int scale)
struct gui_utf8_table * framebuffer_utf8_table
static struct gui_utf8_table utf8_table
bool fb_font_finalise(void)
Finalise framebuffer font handling.
bool fb_font_init(void)
Initialise framebuffer font handling.
uint8_t code_point[GLYPH_LEN]
static uint8_t * get_codepoint(uint32_t id, bool italic)
struct gui_layout_table * framebuffer_layout_table
int fb_get_font_size(const plot_font_style_t *fstyle)
nserror fb_font_width(const plot_font_style_t *fstyle, const char *string, size_t length, int *width)
enum fb_font_style fb_get_font_style(const plot_font_style_t *fstyle)
static nserror utf8_from_local(const char *string, size_t len, char **result)
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.
const uint8_t glyph_lut[16]
Lookup table to scale 4 bits to 8 bits, so e.g.
static nserror utf8_to_local(const char *string, size_t len, char **result)
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
uint8_t glyph_x2[GLYPH_LEN *4]
static const uint8_t * glyph_scale_2(const uint8_t *glyph_data)
#define codepoint_displayable(u)
Interface to platform-specific layout operation table.
Interface to platform-specific utf8 operations.
Netsurf additional integer type formatting macros.
plotter style interfaces, generic styles and style colour helpers.
#define PLOT_STYLE_SCALE
Scaling factor for plot styles.
Interface to utility string handling.
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.
nserror(* utf8_to_local)(const char *string, size_t len, char **result)
Convert a UTF-8 encoded string into the system local encoding.
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_int(OPTION)
Get the value of an integer 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.
nserror utf8_to_enc(const char *string, const char *encname, size_t len, char **result)
Convert a UTF8 string into the named encoding.
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through