summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-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
9 files changed, 93 insertions, 153 deletions
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;