diff options
author | Vincent Sanders <vince@kyllikki.org> | 2016-04-24 17:59:03 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2016-04-24 17:59:03 +0100 |
commit | c9d9537941a9b5b5a2b2557fd775201a2979f428 (patch) | |
tree | d95a9650850fd912652be6d58faf6b4f78cb93a9 | |
parent | f687eb888637c76796ff5a07177dfe0e225f268b (diff) | |
download | netsurf-c9d9537941a9b5b5a2b2557fd775201a2979f428.tar.gz netsurf-c9d9537941a9b5b5a2b2557fd775201a2979f428.tar.bz2 |
update windows frontend to use font layout table
-rw-r--r-- | windows/font.c | 38 | ||||
-rw-r--r-- | windows/font.h | 1 | ||||
-rw-r--r-- | windows/main.c | 1 |
3 files changed, 19 insertions, 21 deletions
diff --git a/windows/font.c b/windows/font.c index 9358d1a85..f67205a6f 100644 --- a/windows/font.c +++ b/windows/font.c @@ -30,7 +30,7 @@ #include "utils/log.h" #include "utils/nsoption.h" #include "utils/utf8.h" -#include "desktop/font.h" +#include "desktop/gui_layout.h" #include "desktop/gui_utf8.h" #include "windows/font.h" @@ -140,8 +140,8 @@ HFONT get_font(const plot_font_style_t *style) * \param[out] width updated to width of string[0..length) * \return true on success and width updated else false */ -static bool -nsfont_width(const plot_font_style_t *style, +static nserror +win32_font_width(const plot_font_style_t *style, const char *string, size_t length, int *width) @@ -185,8 +185,8 @@ nsfont_width(const plot_font_style_t *style, * \param actual_x updated to x coordinate of character closest to x * \return true on success, false on error and error reported */ -static bool -nsfont_position_in_string(const plot_font_style_t *style, +static nserror +win32_font_position(const plot_font_style_t *style, const char *string, size_t length, int x, @@ -240,8 +240,8 @@ nsfont_position_in_string(const plot_font_style_t *style, * string[char_offset] == ' ' || * char_offset == length] */ -static bool -nsfont_split(const plot_font_style_t *style, +static nserror +win32_font_split(const plot_font_style_t *style, const char *string, size_t length, int x, @@ -251,12 +251,7 @@ nsfont_split(const plot_font_style_t *style, int c_off; bool ret = false; - if (nsfont_position_in_string(style, - string, - length, - x, - char_offset, - actual_x)) { + if (win32_font_position(style, string, length, x, char_offset, actual_x)) { c_off = *char_offset; if (*char_offset == length) { ret = true; @@ -274,10 +269,7 @@ nsfont_split(const plot_font_style_t *style, } } - ret = nsfont_width(style, - string, - *char_offset, - actual_x); + ret = win32_font_width(style, string, *char_offset, actual_x); } } @@ -288,12 +280,16 @@ nsfont_split(const plot_font_style_t *style, return ret; } -const struct font_functions nsfont = { - nsfont_width, - nsfont_position_in_string, - nsfont_split + +static struct gui_layout_table layout_table = { + .width = win32_font_width, + .position = win32_font_position, + .split = win32_font_split, }; +struct gui_layout_table *win32_layout_table = &layout_table; + + static struct gui_utf8_table utf8_table = { .utf8_to_local = utf8_to_local_encoding, .local_to_utf8 = utf8_from_local_encoding, diff --git a/windows/font.h b/windows/font.h index ec596f384..f2128afc5 100644 --- a/windows/font.h +++ b/windows/font.h @@ -33,6 +33,7 @@ struct font_desc { const char *encoding; }; +struct gui_layout_table *win32_layout_table; struct gui_utf8_table *win32_utf8_table; extern nserror utf8_to_font_encoding(const struct font_desc* font, diff --git a/windows/main.c b/windows/main.c index dfb3ad107..d2d054414 100644 --- a/windows/main.c +++ b/windows/main.c @@ -161,6 +161,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) .file = win32_file_table, .utf8 = win32_utf8_table, .bitmap = win32_bitmap_table, + .layout = win32_layout_table, }; win32_fetch_table->get_resource_url = gui_get_resource_url; |