NetSurf
|
Windows font handling and character encoding implementation. More...
#include "utils/config.h"
#include <assert.h>
#include <windows.h>
#include "netsurf/inttypes.h"
#include "utils/log.h"
#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "netsurf/layout.h"
#include "netsurf/utf8.h"
#include "netsurf/plot_style.h"
#include "windows/font.h"
Go to the source code of this file.
Macros | |
#define | WSTRLEN 4096 |
Functions | |
nserror | utf8_to_font_encoding (const struct font_desc *font, const char *string, size_t len, char **result) |
convert from utf-8 to win32 font encoding. More... | |
static nserror | utf8_to_local_encoding (const char *string, size_t len, char **result) |
Convert a string to UCS2 from UTF8. More... | |
static nserror | utf8_from_local_encoding (const char *string, size_t len, char **result) |
Convert a string to UTF8 from local encoding. More... | |
HFONT | get_font (const plot_font_style_t *style) |
static nserror | win32_font_width (const plot_font_style_t *style, const char *utf8str, size_t utf8len, int *width) |
Measure the width of a string. More... | |
static nserror | win32_font_position (const plot_font_style_t *style, const char *utf8str, size_t utf8len, int x, size_t *char_offset, int *actual_x) |
Find the position in a string where an x coordinate falls. More... | |
static nserror | win32_font_split (const plot_font_style_t *style, const char *string, size_t length, int x, size_t *offset, int *actual_x) |
Find where to split a string to make it fit a width. More... | |
Variables | |
HWND | font_hwnd |
static struct gui_layout_table | layout_table |
win32 font operations table More... | |
struct gui_layout_table * | win32_layout_table = &layout_table |
static struct gui_utf8_table | utf8_table |
win32 utf8 encoding operations table More... | |
struct gui_utf8_table * | win32_utf8_table = &utf8_table |
Windows font handling and character encoding implementation.
Definition in file font.c.
HFONT get_font | ( | const plot_font_style_t * | style | ) |
Definition at line 92 of file font.c.
References plot_font_style::family, plot_font_style::flags, font_hwnd, FONTF_ITALIC, 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 text(), win32_font_position(), and win32_font_width().
|
static |
Convert a string to UTF8 from local encoding.
[in] | string | source string |
[in] | len | source string length |
[out] | result | The UTF8 string |
Definition at line 74 of file font.c.
References NSERROR_NOMEM, NSERROR_OK, result, and strndup().
nserror utf8_to_font_encoding | ( | const struct font_desc * | font, |
const char * | string, | ||
size_t | len, | ||
char ** | result | ||
) |
convert from utf-8 to win32 font encoding.
[in] | font | font descriptor |
[in] | string | source utf-8 string |
[in] | len | The length of the utf-8 data |
[out] | result | The reencoded string. |
Definition at line 43 of file font.c.
References font_desc::encoding, result, and utf8_to_enc().
|
static |
Convert a string to UCS2 from UTF8.
[in] | string | source string |
[in] | len | source string length |
[out] | result | The UCS2 string |
Definition at line 60 of file font.c.
References result, and utf8_to_enc().
|
static |
Find the position in a string where an x coordinate falls.
style | css_style for this text, with style->font_size.size == CSS_FONT_SIZE_LENGTH |
utf8str | string to measure encoded in UTF-8 |
utf8len | length of string |
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 238 of file font.c.
References get_font(), NSERROR_OK, and NSERROR_UNKNOWN.
Referenced by win32_font_split().
|
static |
Find where to split a string to make it fit a width.
style | css_style for this text, with style->font_size.size == CSS_FONT_SIZE_LENGTH | |
string | UTF-8 string to measure | |
length | length of string | |
x | width available | |
[out] | offset | updated to offset in string of actual_x, [0..length] |
actual_x | updated to x coordinate of character closest to x |
On exit, [char_offset == 0 || string[char_offset] == ' ' || char_offset == length]
Definition at line 296 of file font.c.
References NSERROR_OK, NSLOG, win32_font_position(), and win32_font_width().
|
static |
Measure the width of a string.
[in] | style | plot style for this text |
[in] | utf8str | string encoded in UTF-8 to measure |
[in] | utf8len | length of string, in bytes |
[out] | width | updated to width of string[0..length) |
Definition at line 182 of file font.c.
References get_font(), NSERROR_INVALID, NSERROR_NOSPACE, NSERROR_OK, width, and WSTRLEN.
Referenced by win32_font_split().
HWND font_hwnd |
Definition at line 39 of file font.c.
Referenced by get_font(), and win32_window_create().
|
static |
win32 font operations table
|
static |
win32 utf8 encoding operations table
struct gui_layout_table* win32_layout_table = &layout_table |
struct gui_utf8_table* win32_utf8_table = &utf8_table |