summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xamiga/font.c2
-rw-r--r--amiga/print.c2
-rw-r--r--atari/encoding.h2
-rwxr-xr-xatari/font.c2
-rw-r--r--atari/gui.c2
-rw-r--r--beos/font.cpp2
-rw-r--r--beos/plotters.cpp2
-rw-r--r--beos/scaffolding.cpp2
-rw-r--r--beos/thumbnail.cpp2
-rw-r--r--beos/window.cpp2
-rw-r--r--cocoa/font.m4
-rw-r--r--desktop/browser_history.c14
-rw-r--r--desktop/font.h97
-rw-r--r--desktop/save_pdf/font_haru.c2
-rw-r--r--desktop/save_pdf/font_haru.h2
-rw-r--r--desktop/selection.c18
-rw-r--r--desktop/textarea.c9
-rw-r--r--desktop/textinput.c20
-rw-r--r--desktop/tree.c11
-rw-r--r--desktop/treeview.c10
-rw-r--r--framebuffer/fbtk/text.c2
-rw-r--r--framebuffer/font_freetype.c2
-rw-r--r--framebuffer/font_internal.c4
-rw-r--r--gtk/font_pango.c7
-rw-r--r--gtk/plotters.c1
-rw-r--r--gtk/print.c7
-rw-r--r--gtk/scaffolding.c2
-rw-r--r--gtk/thumbnail.c8
-rw-r--r--monkey/font.c3
-rw-r--r--render/box_textarea.c3
-rw-r--r--render/font.c86
-rw-r--r--render/font.h86
-rw-r--r--render/form.c15
-rw-r--r--render/html.c2
-rw-r--r--render/html_interaction.c13
-rw-r--r--render/html_redraw.c17
-rw-r--r--render/layout.c9
-rw-r--r--render/textplain.c15
-rw-r--r--riscos/dialog.c1
-rw-r--r--riscos/font.c4
-rw-r--r--riscos/plotters.c2
-rw-r--r--riscos/thumbnail.c8
-rw-r--r--windows/font.c2
43 files changed, 270 insertions, 236 deletions
diff --git a/amiga/font.c b/amiga/font.c
index d1fcf7597..711aeb67d 100755
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -26,7 +26,7 @@
#include "amiga/schedule.h"
#include "utils/nsoption.h"
#include "desktop/browser.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/utils.h"
diff --git a/amiga/print.c b/amiga/print.c
index 66e5a558c..19c78d097 100644
--- a/amiga/print.c
+++ b/amiga/print.c
@@ -18,7 +18,7 @@
#include "desktop/printer.h"
#include "amiga/plotters.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "amiga/gui.h"
#include "utils/nsoption.h"
#include "amiga/print.h"
diff --git a/atari/encoding.h b/atari/encoding.h
index d0289b613..784aa8273 100644
--- a/atari/encoding.h
+++ b/atari/encoding.h
@@ -23,8 +23,6 @@
#include <assert.h>
#include <stdbool.h>
-#include "css/css.h"
-#include "render/font.h"
#include "utils/utf8.h"
struct gui_utf8_table *atari_utf8_table;
diff --git a/atari/font.c b/atari/font.c
index c55aca05a..24a18edef 100755
--- a/atari/font.c
+++ b/atari/font.c
@@ -39,7 +39,7 @@
#include <stdbool.h>
#include "css/css.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
diff --git a/atari/gui.c b/atari/gui.c
index f70c740d5..29991515e 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -50,7 +50,7 @@
#include "desktop/browser.h"
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
diff --git a/beos/font.cpp b/beos/font.cpp
index b262562d3..c52e9671c 100644
--- a/beos/font.cpp
+++ b/beos/font.cpp
@@ -32,7 +32,7 @@
#include <View.h>
extern "C" {
#include "css/css.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsoption.h"
diff --git a/beos/plotters.cpp b/beos/plotters.cpp
index 52ab4ec21..81d0e10e7 100644
--- a/beos/plotters.cpp
+++ b/beos/plotters.cpp
@@ -32,7 +32,7 @@
#include <Shape.h>
extern "C" {
#include "desktop/plotters.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp
index 7a00c02a9..b701b98f0 100644
--- a/beos/scaffolding.cpp
+++ b/beos/scaffolding.cpp
@@ -59,7 +59,7 @@ extern "C" {
#include "desktop/plotters.h"
#include "utils/nsoption.h"
#include "desktop/textinput.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "render/form.h"
#include "utils/messages.h"
#include "utils/utils.h"
diff --git a/beos/thumbnail.cpp b/beos/thumbnail.cpp
index 128462f57..12a7320ce 100644
--- a/beos/thumbnail.cpp
+++ b/beos/thumbnail.cpp
@@ -36,7 +36,7 @@ extern "C" {
#include "desktop/browser.h"
#include "desktop/thumbnail.h"
#include "image/bitmap.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/log.h"
}
#include "beos/scaffolding.h"
diff --git a/beos/window.cpp b/beos/window.cpp
index 3fa88ad33..886e20622 100644
--- a/beos/window.cpp
+++ b/beos/window.cpp
@@ -29,7 +29,7 @@ extern "C" {
#include "utils/nsoption.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/log.h"
#include "utils/types.h"
#include "utils/utf8.h"
diff --git a/cocoa/font.m b/cocoa/font.m
index 08fad0a36..3e28dea47 100644
--- a/cocoa/font.m
+++ b/cocoa/font.m
@@ -23,7 +23,7 @@
#import "css/css.h"
#import "utils/nsoption.h"
-#import "render/font.h"
+#import "desktop/font.h"
#import "desktop/plotters.h"
@@ -234,4 +234,4 @@ static inline NSDictionary *cocoa_font_attributes( const plot_font_style_t *styl
cocoa_font_get_nsfont( style ), NSFontAttributeName,
cocoa_convert_colour( style->foreground ), NSForegroundColorAttributeName,
nil];
-} \ No newline at end of file
+}
diff --git a/desktop/browser_history.c b/desktop/browser_history.c
index 8c21eed8e..1e8140626 100644
--- a/desktop/browser_history.c
+++ b/desktop/browser_history.c
@@ -18,7 +18,7 @@
*/
/** \file
- * Browser history tree (implementation).
+ * Browser history tree implementation.
*/
#include <assert.h>
@@ -27,20 +27,20 @@
#include <string.h>
#include <time.h>
+#include "utils/log.h"
+#include "utils/nsurl.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "css/css.h"
+#include "image/bitmap.h"
+
#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
#include "desktop/plotters.h"
#include "desktop/thumbnail.h"
-#include "image/bitmap.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/nsurl.h"
-#include "utils/utils.h"
-
+#include "desktop/font.h"
#define WIDTH 100
#define HEIGHT 86
diff --git a/desktop/font.h b/desktop/font.h
new file mode 100644
index 000000000..4ebd75d73
--- /dev/null
+++ b/desktop/font.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
+ * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 John Tytgat <joty@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Font handling interface.
+ *
+ * These functions provide font related services. They all work on
+ * UTF-8 strings with lengths given.
+ *
+ * Note that an interface to painting is not defined here. Painting is
+ * redirected through platform-dependent plotters anyway, so there is
+ * no gain in abstracting it here.
+ */
+
+#ifndef _NETSURF_DESKTOP_FONT_H_
+#define _NETSURF_DESKTOP_FONT_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#include "desktop/plot_style.h"
+
+struct font_functions
+{
+ /**
+ * Measure the width of a string.
+ *
+ * \param fstyle plot style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string, in bytes
+ * \param width updated to width of string[0..length)
+ * \return true on success, false on error and error reported
+ */
+ bool (*font_width)(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int *width);
+ /**
+ * Find the position in a string where an x coordinate falls.
+ *
+ * \param fstyle style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string, in bytes
+ * \param x x coordinate to search for
+ * \param char_offset updated to offset in string of actual_x, [0..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ */
+ bool (*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);
+ /**
+ * Find where to split a string to make it fit a width.
+ *
+ * \param fstyle style for this text
+ * \param string UTF-8 string to measure
+ * \param length length of string, in bytes
+ * \param x width available
+ * \param char_offset updated to offset in string of actual_x, [1..length]
+ * \param actual_x updated to x coordinate of character closest to x
+ * \return true on success, false on error and error reported
+ *
+ * On exit, char_offset indicates first character after split point.
+ *
+ * Note: char_offset of 0 should 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
+ */
+ bool (*font_split)(const plot_font_style_t *fstyle,
+ const char *string, size_t length,
+ int x, size_t *char_offset, int *actual_x);
+};
+
+extern const struct font_functions nsfont;
+
+#endif
diff --git a/desktop/save_pdf/font_haru.c b/desktop/save_pdf/font_haru.c
index 57d36fe95..e8643f701 100644
--- a/desktop/save_pdf/font_haru.c
+++ b/desktop/save_pdf/font_haru.c
@@ -41,7 +41,7 @@
#include "utils/nsoption.h"
#include "desktop/save_pdf/font_haru.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/log.h"
diff --git a/desktop/save_pdf/font_haru.h b/desktop/save_pdf/font_haru.h
index 0dd6dc0c4..c6578b09f 100644
--- a/desktop/save_pdf/font_haru.h
+++ b/desktop/save_pdf/font_haru.h
@@ -26,8 +26,8 @@
#include <hpdf.h>
-#include "render/font.h"
#include "desktop/plot_style.h"
+#include "desktop/font.h"
bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
HPDF_Doc doc, HPDF_Page page,
diff --git a/desktop/selection.c b/desktop/selection.c
index 34292fdce..ec01e5b81 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -28,21 +28,21 @@
#include <string.h>
#include <dom/dom.h>
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "render/box.h"
+#include "render/form.h"
+#include "render/html_internal.h"
+#include "render/font.h"
+#include "render/textplain.h"
+
#include "desktop/browser_private.h"
#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/plotters.h"
#include "desktop/save_text.h"
#include "desktop/selection.h"
-#include "render/box.h"
-#include "render/font.h"
-#include "render/form.h"
-#include "render/html_internal.h"
-#include "render/textplain.h"
-#include "utils/log.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
-
/**
* Text selection works by labelling each node in the box tree with its
diff --git a/desktop/textarea.c b/desktop/textarea.c
index d29e5f247..8b84f3279 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -23,18 +23,19 @@
#include <stdint.h>
#include <string.h>
+
#include "css/utils.h"
+#include "utils/log.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
#include "desktop/mouse.h"
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "desktop/plotters.h"
#include "desktop/scrollbar.h"
+#include "desktop/font.h"
#include "desktop/gui_factory.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
#define CARET_COLOR 0x0000FF
#define TA_ALLOC_STEP 512
diff --git a/desktop/textinput.c b/desktop/textinput.c
index fd6ae9ff1..cf0697a2e 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -21,7 +21,7 @@
*/
/** \file
- * Textual input handling (implementation)
+ * Textual input handling implementation
*/
#include <assert.h>
@@ -29,21 +29,21 @@
#include <string.h>
#include <dom/dom.h>
+#include "utils/log.h"
+#include "utils/talloc.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
+#include "render/box.h"
+#include "render/form.h"
+#include "render/html_internal.h"
+#include "render/layout.h"
+
#include "desktop/browser_private.h"
#include "desktop/gui_factory.h"
#include "desktop/mouse.h"
#include "desktop/scrollbar.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
-#include "render/box.h"
-#include "render/font.h"
-#include "render/form.h"
-#include "render/html_internal.h"
-#include "render/layout.h"
-#include "utils/log.h"
-#include "utils/talloc.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
/* Define to enable textinput debug */
#undef TEXTINPUT_DEBUG
diff --git a/desktop/tree.c b/desktop/tree.c
index c29afa761..975f74409 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -26,16 +26,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "css/utils.h"
+#include "utils/nsoption.h"
+
#include "desktop/browser.h"
#include "desktop/tree.h"
-#include "utils/nsoption.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
struct tree {
unsigned int flags; /* Tree flags */
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 484d279cf..4e597e0b5 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -16,14 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Treeview handling (implementation).
+/**
+ * \file
+ *
+ * Treeview handling implementation.
*/
#include "utils/log.h"
#include "css/utils.h"
#include "image/bitmap.h"
-#include "render/font.h"
#include "content/hlcache.h"
#include "desktop/system_colour.h"
@@ -31,8 +32,9 @@
#include "desktop/plotters.h"
#include "desktop/textarea.h"
#include "desktop/treeview.h"
+#include "desktop/font.h"
-/* TODO: get rid of REDRAW_MAX -- need to be able to know window size */
+/** @todo get rid of REDRAW_MAX -- need to be able to know window size */
#define REDRAW_MAX 8000
struct treeview_globals {
diff --git a/framebuffer/fbtk/text.c b/framebuffer/fbtk/text.c
index b05271b44..f15586a92 100644
--- a/framebuffer/fbtk/text.c
+++ b/framebuffer/fbtk/text.c
@@ -29,7 +29,7 @@
#include "utils/log.h"
#include "desktop/browser.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "framebuffer/gui.h"
#include "framebuffer/fbtk.h"
diff --git a/framebuffer/font_freetype.c b/framebuffer/font_freetype.c
index eaaf2f099..3469a95ec 100644
--- a/framebuffer/font_freetype.c
+++ b/framebuffer/font_freetype.c
@@ -27,8 +27,8 @@
#include "utils/utf8.h"
#include "utils/log.h"
#include "utils/nsoption.h"
-#include "render/font.h"
#include "desktop/gui.h"
+#include "desktop/font.h"
#include "desktop/browser.h"
#include "framebuffer/gui.h"
diff --git a/framebuffer/font_internal.c b/framebuffer/font_internal.c
index 9b850d5c8..4ac850448 100644
--- a/framebuffer/font_internal.c
+++ b/framebuffer/font_internal.c
@@ -20,12 +20,12 @@
#include <inttypes.h>
#include <string.h>
#include <assert.h>
+#include <stdlib.h>
#include "utils/nsoption.h"
#include "utils/utf8.h"
#include "desktop/gui.h"
-#include "css/css.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "framebuffer/gui.h"
#include "framebuffer/font.h"
diff --git a/gtk/font_pango.c b/gtk/font_pango.c
index 1cb536e9e..c49b32b25 100644
--- a/gtk/font_pango.c
+++ b/gtk/font_pango.c
@@ -27,12 +27,13 @@
#include <stdio.h>
#include <gtk/gtk.h>
-#include "gtk/font_pango.h"
-#include "gtk/plotters.h"
-#include "render/font.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/nsoption.h"
+#include "desktop/font.h"
+
+#include "gtk/font_pango.h"
+#include "gtk/plotters.h"
static bool nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/gtk/plotters.c b/gtk/plotters.c
index b2a7edecc..de0bf9d48 100644
--- a/gtk/plotters.c
+++ b/gtk/plotters.c
@@ -33,7 +33,6 @@
#include "utils/log.h"
#include "desktop/plotters.h"
-#include "render/font.h"
#include "utils/nsoption.h"
#include "gtk/font_pango.h"
diff --git a/gtk/print.c b/gtk/print.c
index 68a96dc2d..e5870267a 100644
--- a/gtk/print.c
+++ b/gtk/print.c
@@ -31,19 +31,20 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
+#include "utils/log.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
+#include "desktop/font.h"
+
#include "gtk/font_pango.h"
#include "gtk/bitmap.h"
#include "gtk/print.h"
#include "gtk/scaffolding.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/utils.h"
/* Globals */
cairo_t *gtk_print_current_cr;
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index 4706c6f60..4be27c7db 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -44,7 +44,7 @@
#include "desktop/save_text.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "render/html.h"
#include "content/hlcache.h"
diff --git a/gtk/thumbnail.c b/gtk/thumbnail.c
index 19c5fc193..4bdab7485 100644
--- a/gtk/thumbnail.c
+++ b/gtk/thumbnail.c
@@ -28,19 +28,19 @@
#include <gtk/gtk.h>
#include <gdk/gdk.h>
+#include "utils/log.h"
+#include "utils/utils.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/plotters.h"
#include "desktop/browser.h"
#include "desktop/thumbnail.h"
+#include "image/bitmap.h"
+
#include "gtk/scaffolding.h"
#include "gtk/plotters.h"
#include "gtk/bitmap.h"
-#include "image/bitmap.h"
-#include "render/font.h"
-#include "utils/log.h"
-#include "utils/utils.h"
/**
* Create a thumbnail of a page.
diff --git a/monkey/font.c b/monkey/font.c
index c4f4bffe1..3b6ca4fdc 100644
--- a/monkey/font.c
+++ b/monkey/font.c
@@ -16,10 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "render/font.h"
#include "utils/nsoption.h"
#include "utils/utf8.h"
-
+#include "desktop/font.h"
static bool nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
diff --git a/render/box_textarea.c b/render/box_textarea.c
index a1bbb539e..1a431ed88 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -25,10 +25,11 @@
#include "desktop/browser.h"
#include "desktop/textarea.h"
#include "desktop/textinput.h"
+#include "utils/log.h"
+
#include "render/box_textarea.h"
#include "render/font.h"
#include "render/form.h"
-#include "utils/log.h"
bool box_textarea_keypress(html_content *html, struct box *box, uint32_t key)
diff --git a/render/font.c b/render/font.c
index 03c5a36fb..0b059a218 100644
--- a/render/font.c
+++ b/render/font.c
@@ -16,54 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "css/css.h"
-#include "css/utils.h"
-#include "utils/nsoption.h"
-#include "render/font.h"
-
-static plot_font_generic_family_t plot_font_generic_family(
- enum css_font_family_e css);
-static int plot_font_weight(enum css_font_weight_e css);
-static plot_font_flags_t plot_font_flags(enum css_font_style_e style,
- enum css_font_variant_e variant);
-
/**
- * Populate a font style using data from a computed CSS style
+ * \file
*
- * \param css Computed style to consider
- * \param fstyle Font style to populate
+ * Renderer internal font handling implementation.
*/
-void font_plot_style_from_css(const css_computed_style *css,
- plot_font_style_t *fstyle)
-{
- lwc_string **families;
- css_fixed length = 0;
- css_unit unit = CSS_UNIT_PX;
- css_color col;
- fstyle->family = plot_font_generic_family(
- css_computed_font_family(css, &families));
-
- css_computed_font_size(css, &length, &unit);
- fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit),
- INTTOFIX(FONT_SIZE_SCALE)));
-
- /* Clamp font size to configured minimum */
- if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10)
- fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10;
-
- fstyle->weight = plot_font_weight(css_computed_font_weight(css));
- fstyle->flags = plot_font_flags(css_computed_font_style(css),
- css_computed_font_variant(css));
-
- css_computed_color(css, &col);
- fstyle->foreground = nscss_color_to_ns(col);
- fstyle->background = 0;
-}
+#include "css/css.h"
+#include "css/utils.h"
+#include "utils/nsoption.h"
-/******************************************************************************
- * Helper functions *
- ******************************************************************************/
+#include "render/font.h"
/**
* Map a generic CSS font family to a generic plot font family
@@ -71,7 +34,7 @@ void font_plot_style_from_css(const css_computed_style *css,
* \param css Generic CSS font family
* \return Plot font family
*/
-plot_font_generic_family_t plot_font_generic_family(
+static plot_font_generic_family_t plot_font_generic_family(
enum css_font_family_e css)
{
plot_font_generic_family_t plot;
@@ -104,7 +67,7 @@ plot_font_generic_family_t plot_font_generic_family(
* \param css CSS font weight
* \return Plot weight
*/
-int plot_font_weight(enum css_font_weight_e css)
+static int plot_font_weight(enum css_font_weight_e css)
{
int weight;
@@ -146,12 +109,12 @@ int plot_font_weight(enum css_font_weight_e css)
/**
* Map a CSS font style and font variant to plot font flags
- *
+ *
* \param style CSS font style
* \param variant CSS font variant
* \return Computed plot flags
*/
-plot_font_flags_t plot_font_flags(enum css_font_style_e style,
+static plot_font_flags_t plot_font_flags(enum css_font_style_e style,
enum css_font_variant_e variant)
{
plot_font_flags_t flags = FONTF_NONE;
@@ -167,3 +130,32 @@ plot_font_flags_t plot_font_flags(enum css_font_style_e style,
return flags;
}
+
+/* exported function documented in render/font_internal.h */
+void font_plot_style_from_css(const css_computed_style *css,
+ plot_font_style_t *fstyle)
+{
+ lwc_string **families;
+ css_fixed length = 0;
+ css_unit unit = CSS_UNIT_PX;
+ css_color col;
+
+ fstyle->family = plot_font_generic_family(
+ css_computed_font_family(css, &families));
+
+ css_computed_font_size(css, &length, &unit);
+ fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit),
+ INTTOFIX(FONT_SIZE_SCALE)));
+
+ /* Clamp font size to configured minimum */
+ if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10)
+ fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10;
+
+ fstyle->weight = plot_font_weight(css_computed_font_weight(css));
+ fstyle->flags = plot_font_flags(css_computed_font_style(css),
+ css_computed_font_variant(css));
+
+ css_computed_color(css, &col);
+ fstyle->foreground = nscss_color_to_ns(col);
+ fstyle->background = 0;
+}
diff --git a/render/font.h b/render/font.h
index bc8df2335..e4353df64 100644
--- a/render/font.h
+++ b/render/font.h
@@ -1,7 +1,5 @@
/*
- * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
- * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
- * Copyright 2004 John Tytgat <joty@netsurf-browser.org>
+ * Copyright 2014 Vincent Sanders <vince@netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,83 +17,23 @@
*/
/** \file
- * Font handling (interface).
*
- * These functions provide font related services. They all work on UTF-8 strings
- * with lengths given.
+ * Internal font handling interfaces.
*
- * Note that an interface to painting is not defined here. Painting is
- * redirected through platform-dependent plotters anyway, so there is no gain in
- * abstracting it here.
+ * These functions provide font related services. They all work on
+ * UTF-8 strings with lengths given.
*/
#ifndef _NETSURF_RENDER_FONT_H_
#define _NETSURF_RENDER_FONT_H_
-#include <stdbool.h>
-#include <stddef.h>
-
-#include "css/css.h"
-#include "desktop/plot_style.h"
-
-struct font_functions
-{
- /**
- * Measure the width of a string.
- *
- * \param fstyle plot style for this text
- * \param string UTF-8 string to measure
- * \param length length of string, in bytes
- * \param width updated to width of string[0..length)
- * \return true on success, false on error and error reported
- */
- bool (*font_width)(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int *width);
- /**
- * Find the position in a string where an x coordinate falls.
- *
- * \param fstyle style for this text
- * \param string UTF-8 string to measure
- * \param length length of string, in bytes
- * \param x x coordinate to search for
- * \param char_offset updated to offset in string of actual_x, [0..length]
- * \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
- */
- bool (*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);
- /**
- * Find where to split a string to make it fit a width.
- *
- * \param fstyle style for this text
- * \param string UTF-8 string to measure
- * \param length length of string, in bytes
- * \param x width available
- * \param char_offset updated to offset in string of actual_x, [1..length]
- * \param actual_x updated to x coordinate of character closest to x
- * \return true on success, false on error and error reported
- *
- * On exit, char_offset indicates first character after split point.
- *
- * Note: char_offset of 0 should 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
- */
- bool (*font_split)(const plot_font_style_t *fstyle,
- const char *string, size_t length,
- int x, size_t *char_offset, int *actual_x);
-};
-
-extern const struct font_functions nsfont;
-
-void font_plot_style_from_css(const css_computed_style *css,
- plot_font_style_t *fstyle);
+/**
+ * Populate a font style using data from a computed CSS style
+ *
+ * \param css Computed style to consider
+ * \param fstyle Font style to populate
+ */
+void font_plot_style_from_css(const css_computed_style *css,
+ plot_font_style_t *fstyle);
#endif
diff --git a/render/form.c b/render/form.c
index 76a67ba5c..3dd3a6cdd 100644
--- a/render/form.c
+++ b/render/form.c
@@ -33,6 +33,13 @@
#include <string.h>
#include <dom/dom.h>
+#include "utils/corestrings.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/talloc.h"
+#include "utils/url.h"
+#include "utils/utf8.h"
+#include "utils/utils.h"
#include "content/fetch.h"
#include "content/hlcache.h"
#include "css/css.h"
@@ -43,19 +50,13 @@
#include "desktop/plotters.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
+
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
#include "render/html.h"
#include "render/html_internal.h"
#include "render/layout.h"
-#include "utils/corestrings.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/talloc.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
#define MAX_SELECT_HEIGHT 210
#define SELECT_LINE_SPACING 0.2
diff --git a/render/html.c b/render/html.c
index 36f6e807d..7ab8fb5bd 100644
--- a/render/html.c
+++ b/render/html.c
@@ -47,9 +47,9 @@
#include "image/bitmap.h"
#include "javascript/js.h"
#include "desktop/gui_factory.h"
+#include "desktop/font.h"
#include "render/box.h"
-#include "render/font.h"
#include "render/form.h"
#include "render/html_internal.h"
#include "render/imagemap.h"
diff --git a/render/html_interaction.c b/render/html_interaction.c
index 279eb4058..0d05485f2 100644
--- a/render/html_interaction.c
+++ b/render/html_interaction.c
@@ -28,6 +28,10 @@
#include <dom/dom.h>
+#include "utils/corestrings.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/log.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "desktop/browser.h"
@@ -39,6 +43,9 @@
#include "desktop/selection.h"
#include "desktop/textarea.h"
#include "desktop/textinput.h"
+#include "desktop/font.h"
+#include "javascript/js.h"
+
#include "render/box.h"
#include "render/box_textarea.h"
#include "render/font.h"
@@ -46,12 +53,6 @@
#include "render/html_internal.h"
#include "render/imagemap.h"
#include "render/search.h"
-#include "javascript/js.h"
-#include "utils/corestrings.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-
/**
* Get pointer shape for given box
diff --git a/render/html_redraw.c b/render/html_redraw.c
index 92b70fec7..12ed1d3d4 100644
--- a/render/html_redraw.c
+++ b/render/html_redraw.c
@@ -22,8 +22,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
- * Redraw of a CONTENT_HTML (implementation).
+/**
+ * \file
+ *
+ * Redrawing CONTENT_HTML implementation.
*/
#include <assert.h>
@@ -32,7 +34,11 @@
#include <string.h>
#include <math.h>
#include <dom/dom.h>
+
#include "utils/config.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
#include "content/content_protected.h"
#include "css/css.h"
#include "css/utils.h"
@@ -42,18 +48,15 @@
#include "desktop/print.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
+#include "desktop/font.h"
#include "image/bitmap.h"
+
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "render/search.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
-
bool html_redraw_debug = false;
diff --git a/render/layout.c b/render/layout.c
index ab2dd6cc1..79961094f 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -41,21 +41,24 @@
#include <string.h>
#include <math.h>
#include <dom/dom.h>
+
+#include "utils/log.h"
+#include "utils/talloc.h"
+#include "utils/utils.h"
#include "css/css.h"
#include "css/utils.h"
#include "content/content_protected.h"
#include "utils/nsoption.h"
#include "desktop/scrollbar.h"
#include "desktop/textarea.h"
+#include "desktop/font.h"
+
#include "render/box.h"
#include "render/font.h"
#include "render/form.h"
#include "render/html_internal.h"
#include "render/layout.h"
#include "render/table.h"
-#include "utils/log.h"
-#include "utils/talloc.h"
-#include "utils/utils.h"
/* Define to enable layout debugging */
diff --git a/render/textplain.c b/render/textplain.c
index 86c87330d..9d87fbf1e 100644
--- a/render/textplain.c
+++ b/render/textplain.c
@@ -31,6 +31,12 @@
#include <parserutils/input/inputstream.h>
#include <parserutils/charset/utf8.h>
+#include "utils/corestrings.h"
+#include "utils/http.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/utf8.h"
#include "content/content_protected.h"
#include "content/hlcache.h"
#include "css/css.h"
@@ -41,17 +47,12 @@
#include "desktop/search.h"
#include "desktop/selection.h"
#include "desktop/textinput.h"
-#include "render/font.h"
+#include "desktop/font.h"
+
#include "render/search.h"
#include "render/textplain.h"
#include "render/html.h"
#include "render/search.h"
-#include "utils/corestrings.h"
-#include "utils/http.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/utf8.h"
struct textplain_line {
size_t start;
diff --git a/riscos/dialog.c b/riscos/dialog.c
index fd854b857..0244860cc 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -42,7 +42,6 @@
#include "utils/utils.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
-#include "render/font.h"
#include "riscos/configure.h"
#include "riscos/cookies.h"
diff --git a/riscos/font.c b/riscos/font.c
index 7e6c80fe5..db6376a88 100644
--- a/riscos/font.c
+++ b/riscos/font.c
@@ -29,13 +29,11 @@
#include <oslib/wimp.h>
#include <oslib/wimpreadsysinfo.h>
-#include "css/css.h"
-#include "css/utils.h"
-#include "render/font.h"
#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
+#include "desktop/font.h"
#include "riscos/gui.h"
#include "riscos/font.h"
diff --git a/riscos/plotters.c b/riscos/plotters.c
index 6e49c2278..e3745c5ba 100644
--- a/riscos/plotters.c
+++ b/riscos/plotters.c
@@ -28,7 +28,6 @@
#include "utils/log.h"
#include "desktop/plotters.h"
-#include "render/font.h"
#include "riscos/bitmap.h"
#include "riscos/image.h"
@@ -36,7 +35,6 @@
#include "riscos/font.h"
#include "riscos/oslib_pre7.h"
-
static bool ro_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool ro_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool ro_plot_draw_path(const draw_path * const path, int width,
diff --git a/riscos/thumbnail.c b/riscos/thumbnail.c
index 2bdd37251..e259686f8 100644
--- a/riscos/thumbnail.c
+++ b/riscos/thumbnail.c
@@ -31,21 +31,21 @@
#include "oslib/colourtrans.h"
#include "oslib/osfile.h"
#include "oslib/osspriteop.h"
+
+#include "utils/nsoption.h"
+#include "utils/log.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/plotters.h"
#include "desktop/thumbnail.h"
#include "image/bitmap.h"
-#include "render/font.h"
+
#include "riscos/bitmap.h"
#include "riscos/gui.h"
-#include "utils/nsoption.h"
#include "riscos/oslib_pre7.h"
#include "riscos/thumbnail.h"
#include "riscos/tinct.h"
-#include "utils/log.h"
-
/* Whether we can use 32bpp sprites
*/
diff --git a/windows/font.c b/windows/font.c
index 09adeeda7..6e1efdc6a 100644
--- a/windows/font.c
+++ b/windows/font.c
@@ -27,7 +27,7 @@
#include <windows.h>
#include "css/css.h"
-#include "render/font.h"
+#include "desktop/font.h"
#include "utils/nsoption.h"
#include "utils/utf8.h"