Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/7677901edfc72228572e72f0858a55ab012f860a
...commit
http://git.netsurf-browser.org/netsurf.git/commit/7677901edfc72228572e72f0858a55ab012f860a
...tree
http://git.netsurf-browser.org/netsurf.git/tree/7677901edfc72228572e72f0858a55ab012f860a
The branch, master has been updated
via 7677901edfc72228572e72f0858a55ab012f860a (commit)
via 6ddb66ccfbf2c5627e04b9fc6a70661b764d9a93 (commit)
via c9d9537941a9b5b5a2b2557fd775201a2979f428 (commit)
from f687eb888637c76796ff5a07177dfe0e225f268b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=7677901edfc72228572e72f0858a55ab012f860a
commit 7677901edfc72228572e72f0858a55ab012f860a
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
update amiga font layout handling to use table
diff --git a/amiga/font.c b/amiga/font.c
index 39cb386..1c9702a 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -25,7 +25,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "amiga/font.h"
#include "amiga/font_bullet.h"
@@ -119,7 +119,7 @@ void ami_font_fini(void)
}
/* Stub entry points */
-static bool nsfont_width(const plot_font_style_t *fstyle,
+static nserror ami_font_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
{
@@ -127,7 +127,7 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
return ami_nsfont->width(fstyle, string, length, width);
}
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+static nserror ami_font_position(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
@@ -135,7 +135,7 @@ static bool nsfont_position_in_string(const
plot_font_style_t *fstyle,
return ami_nsfont->posn(fstyle, string, length, x, char_offset,
actual_x);
}
-static bool nsfont_split(const plot_font_style_t *fstyle,
+static nserror ami_font_split(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
@@ -143,9 +143,10 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
return ami_nsfont->split(fstyle, string, length, x, char_offset,
actual_x);
}
-const struct font_functions nsfont = {
- nsfont_width,
- nsfont_position_in_string,
- nsfont_split
+static struct gui_layout_table layout_table = {
+ .width = ami_font_width,
+ .position = ami_font_position,
+ .split = ami_font_split,
};
+struct gui_layout_table *ami_layout_table = &layout_table;
diff --git a/amiga/font.h b/amiga/font.h
index da23b59..a0b63d0 100755
--- a/amiga/font.h
+++ b/amiga/font.h
@@ -55,5 +55,8 @@ struct ami_font_functions {
};
const struct ami_font_functions *ami_nsfont;
+
+struct gui_layout_table *ami_layout_table;
+
#endif
diff --git a/amiga/font_diskfont.c b/amiga/font_diskfont.c
index 6ad6e79..91bec20 100644
--- a/amiga/font_diskfont.c
+++ b/amiga/font_diskfont.c
@@ -30,7 +30,6 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
-#include "desktop/font.h"
#include "amiga/font.h"
#include "amiga/font_diskfont.h"
diff --git a/amiga/print.c b/amiga/print.c
index 72b83e8..908b026 100644
--- a/amiga/print.c
+++ b/amiga/print.c
@@ -50,12 +50,13 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "desktop/printer.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "desktop/mouse.h"
#include "desktop/gui_window.h"
#include "content/hlcache.h"
#include "amiga/plotters.h"
+#include "amiga/font.h"
#include "amiga/gui.h"
#include "amiga/libs.h"
#include "amiga/misc.h"
@@ -414,7 +415,7 @@ void ami_print(struct hlcache_handle *c, int copies)
ami_print_info.PD = (struct PrinterData
*)ami_print_info.PReq->io_Device;
ami_print_info.PED = &ami_print_info.PD->pd_SegmentData->ps_PED;
- ami_print_info.ps = print_make_settings(PRINT_DEFAULT,
nsurl_access(hlcache_handle_get_url(c)), &nsfont);
+ ami_print_info.ps = print_make_settings(PRINT_DEFAULT,
nsurl_access(hlcache_handle_get_url(c)), ami_layout_table);
ami_print_info.ps->page_width = ami_print_info.PED->ped_MaxXDots;
ami_print_info.ps->page_height = ami_print_info.PED->ped_MaxYDots;
ami_print_info.ps->scale = scale;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=6ddb66ccfbf2c5627e04b9fc6a70661b764d9a93
commit 6ddb66ccfbf2c5627e04b9fc6a70661b764d9a93
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
update atari to use font layout table
diff --git a/atari/font.c b/atari/font.c
index 729986c..cb0c574 100644
--- a/atari/font.c
+++ b/atari/font.c
@@ -19,11 +19,12 @@
#include <inttypes.h>
#include <assert.h>
#include <stdbool.h>
+#include <stdlib.h>
-#include "desktop/font.h"
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
+#include "desktop/gui_layout.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
@@ -35,61 +36,121 @@
extern FONT_PLOTTER fplotter;
-static bool atari_font_position_in_string(const plot_font_style_t *
fstyle,const char *string,
- size_t length,int x, size_t
*char_offset, int *actual_x )
-{
- float scale = plot_get_scale();
-
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->pixel_pos(fplotter, &newstyle, string, length, x,
char_offset, actual_x);
- } else {
- fplotter->pixel_pos(fplotter, fstyle, string, length, x, char_offset,
actual_x);
- }
- return( true );
-}
-
-static bool atari_font_split( const plot_font_style_t * fstyle, const char
*string,
- size_t length,int x, size_t
*char_offset, int *actual_x )
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x coordinate to search for
+ * \param[out] char_offset updated to offset in string of actual_x, [0..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK and char_offset and actual_x updated or appropriate
error code on faliure
+ */
+static nserror
+atari_font_position(const plot_font_style_t *fstyle,
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
- float scale = plot_get_scale();
-
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->str_split(fplotter, &newstyle, string, length, x,
char_offset,
- actual_x);
- } else {
- fplotter->str_split(fplotter, fstyle, string, length, x, char_offset,
- actual_x);
- }
+ float scale = plot_get_scale();
+
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->pixel_pos(fplotter, &newstyle, string, length, x,
+ char_offset, actual_x);
+ } else {
+ fplotter->pixel_pos(fplotter, fstyle, string, length, x,
+ char_offset, actual_x);
+ }
+
+ return NSERROR_OK;
+}
- return( true );
+/**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x width available
+ * \param[out] char_offset updated to offset in string of actual_x, [1..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK or appropriate error code on faliure
+ *
+ * On exit, char_offset indicates first character after split point.
+ *
+ * \note char_offset of 0 must never be returned.
+ *
+ * Returns:
+ * char_offset giving split point closest to x, where actual_x <= x
+ * else
+ * char_offset giving split point closest to x, where actual_x > x
+ *
+ * Returning char_offset == length means no split possible
+ */
+static nserror
+atari_font_split(const plot_font_style_t *fstyle,
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
+{
+ float scale = plot_get_scale();
+
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->str_split(fplotter, &newstyle, string, length, x,
+ char_offset, actual_x);
+ } else {
+ fplotter->str_split(fplotter, fstyle, string, length, x,
+ char_offset, actual_x);
+ }
+
+ return NSERROR_OK;
}
-static bool atari_font_width( const plot_font_style_t *fstyle, const char *
str,
- size_t length, int * width )
-{
- float scale = plot_get_scale();
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->str_width(fplotter, &newstyle, str, length, width);
- } else {
- fplotter->str_width(fplotter, fstyle, str, length, width);
- }
+/**
+ * Measure the width of a string.
+ *
+ * \param[in] fstyle plot style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[out] width updated to width of string[0..length)
+ * \return NSERROR_OK and width updated or appropriate error code on faliure
+ */
+static nserror
+atari_font_width(const plot_font_style_t *fstyle,
+ const char *str,
+ size_t length,
+ int * width)
+{
+ float scale = plot_get_scale();
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->str_width(fplotter, &newstyle, str, length, width);
+ } else {
+ fplotter->str_width(fplotter, fstyle, str, length, width);
+ }
- return( true );
+ return NSERROR_OK;
}
-const struct font_functions nsfont = {
- atari_font_width,
- atari_font_position_in_string,
- atari_font_split
+
+static struct gui_layout_table layout_table = {
+ .width = atari_font_width,
+ .position = atari_font_position,
+ .split = atari_font_split,
};
+struct gui_layout_table *atari_layout_table = &layout_table;
diff --git a/atari/font.h b/atari/font.h
index 065a35a..a01d000 100644
--- a/atari/font.h
+++ b/atari/font.h
@@ -19,6 +19,7 @@
#ifndef NS_ATARI_FONT_H
#define NS_ATARI_FONT_H
+struct gui_layout_table *atari_layout_table;
#endif /* NETSURF_FB_FONT_H */
diff --git a/atari/gui.c b/atari/gui.c
index 5e5ef19..47b6693 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -35,7 +35,7 @@
#include "content/hlcache.h"
#include "desktop/treeview.h"
#include "desktop/browser.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "desktop/gui_window.h"
#include "desktop/gui_clipboard.h"
#include "desktop/gui_fetch.h"
@@ -66,6 +66,7 @@
#include "atari/file.h"
#include "atari/filetype.h"
#include "atari/bitmap.h"
+#include "atari/font.h"
#include "cflib.h"
static bool atari_quit = false;
@@ -1118,7 +1119,8 @@ int main(int argc, char** argv)
.utf8 = atari_utf8_table,
.search = atari_search_table,
.llcache = filesystem_llcache_table,
- .bitmap = atari_bitmap_table
+ .bitmap = atari_bitmap_table,
+ .layout = atari_layout_table
};
ret = netsurf_register(&atari_table);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c9d9537941a9b5b5a2b2557fd775201a2979f428
commit c9d9537941a9b5b5a2b2557fd775201a2979f428
Author: Vincent Sanders <[email protected]>
Commit: Vincent Sanders <[email protected]>
update windows frontend to use font layout table
diff --git a/windows/font.c b/windows/font.c
index 9358d1a..f67205a 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 ec596f3..f2128af 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 dfb3ad1..d2d0544 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;
-----------------------------------------------------------------------
Summary of changes:
amiga/font.c | 17 +++---
amiga/font.h | 3 +
amiga/font_diskfont.c | 1 -
amiga/print.c | 5 +-
atari/font.c | 153 ++++++++++++++++++++++++++++++++++---------------
atari/font.h | 1 +
atari/gui.c | 6 +-
windows/font.c | 38 ++++++------
windows/font.h | 1 +
windows/main.c | 1 +
10 files changed, 146 insertions(+), 80 deletions(-)
diff --git a/amiga/font.c b/amiga/font.c
index 39cb386..1c9702a 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -25,7 +25,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "amiga/font.h"
#include "amiga/font_bullet.h"
@@ -119,7 +119,7 @@ void ami_font_fini(void)
}
/* Stub entry points */
-static bool nsfont_width(const plot_font_style_t *fstyle,
+static nserror ami_font_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
{
@@ -127,7 +127,7 @@ static bool nsfont_width(const plot_font_style_t *fstyle,
return ami_nsfont->width(fstyle, string, length, width);
}
-static bool nsfont_position_in_string(const plot_font_style_t *fstyle,
+static nserror ami_font_position(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
@@ -135,7 +135,7 @@ static bool nsfont_position_in_string(const
plot_font_style_t *fstyle,
return ami_nsfont->posn(fstyle, string, length, x, char_offset,
actual_x);
}
-static bool nsfont_split(const plot_font_style_t *fstyle,
+static nserror ami_font_split(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
@@ -143,9 +143,10 @@ static bool nsfont_split(const plot_font_style_t *fstyle,
return ami_nsfont->split(fstyle, string, length, x, char_offset,
actual_x);
}
-const struct font_functions nsfont = {
- nsfont_width,
- nsfont_position_in_string,
- nsfont_split
+static struct gui_layout_table layout_table = {
+ .width = ami_font_width,
+ .position = ami_font_position,
+ .split = ami_font_split,
};
+struct gui_layout_table *ami_layout_table = &layout_table;
diff --git a/amiga/font.h b/amiga/font.h
index da23b59..a0b63d0 100755
--- a/amiga/font.h
+++ b/amiga/font.h
@@ -55,5 +55,8 @@ struct ami_font_functions {
};
const struct ami_font_functions *ami_nsfont;
+
+struct gui_layout_table *ami_layout_table;
+
#endif
diff --git a/amiga/font_diskfont.c b/amiga/font_diskfont.c
index 6ad6e79..91bec20 100644
--- a/amiga/font_diskfont.c
+++ b/amiga/font_diskfont.c
@@ -30,7 +30,6 @@
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
-#include "desktop/font.h"
#include "amiga/font.h"
#include "amiga/font_diskfont.h"
diff --git a/amiga/print.c b/amiga/print.c
index 72b83e8..908b026 100644
--- a/amiga/print.c
+++ b/amiga/print.c
@@ -50,12 +50,13 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "desktop/printer.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "desktop/mouse.h"
#include "desktop/gui_window.h"
#include "content/hlcache.h"
#include "amiga/plotters.h"
+#include "amiga/font.h"
#include "amiga/gui.h"
#include "amiga/libs.h"
#include "amiga/misc.h"
@@ -414,7 +415,7 @@ void ami_print(struct hlcache_handle *c, int copies)
ami_print_info.PD = (struct PrinterData
*)ami_print_info.PReq->io_Device;
ami_print_info.PED = &ami_print_info.PD->pd_SegmentData->ps_PED;
- ami_print_info.ps = print_make_settings(PRINT_DEFAULT,
nsurl_access(hlcache_handle_get_url(c)), &nsfont);
+ ami_print_info.ps = print_make_settings(PRINT_DEFAULT,
nsurl_access(hlcache_handle_get_url(c)), ami_layout_table);
ami_print_info.ps->page_width = ami_print_info.PED->ped_MaxXDots;
ami_print_info.ps->page_height = ami_print_info.PED->ped_MaxYDots;
ami_print_info.ps->scale = scale;
diff --git a/atari/font.c b/atari/font.c
index 729986c..cb0c574 100644
--- a/atari/font.c
+++ b/atari/font.c
@@ -19,11 +19,12 @@
#include <inttypes.h>
#include <assert.h>
#include <stdbool.h>
+#include <stdlib.h>
-#include "desktop/font.h"
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
+#include "desktop/gui_layout.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
@@ -35,61 +36,121 @@
extern FONT_PLOTTER fplotter;
-static bool atari_font_position_in_string(const plot_font_style_t *
fstyle,const char *string,
- size_t length,int x, size_t
*char_offset, int *actual_x )
-{
- float scale = plot_get_scale();
-
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->pixel_pos(fplotter, &newstyle, string, length, x,
char_offset, actual_x);
- } else {
- fplotter->pixel_pos(fplotter, fstyle, string, length, x, char_offset,
actual_x);
- }
- return( true );
-}
-
-static bool atari_font_split( const plot_font_style_t * fstyle, const char
*string,
- size_t length,int x, size_t
*char_offset, int *actual_x )
+/**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x coordinate to search for
+ * \param[out] char_offset updated to offset in string of actual_x, [0..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK and char_offset and actual_x updated or appropriate
error code on faliure
+ */
+static nserror
+atari_font_position(const plot_font_style_t *fstyle,
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
{
- float scale = plot_get_scale();
-
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->str_split(fplotter, &newstyle, string, length, x,
char_offset,
- actual_x);
- } else {
- fplotter->str_split(fplotter, fstyle, string, length, x, char_offset,
- actual_x);
- }
+ float scale = plot_get_scale();
+
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->pixel_pos(fplotter, &newstyle, string, length, x,
+ char_offset, actual_x);
+ } else {
+ fplotter->pixel_pos(fplotter, fstyle, string, length, x,
+ char_offset, actual_x);
+ }
+
+ return NSERROR_OK;
+}
- return( true );
+/**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param[in] fstyle style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[in] x width available
+ * \param[out] char_offset updated to offset in string of actual_x, [1..length]
+ * \param[out] actual_x updated to x coordinate of character closest to x
+ * \return NSERROR_OK or appropriate error code on faliure
+ *
+ * On exit, char_offset indicates first character after split point.
+ *
+ * \note char_offset of 0 must never be returned.
+ *
+ * Returns:
+ * char_offset giving split point closest to x, where actual_x <= x
+ * else
+ * char_offset giving split point closest to x, where actual_x > x
+ *
+ * Returning char_offset == length means no split possible
+ */
+static nserror
+atari_font_split(const plot_font_style_t *fstyle,
+ const char *string,
+ size_t length,
+ int x,
+ size_t *char_offset,
+ int *actual_x)
+{
+ float scale = plot_get_scale();
+
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->str_split(fplotter, &newstyle, string, length, x,
+ char_offset, actual_x);
+ } else {
+ fplotter->str_split(fplotter, fstyle, string, length, x,
+ char_offset, actual_x);
+ }
+
+ return NSERROR_OK;
}
-static bool atari_font_width( const plot_font_style_t *fstyle, const char *
str,
- size_t length, int * width )
-{
- float scale = plot_get_scale();
- if (scale != 1.0) {
- plot_font_style_t newstyle = *fstyle;
- newstyle.size = (int)((float)fstyle->size*scale);
- fplotter->str_width(fplotter, &newstyle, str, length, width);
- } else {
- fplotter->str_width(fplotter, fstyle, str, length, width);
- }
+/**
+ * Measure the width of a string.
+ *
+ * \param[in] fstyle plot style for this text
+ * \param[in] string UTF-8 string to measure
+ * \param[in] length length of string, in bytes
+ * \param[out] width updated to width of string[0..length)
+ * \return NSERROR_OK and width updated or appropriate error code on faliure
+ */
+static nserror
+atari_font_width(const plot_font_style_t *fstyle,
+ const char *str,
+ size_t length,
+ int * width)
+{
+ float scale = plot_get_scale();
+ if (scale != 1.0) {
+ plot_font_style_t newstyle = *fstyle;
+ newstyle.size = (int)((float)fstyle->size*scale);
+ fplotter->str_width(fplotter, &newstyle, str, length, width);
+ } else {
+ fplotter->str_width(fplotter, fstyle, str, length, width);
+ }
- return( true );
+ return NSERROR_OK;
}
-const struct font_functions nsfont = {
- atari_font_width,
- atari_font_position_in_string,
- atari_font_split
+
+static struct gui_layout_table layout_table = {
+ .width = atari_font_width,
+ .position = atari_font_position,
+ .split = atari_font_split,
};
+struct gui_layout_table *atari_layout_table = &layout_table;
diff --git a/atari/font.h b/atari/font.h
index 065a35a..a01d000 100644
--- a/atari/font.h
+++ b/atari/font.h
@@ -19,6 +19,7 @@
#ifndef NS_ATARI_FONT_H
#define NS_ATARI_FONT_H
+struct gui_layout_table *atari_layout_table;
#endif /* NETSURF_FB_FONT_H */
diff --git a/atari/gui.c b/atari/gui.c
index 5e5ef19..47b6693 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -35,7 +35,7 @@
#include "content/hlcache.h"
#include "desktop/treeview.h"
#include "desktop/browser.h"
-#include "desktop/font.h"
+#include "desktop/gui_layout.h"
#include "desktop/gui_window.h"
#include "desktop/gui_clipboard.h"
#include "desktop/gui_fetch.h"
@@ -66,6 +66,7 @@
#include "atari/file.h"
#include "atari/filetype.h"
#include "atari/bitmap.h"
+#include "atari/font.h"
#include "cflib.h"
static bool atari_quit = false;
@@ -1118,7 +1119,8 @@ int main(int argc, char** argv)
.utf8 = atari_utf8_table,
.search = atari_search_table,
.llcache = filesystem_llcache_table,
- .bitmap = atari_bitmap_table
+ .bitmap = atari_bitmap_table,
+ .layout = atari_layout_table
};
ret = netsurf_register(&atari_table);
diff --git a/windows/font.c b/windows/font.c
index 9358d1a..f67205a 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 ec596f3..f2128af 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 dfb3ad1..d2d0544 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;
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org