update windows frontend to use font layout table
This commit is contained in:
parent
f687eb8886
commit
c9d9537941
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue