update windows frontend to use font layout table

This commit is contained in:
Vincent Sanders 2016-04-24 17:59:03 +01:00
parent f687eb8886
commit c9d9537941
3 changed files with 19 additions and 21 deletions

View File

@ -30,7 +30,7 @@
#include "utils/log.h" #include "utils/log.h"
#include "utils/nsoption.h" #include "utils/nsoption.h"
#include "utils/utf8.h" #include "utils/utf8.h"
#include "desktop/font.h" #include "desktop/gui_layout.h"
#include "desktop/gui_utf8.h" #include "desktop/gui_utf8.h"
#include "windows/font.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) * \param[out] width updated to width of string[0..length)
* \return true on success and width updated else false * \return true on success and width updated else false
*/ */
static bool static nserror
nsfont_width(const plot_font_style_t *style, win32_font_width(const plot_font_style_t *style,
const char *string, const char *string,
size_t length, size_t length,
int *width) 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 * \param actual_x updated to x coordinate of character closest to x
* \return true on success, false on error and error reported * \return true on success, false on error and error reported
*/ */
static bool static nserror
nsfont_position_in_string(const plot_font_style_t *style, win32_font_position(const plot_font_style_t *style,
const char *string, const char *string,
size_t length, size_t length,
int x, int x,
@ -240,8 +240,8 @@ nsfont_position_in_string(const plot_font_style_t *style,
* string[char_offset] == ' ' || * string[char_offset] == ' ' ||
* char_offset == length] * char_offset == length]
*/ */
static bool static nserror
nsfont_split(const plot_font_style_t *style, win32_font_split(const plot_font_style_t *style,
const char *string, const char *string,
size_t length, size_t length,
int x, int x,
@ -251,12 +251,7 @@ nsfont_split(const plot_font_style_t *style,
int c_off; int c_off;
bool ret = false; bool ret = false;
if (nsfont_position_in_string(style, if (win32_font_position(style, string, length, x, char_offset, actual_x)) {
string,
length,
x,
char_offset,
actual_x)) {
c_off = *char_offset; c_off = *char_offset;
if (*char_offset == length) { if (*char_offset == length) {
ret = true; ret = true;
@ -274,10 +269,7 @@ nsfont_split(const plot_font_style_t *style,
} }
} }
ret = nsfont_width(style, ret = win32_font_width(style, string, *char_offset, actual_x);
string,
*char_offset,
actual_x);
} }
} }
@ -288,12 +280,16 @@ nsfont_split(const plot_font_style_t *style,
return ret; return ret;
} }
const struct font_functions nsfont = {
nsfont_width, static struct gui_layout_table layout_table = {
nsfont_position_in_string, .width = win32_font_width,
nsfont_split .position = win32_font_position,
.split = win32_font_split,
}; };
struct gui_layout_table *win32_layout_table = &layout_table;
static struct gui_utf8_table utf8_table = { static struct gui_utf8_table utf8_table = {
.utf8_to_local = utf8_to_local_encoding, .utf8_to_local = utf8_to_local_encoding,
.local_to_utf8 = utf8_from_local_encoding, .local_to_utf8 = utf8_from_local_encoding,

View File

@ -33,6 +33,7 @@ struct font_desc {
const char *encoding; const char *encoding;
}; };
struct gui_layout_table *win32_layout_table;
struct gui_utf8_table *win32_utf8_table; struct gui_utf8_table *win32_utf8_table;
extern nserror utf8_to_font_encoding(const struct font_desc* font, extern nserror utf8_to_font_encoding(const struct font_desc* font,

View File

@ -161,6 +161,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd)
.file = win32_file_table, .file = win32_file_table,
.utf8 = win32_utf8_table, .utf8 = win32_utf8_table,
.bitmap = win32_bitmap_table, .bitmap = win32_bitmap_table,
.layout = win32_layout_table,
}; };
win32_fetch_table->get_resource_url = gui_get_resource_url; win32_fetch_table->get_resource_url = gui_get_resource_url;