summaryrefslogtreecommitdiff
path: root/render/font.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-10-13 11:56:31 +0100
committerVincent Sanders <vince@kyllikki.org>2014-10-13 11:56:31 +0100
commit17be8cf216e08a57c511ec1ea43eae40874fa9de (patch)
tree270667cd4a3418b185e5432be1c7c8b7dca8792f /render/font.c
parent33c6073dbed882506e5a16fc43e7e2a71a2d6be2 (diff)
downloadnetsurf-17be8cf216e08a57c511ec1ea43eae40874fa9de.tar.gz
netsurf-17be8cf216e08a57c511ec1ea43eae40874fa9de.tar.bz2
Put the font operations table alongside all the other core API
The netsurf core is driven from numerous operation tables most of which are now set through a common netsurf_register() interface. The font and plotting interfaces are currently separate and unlike all the other operation tables are modified for differing contexts. This change moves the font operations alongside all the other operations table and remove unnecessary interaction with the renderers font internals. Further this also removes the need for css internals to be visible in frontends.
Diffstat (limited to 'render/font.c')
-rw-r--r--render/font.c86
1 files changed, 39 insertions, 47 deletions
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;
+}