Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/a40dca49e8493802d7064...
...commit
http://git.netsurf-browser.org/netsurf.git/commit/a40dca49e8493802d7064bd...
...tree
http://git.netsurf-browser.org/netsurf.git/tree/a40dca49e8493802d7064bd8e...
The branch, master has been updated
via a40dca49e8493802d7064bd8e6aaab03436568ee (commit)
via 8a931f01b958ad5862433ece6024bbde0aa4ecb8 (commit)
via 8332bf6b2a42fd03b864e46f60eeaa76b51da496 (commit)
via 5f4f23f11a1c2aaa85df6bb58f0be6e66fa7cc7b (commit)
via 66493421e65d8cbda3e17fdbe43824387e3d51a7 (commit)
via a58d97a41a6192038573da6862571dc72a560458 (commit)
from 6cabd4cd628833afa32aeb7c614ef153b4a1c985 (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=a40dca49e8493802d70...
commit a40dca49e8493802d7064bd8e6aaab03436568ee
Merge: 6cabd4c 8a931f0
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Merge branch 'tlsa/plotter-polish'
-----------------------------------------------------------------------
Summary of changes:
content/handlers/html/box_textarea.c | 2 +-
content/handlers/html/font.c | 7 +--
content/handlers/html/form.c | 2 +-
content/handlers/html/html_redraw_border.c | 2 +-
content/handlers/image/svg.c | 13 ++---
content/handlers/text/textplain.c | 6 +--
desktop/font_haru.c | 2 +-
desktop/knockout.c | 4 +-
desktop/local_history.c | 10 ++--
desktop/plot_style.c | 14 +++---
desktop/save_pdf.c | 16 +++----
desktop/scrollbar.c | 6 +--
desktop/textarea.c | 10 ++--
desktop/treeview.c | 2 +-
frontends/amiga/dt_sound.c | 2 +-
frontends/amiga/font_bullet.c | 4 +-
frontends/amiga/font_diskfont.c | 2 +-
frontends/amiga/plotters.c | 10 ++--
frontends/amiga/plugin_hack.c | 2 +-
frontends/atari/plot/font_freetype.c | 2 +-
frontends/atari/plot/font_vdi.c | 14 +++---
frontends/atari/plot/plot.c | 8 ++--
frontends/atari/toolbar.c | 4 +-
frontends/beos/font.cpp | 2 +-
frontends/beos/plotters.cpp | 8 ++--
frontends/framebuffer/fbtk/text.c | 2 +-
frontends/framebuffer/font_freetype.c | 2 +-
frontends/framebuffer/font_internal.c | 2 +-
frontends/framebuffer/framebuffer.c | 8 ++--
frontends/gtk/layout_pango.c | 2 +-
frontends/gtk/plotters.c | 33 +++++++------
frontends/gtk/print.c | 32 ++++++-------
frontends/monkey/layout.c | 10 ++--
frontends/monkey/plot.c | 6 +--
frontends/riscos/font.c | 2 +-
frontends/riscos/plotters.c | 20 ++++----
frontends/riscos/print.c | 1 -
frontends/riscos/save_draw.c | 9 ++--
frontends/windows/font.c | 2 +-
frontends/windows/plot.c | 10 ++--
include/netsurf/plot_style.h | 34 +++++++++++--
include/netsurf/plotters.h | 72 +++++++++++++++++++++++-----
42 files changed, 232 insertions(+), 169 deletions(-)
diff --git a/content/handlers/html/box_textarea.c b/content/handlers/html/box_textarea.c
index 858de50..c19afbb 100644
--- a/content/handlers/html/box_textarea.c
+++ b/content/handlers/html/box_textarea.c
@@ -244,7 +244,7 @@ bool box_textarea_create_textarea(html_content *html,
textarea_flags ta_flags;
plot_font_style_t fstyle = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 10 * FONT_SIZE_SCALE,
+ .size = 10 * PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0,
diff --git a/content/handlers/html/font.c b/content/handlers/html/font.c
index 9dbf592..7ebe168 100644
--- a/content/handlers/html/font.c
+++ b/content/handlers/html/font.c
@@ -144,14 +144,15 @@ void font_plot_style_from_css(
fstyle->family = plot_font_generic_family(
css_computed_font_family(css, &families));
+ fstyle->families = families;
css_computed_font_size(css, &length, &unit);
fstyle->size = FIXTOINT(FMUL(nscss_len2pt(len_ctx, length, unit),
- INTTOFIX(FONT_SIZE_SCALE)));
+ INTTOFIX(PLOT_STYLE_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;
+ if (fstyle->size < (nsoption_int(font_min_size) * PLOT_STYLE_SCALE) / 10)
+ fstyle->size = (nsoption_int(font_min_size) * PLOT_STYLE_SCALE) / 10;
fstyle->weight = plot_font_weight(css_computed_font_weight(css));
fstyle->flags = plot_font_flags(css_computed_font_style(css),
diff --git a/content/handlers/html/form.c b/content/handlers/html/form.c
index 9fe2e77..8ba99d4 100644
--- a/content/handlers/html/form.c
+++ b/content/handlers/html/form.c
@@ -1160,7 +1160,7 @@ bool form_open_select_menu(void *client_data,
menu->line_height = FIXTOINT(FDIV((FMUL(FLTTOFIX(1.2),
FMUL(nscss_screen_dpi,
- INTTOFIX(fstyle.size / FONT_SIZE_SCALE)))),
+ INTTOFIX(fstyle.size / PLOT_STYLE_SCALE)))),
F_72));
line_height_with_spacing = menu->line_height +
diff --git a/content/handlers/html/html_redraw_border.c
b/content/handlers/html/html_redraw_border.c
index 2a849e8..0b3d858 100644
--- a/content/handlers/html/html_redraw_border.c
+++ b/content/handlers/html/html_redraw_border.c
@@ -111,7 +111,7 @@ html_redraw_border_plot(const int side,
plot_style_bdr.stroke_type = PLOT_OP_TYPE_DASH;
plot_style_bdr.stroke_colour = c;
- plot_style_bdr.stroke_width = thickness;
+ plot_style_bdr.stroke_width = (thickness << PLOT_STYLE_RADIX);
plot_style_fillbdr.fill_colour = c;
plot_style_fillbdr_dark.fill_colour = darken_colour(c);
plot_style_fillbdr_light.fill_colour = lighten_colour(c);
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index 2edc7bd..5126073 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -188,14 +188,15 @@ svg_redraw_internal(struct content *c,
for (i = 0; i != diagram->shape_count; i++) {
if (diagram->shape[i].path) {
+ pstyle.stroke_width = plot_style_int_to_fixed(
+ diagram->shape[i].stroke);
pstyle.stroke_colour = BGR(diagram->shape[i].stroke);
pstyle.fill_colour = BGR(diagram->shape[i].fill);
res = ctx->plot->path(ctx,
- &pstyle,
- diagram->shape[i].path,
- diagram->shape[i].path_length,
- diagram->shape[i].stroke_width,
- transform);
+ &pstyle,
+ diagram->shape[i].path,
+ diagram->shape[i].path_length,
+ transform);
if (res != NSERROR_OK) {
return false;
}
@@ -210,7 +211,7 @@ svg_redraw_internal(struct content *c,
fstyle.background = 0xffffff;
fstyle.foreground = 0x000000;
- fstyle.size = (8 * FONT_SIZE_SCALE) * scale;
+ fstyle.size = (8 * PLOT_STYLE_SCALE) * scale;
res = ctx->plot->text(ctx,
&fstyle,
diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c
index e6d167b..af990d1 100644
--- a/content/handlers/text/textplain.c
+++ b/content/handlers/text/textplain.c
@@ -86,7 +86,7 @@ typedef struct textplain_content {
#define MARGIN 4
#define TAB_WIDTH 8 /* must be power of 2 currently */
-#define TEXT_SIZE 10 * FONT_SIZE_SCALE /* Unscaled text size in pt */
+#define TEXT_SIZE 10 * PLOT_STYLE_SCALE /* Unscaled text size in pt */
static plot_font_style_t textplain_style = {
.family = PLOT_FONT_FAMILY_MONOSPACE,
@@ -149,7 +149,7 @@ textplain_create_internal(textplain_content *c, lwc_string *encoding)
parserutils_inputstream *stream;
parserutils_error error;
- textplain_style.size = (nsoption_int(font_size) * FONT_SIZE_SCALE) / 10;
+ textplain_style.size = (nsoption_int(font_size) * PLOT_STYLE_SCALE) / 10;
utf8_data = malloc(CHUNK);
if (utf8_data == NULL)
@@ -400,7 +400,7 @@ static float textplain_line_height(void)
/* Size is in points, so convert to pixels.
* Then use a constant line height of 1.2 x font size.
*/
- return FIXTOFLT(FDIV((FMUL(FLTTOFIX(1.2), FMUL(nscss_screen_dpi,
INTTOFIX((textplain_style.size / FONT_SIZE_SCALE))))), F_72));
+ return FIXTOFLT(FDIV((FMUL(FLTTOFIX(1.2), FMUL(nscss_screen_dpi,
INTTOFIX((textplain_style.size / PLOT_STYLE_SCALE))))), F_72));
}
diff --git a/desktop/font_haru.c b/desktop/font_haru.c
index f92d891..4ee9824 100644
--- a/desktop/font_haru.c
+++ b/desktop/font_haru.c
@@ -352,7 +352,7 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
if (size <= 0)
return true;
- size /= FONT_SIZE_SCALE;
+ size /= PLOT_STYLE_SCALE;
if (size > HPDF_MAX_FONTSIZE)
size = HPDF_MAX_FONTSIZE;
diff --git a/desktop/knockout.c b/desktop/knockout.c
index 6dbf4eb..127a48c 100644
--- a/desktop/knockout.c
+++ b/desktop/knockout.c
@@ -671,7 +671,6 @@ knockout_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -680,14 +679,13 @@ knockout_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
nserror res;
nserror ffres;
ffres = knockout_plot_flush(ctx);
- res = real_plot.path(ctx, pstyle, p, n, width, transform);
+ res = real_plot.path(ctx, pstyle, p, n, transform);
/* return the first error */
if ((res != NSERROR_OK) && (ffres == NSERROR_OK)) {
diff --git a/desktop/local_history.c b/desktop/local_history.c
index 3219de9..75da4af 100644
--- a/desktop/local_history.c
+++ b/desktop/local_history.c
@@ -55,7 +55,7 @@ struct local_history_session {
*/
static plot_style_t pstyle_line = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 2,
+ .stroke_width = plot_style_int_to_fixed(2),
};
@@ -72,7 +72,7 @@ static plot_style_t pstyle_bg = {
*/
static plot_style_t pstyle_rect = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
@@ -81,7 +81,7 @@ static plot_style_t pstyle_rect = {
*/
static plot_style_t pstyle_rect_sel = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 3,
+ .stroke_width = plot_style_int_to_fixed(3),
};
@@ -90,7 +90,7 @@ static plot_style_t pstyle_rect_sel = {
*/
static plot_font_style_t pfstyle_node = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 8 * FONT_SIZE_SCALE,
+ .size = 8 * PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
};
@@ -101,7 +101,7 @@ static plot_font_style_t pfstyle_node = {
*/
static plot_font_style_t pfstyle_node_sel = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 8 * FONT_SIZE_SCALE,
+ .size = 8 * PLOT_STYLE_SCALE,
.weight = 900,
.flags = FONTF_NONE,
};
diff --git a/desktop/plot_style.c b/desktop/plot_style.c
index 1f0ac39..0595414 100644
--- a/desktop/plot_style.c
+++ b/desktop/plot_style.c
@@ -47,7 +47,7 @@ plot_style_t *plot_style_fill_red = &plot_style_fill_red_static;
static const plot_style_t plot_style_content_edge_static = {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_colour = 0x00ff0000,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
plot_style_t const * const plot_style_content_edge =
&plot_style_content_edge_static;
@@ -55,7 +55,7 @@ plot_style_t const * const plot_style_content_edge =
static const plot_style_t plot_style_padding_edge_static = {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_colour = 0x000000ff,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
plot_style_t const * const plot_style_padding_edge =
&plot_style_padding_edge_static;
@@ -63,7 +63,7 @@ plot_style_t const * const plot_style_padding_edge =
static const plot_style_t plot_style_margin_edge_static = {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_colour = 0x0000ffff,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
plot_style_t const * const plot_style_margin_edge =
&plot_style_margin_edge_static;
@@ -74,14 +74,14 @@ static const plot_style_t plot_style_broken_object_static = {
.fill_colour = 0x008888ff,
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_colour = 0x000000ff,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
plot_style_t const * const plot_style_broken_object =
&plot_style_broken_object_static;
static const plot_font_style_t plot_fstyle_broken_object_static = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 16 * FONT_SIZE_SCALE,
+ .size = 16 * PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0x8888ff,
@@ -134,7 +134,7 @@ plot_style_t *plot_style_fill_wblobc =
&plot_style_fill_wblobc_static;
static plot_style_t plot_style_stroke_wblobc_static = {
.stroke_type = PLOT_OP_TYPE_SOLID,
.stroke_colour = WIDGET_BLOBC,
- .stroke_width = 2,
+ .stroke_width = plot_style_int_to_fixed(2),
};
plot_style_t *plot_style_stroke_wblobc = &plot_style_stroke_wblobc_static;
@@ -156,7 +156,7 @@ plot_style_t *plot_style_stroke_lightwbasec =
&plot_style_stroke_lightwbasec_sta
/* Generic font style */
static const plot_font_style_t plot_style_font_static = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 8 * FONT_SIZE_SCALE,
+ .size = 8 * PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0xffffff,
diff --git a/desktop/save_pdf.c b/desktop/save_pdf.c
index 83e3d4f..8891900 100644
--- a/desktop/save_pdf.c
+++ b/desktop/save_pdf.c
@@ -213,10 +213,10 @@ bool pdf_plot_rectangle(int x0, int y0, int x1, int y1, const
plot_style_t *psty
}
apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
- pstyle->stroke_width,
- dash);
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
+ plot_style_int_to_fixed(pstyle->stroke_width),
+ dash);
HPDF_Page_Rectangle(pdf_page, x0, page_height - y0, x1 - x0, -(y1 - y0));
HPDF_Page_Stroke(pdf_page);
@@ -245,10 +245,10 @@ bool pdf_plot_line(int x0, int y0, int x1, int y1, const
plot_style_t *pstyle)
}
apply_clip_and_mode(false,
- NS_TRANSPARENT,
- pstyle->stroke_colour,
- pstyle->stroke_width,
- dash);
+ NS_TRANSPARENT,
+ pstyle->stroke_colour,
+ plot_style_int_to_fixed(pstyle->stroke_width),
+ dash);
HPDF_Page_MoveTo(pdf_page, x0, page_height - y0);
HPDF_Page_LineTo(pdf_page, x1, page_height - y1);
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c
index 5a7420a..af5536b 100644
--- a/desktop/scrollbar.c
+++ b/desktop/scrollbar.c
@@ -164,17 +164,17 @@ scrollbar_rectangle(const struct redraw_context *ctx,
static plot_style_t c0 = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
static plot_style_t c1 = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
static plot_style_t c2 = {
.stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
if (inset) {
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 3fd4c98..5bae27a 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -45,9 +45,9 @@
#define TA_ALLOC_STEP 512
static plot_style_t pstyle_stroke_caret = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = CARET_COLOR,
- .stroke_width = 1,
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = CARET_COLOR,
+ .stroke_width = plot_style_int_to_fixed(1),
};
struct line_info {
@@ -1805,7 +1805,7 @@ static void textarea_setup_text_offsets(struct textarea *ta)
ta->line_height = FIXTOINT(FMUL(FLTTOFIX(1.3), FDIV(FMUL(
nscss_screen_dpi, FDIV(INTTOFIX(ta->fstyle.size),
- INTTOFIX(FONT_SIZE_SCALE))), F_72)));
+ INTTOFIX(PLOT_STYLE_SCALE))), F_72)));
text_y_offset = text_y_offset_baseline = ta->border_width;
if (ta->flags & TEXTAREA_MULTILINE) {
@@ -1948,7 +1948,7 @@ struct textarea *textarea_create(const textarea_flags flags,
ret->line_height = FIXTOINT(FMUL(FLTTOFIX(1.3), FDIV(FMUL(
nscss_screen_dpi, FDIV(INTTOFIX(setup->text.size),
- INTTOFIX(FONT_SIZE_SCALE))), F_72)));
+ INTTOFIX(PLOT_STYLE_SCALE))), F_72)));
ret->caret_pos.line = ret->caret_pos.byte_off = -1;
ret->caret_x = 0;
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 1651ff5..928a696 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -5195,7 +5195,7 @@ nserror treeview_init(void)
10 + 36) / 72;
tree_g.line_height = (font_px_size * 8 + 3) / 6;
- res = treeview_init_plot_styles(font_pt_size * FONT_SIZE_SCALE / 10);
+ res = treeview_init_plot_styles(font_pt_size * PLOT_STYLE_SCALE / 10);
if (res != NSERROR_OK) {
return res;
}
diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c
index ae313bb..f3b365d 100644
--- a/frontends/amiga/dt_sound.c
+++ b/frontends/amiga/dt_sound.c
@@ -195,7 +195,7 @@ bool amiga_dt_sound_redraw(struct content *c,
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = 0xffffff,
.stroke_colour = 0x000000,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
struct rect rect;
diff --git a/frontends/amiga/font_bullet.c b/frontends/amiga/font_bullet.c
index c8ad34c..62c2dde 100644
--- a/frontends/amiga/font_bullet.c
+++ b/frontends/amiga/font_bullet.c
@@ -63,7 +63,7 @@
#define NSA_VALUE_SHEARSIN (1 << 14)
#define NSA_VALUE_SHEARCOS (1 << 16)
-#define NSA_FONT_EMWIDTH(s) (s / FONT_SIZE_SCALE) * (ami_font_dpi_get_xdpi() / 72.0)
+#define NSA_FONT_EMWIDTH(s) (s / PLOT_STYLE_SCALE) * (ami_font_dpi_get_xdpi() / 72.0)
const uint16 sc_table[] = {
0x0061, 0x1D00, /* a */
@@ -512,7 +512,7 @@ static struct OutlineFont *ami_open_outline_font(const
plot_font_style_t *fstyle
}
/* Scale to 16.16 fixed point */
- ysize = fstyle->size * ((1 << 16) / FONT_SIZE_SCALE);
+ ysize = fstyle->size * ((1 << 16) / PLOT_STYLE_SCALE);
if(designed_node == NULL) {
ofont = node->font;
diff --git a/frontends/amiga/font_diskfont.c b/frontends/amiga/font_diskfont.c
index 2da3f00..a587d6e 100644
--- a/frontends/amiga/font_diskfont.c
+++ b/frontends/amiga/font_diskfont.c
@@ -97,7 +97,7 @@ static struct TextFont *ami_font_bm_open(struct RastPort *rp, const
plot_font_st
snprintf(font, MAX_FONT_NAME_SIZE, "%s.font", fontname);
tattr.ta_Name = font;
- tattr.ta_YSize = fstyle->size / FONT_SIZE_SCALE;
+ tattr.ta_YSize = fstyle->size / PLOT_STYLE_SCALE;
NSLOG(netsurf, INFO, "font: %s/%d", tattr.ta_Name, tattr.ta_YSize);
if(prev_font != NULL) CloseFont(prev_font);
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index b848543..4623afa 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -722,8 +722,8 @@ ami_line(const struct redraw_context *ctx,
struct gui_globals *glob = (struct gui_globals *)ctx->priv;
- glob->rp->PenWidth = style->stroke_width;
- glob->rp->PenHeight = style->stroke_width;
+ glob->rp->PenWidth = plot_style_fixed_to_int(style->stroke_width);
+ glob->rp->PenHeight = plot_style_fixed_to_int(style->stroke_width);
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
@@ -780,8 +780,8 @@ ami_rectangle(const struct redraw_context *ctx,
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- glob->rp->PenWidth = style->stroke_width;
- glob->rp->PenHeight = style->stroke_width;
+ glob->rp->PenWidth = plot_style_fixed_to_int(style->stroke_width);
+ glob->rp->PenHeight = plot_style_fixed_to_int(style->stroke_width);
switch (style->stroke_type) {
case PLOT_OP_TYPE_SOLID: /**< Solid colour */
@@ -868,7 +868,6 @@ ami_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -877,7 +876,6 @@ ami_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
unsigned int i;
diff --git a/frontends/amiga/plugin_hack.c b/frontends/amiga/plugin_hack.c
index 4fd1f03..5d7ec19 100644
--- a/frontends/amiga/plugin_hack.c
+++ b/frontends/amiga/plugin_hack.c
@@ -151,7 +151,7 @@ bool amiga_plugin_hack_redraw(struct content *c,
.fill_type = PLOT_OP_TYPE_SOLID,
.fill_colour = 0xffffff,
.stroke_colour = 0x000000,
- .stroke_width = 1,
+ .stroke_width = plot_style_int_to_fixed(1),
};
struct rect rect;
nserror res;
diff --git a/frontends/atari/plot/font_freetype.c b/frontends/atari/plot/font_freetype.c
index 1688e97..f8109f6 100644
--- a/frontends/atari/plot/font_freetype.c
+++ b/frontends/atari/plot/font_freetype.c
@@ -250,7 +250,7 @@ static void ft_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler
srec)
srec->face_id = (FTC_FaceID)font_faces[selected_face];
- srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE;
+ srec->width = srec->height = (fstyle->size * 64) / PLOT_STYLE_SCALE;
srec->pixel = 0;
/* calculate x/y resolution, when browser_get_dpi() isn't available */
diff --git a/frontends/atari/plot/font_vdi.c b/frontends/atari/plot/font_vdi.c
index 7cd82dd..556c08e 100644
--- a/frontends/atari/plot/font_vdi.c
+++ b/frontends/atari/plot/font_vdi.c
@@ -106,9 +106,9 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t
*fstyle, const c
fx |= 1;
vst_effects( self->vdi_handle, fx );
/* TODO: replace 90 with global dpi setting */
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 );
vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
/*
if(slen != utf8_bounded_length(str, length)){
@@ -148,10 +148,10 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t *
fstyle, const
if( fstyle->weight > 450 )
fx |= 1;
vst_effects( self->vdi_handle, fx );
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 );
vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
*actual_x = 0;
//*char_offset = 0;
@@ -216,7 +216,7 @@ static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t *
fstyle,const
if( fstyle->weight > 450 )
fx |= 1;
vst_effects(self->vdi_handle, fx);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 );
vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
*actual_x = 0;
*char_offset = 0;
@@ -283,8 +283,8 @@ static int text( FONT_PLOTTER self, int x, int y, const char *text,
size_t leng
/* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
use that value or pass it as arg, to reduce netsurf dependency */
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ //pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 );
+ pxsize = ceil( (fstyle->size/PLOT_STYLE_SCALE) * 90 / 72 );
plot_get_dimensions(&canvas);
x += canvas.g_x;
diff --git a/frontends/atari/plot/plot.c b/frontends/atari/plot/plot.c
index 14c6703..4935b17 100644
--- a/frontends/atari/plot/plot.c
+++ b/frontends/atari/plot/plot.c
@@ -2124,7 +2124,7 @@ plot_line(const struct redraw_context *ctx,
{
short pxy[4];
uint32_t lt;
- int sw = pstyle->stroke_width;
+ int sw = plot_style_fixed_to_int(pstyle->stroke_width);
if (((line->x0 < 0) && (line->x1 < 0)) ||
((line->y0 < 0) && (line->y1 < 0))) {
@@ -2183,7 +2183,7 @@ plot_rectangle(const struct redraw_context *ctx,
{
short pxy[4];
GRECT r, rclip, sclip;
- int sw = pstyle->stroke_width;
+ int sw = plot_style_fixed_to_int(pstyle->stroke_width);
uint32_t lt;
/* current canvas clip: */
@@ -2266,7 +2266,7 @@ plot_rectangle(const struct redraw_context *ctx,
if (pstyle->fill_type != PLOT_OP_TYPE_NONE ) {
short stroke_width = (short)(pstyle->stroke_type != PLOT_OP_TYPE_NONE) ?
- pstyle->stroke_width : 0;
+ plot_style_fixed_to_int(pstyle->stroke_width) : 0;
vsf_rgbcolor(atari_plot_vdi_handle, pstyle->fill_colour);
vsf_perimeter(atari_plot_vdi_handle, 0);
@@ -2343,7 +2343,6 @@ plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -2352,7 +2351,6 @@ plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
/** \todo Implement atari path plot */
diff --git a/frontends/atari/toolbar.c b/frontends/atari/toolbar.c
index fdfedcb..b8f4226 100644
--- a/frontends/atari/toolbar.c
+++ b/frontends/atari/toolbar.c
@@ -94,7 +94,7 @@ static float toolbar_url_scale = 1.0;
static plot_font_style_t font_style_url = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 14*FONT_SIZE_SCALE,
+ .size = 14*PLOT_STYLE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0xffffff,
@@ -302,7 +302,7 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
/* create the url widget: */
font_style_url.size =
- toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
+ toolbar_styles[t->style].font_height_pt * PLOT_STYLE_SCALE;
textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET;
textarea_setup ta_setup;
diff --git a/frontends/beos/font.cpp b/frontends/beos/font.cpp
index 8111303..5e7e782 100644
--- a/frontends/beos/font.cpp
+++ b/frontends/beos/font.cpp
@@ -130,7 +130,7 @@ void nsbeos_style_to_font(BFont &font, const struct
plot_font_style *fstyle)
}
//fprintf(stderr, "nsbeos_style_to_font: value %f unit %d\n",
style->font_size.value.length.value, style->font_size.value.length.unit);
- size = fstyle->size / FONT_SIZE_SCALE;
+ size = fstyle->size / PLOT_STYLE_SCALE;
//fprintf(stderr, "nsbeos_style_to_font: %f %d\n", size,
style->font_size.value.length.unit);
diff --git a/frontends/beos/plotters.cpp b/frontends/beos/plotters.cpp
index c4903e0..2c50f94 100644
--- a/frontends/beos/plotters.cpp
+++ b/frontends/beos/plotters.cpp
@@ -370,7 +370,7 @@ nsbeos_plot_line(const struct redraw_context *ctx,
nsbeos_set_colour(style->stroke_colour);
float pensize = view->PenSize();
- view->SetPenSize(style->stroke_width);
+ view->SetPenSize(plot_style_fixed_to_float(style->stroke_width));
BPoint start(line->x0, line->y0);
BPoint end(line->x1, line->y1);
@@ -447,7 +447,7 @@ nsbeos_plot_rectangle(const struct redraw_context *ctx,
nsbeos_set_colour(style->stroke_colour);
float pensize = view->PenSize();
- view->SetPenSize(style->stroke_width);
+ view->SetPenSize(plot_style_fixed_to_float(style->stroke_width));
BRect rect(nsrect->x0, nsrect->y0, nsrect->x1, nsrect->y1);
view->StrokeRect(rect, pat);
@@ -518,7 +518,6 @@ nsbeos_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -527,7 +526,6 @@ nsbeos_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
unsigned int i;
@@ -578,7 +576,7 @@ nsbeos_plot_path(const struct redraw_context *ctx,
rgb_color old_high = view->HighColor();
float old_pen = view->PenSize();
- view->SetPenSize(width);
+ view->SetPenSize(plot_style_fixed_to_float(pstyle->stroke_width));
view->MovePenTo(0, 0);
if (pstyle->fill_colour != NS_TRANSPARENT) {
view->SetHighColor(nsbeos_rgb_colour(pstyle->fill_colour));
diff --git a/frontends/framebuffer/fbtk/text.c b/frontends/framebuffer/fbtk/text.c
index 4f3a238..9c96dce 100644
--- a/frontends/framebuffer/fbtk/text.c
+++ b/frontends/framebuffer/fbtk/text.c
@@ -71,7 +71,7 @@ fb_text_font_style(fbtk_widget_t *widget, int *font_height, int
*padding,
#endif
font_style->family = PLOT_FONT_FAMILY_SANS_SERIF;
- font_style->size = px_to_pt(*font_height * FONT_SIZE_SCALE);
+ font_style->size = px_to_pt(*font_height * PLOT_STYLE_SCALE);
font_style->weight = 400;
font_style->flags = FONTF_NONE;
font_style->background = widget->bg;
diff --git a/frontends/framebuffer/font_freetype.c
b/frontends/framebuffer/font_freetype.c
index 9e47e4b..744ac62 100644
--- a/frontends/framebuffer/font_freetype.c
+++ b/frontends/framebuffer/font_freetype.c
@@ -392,7 +392,7 @@ static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler
srec)
srec->face_id = (FTC_FaceID)fb_faces[selected_face];
- srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE;
+ srec->width = srec->height = (fstyle->size * 64) / PLOT_STYLE_SCALE;
srec->pixel = 0;
srec->x_res = srec->y_res = browser_get_dpi();
diff --git a/frontends/framebuffer/font_internal.c
b/frontends/framebuffer/font_internal.c
index ff3471d..d755681 100644
--- a/frontends/framebuffer/font_internal.c
+++ b/frontends/framebuffer/font_internal.c
@@ -212,7 +212,7 @@ fb_get_font_size(const plot_font_style_t *fstyle)
{
int size = fstyle->size * 10 /
(((nsoption_int(font_min_size) * 3 +
- nsoption_int(font_size)) / 4) * FONT_SIZE_SCALE);
+ nsoption_int(font_size)) / 4) * PLOT_STYLE_SCALE);
if (size > 2)
size = 2;
else if (size <= 0)
diff --git a/frontends/framebuffer/framebuffer.c b/frontends/framebuffer/framebuffer.c
index 2ccc750..52afdbf 100644
--- a/frontends/framebuffer/framebuffer.c
+++ b/frontends/framebuffer/framebuffer.c
@@ -168,7 +168,7 @@ framebuffer_plot_line(const struct redraw_context *ctx,
}
pen.stroke_colour = style->stroke_colour;
- pen.stroke_width = style->stroke_width;
+ pen.stroke_width = plot_style_fixed_to_int(style->stroke_width);
nsfb_plot_line(nsfb, &rect, &pen);
}
@@ -216,7 +216,9 @@ framebuffer_plot_rectangle(const struct redraw_context *ctx,
dashed = true;
}
- nsfb_plot_rectangle(nsfb, &rect, style->stroke_width, style->stroke_colour,
dotted, dashed);
+ nsfb_plot_rectangle(nsfb, &rect,
+ plot_style_fixed_to_int(style->stroke_width),
+ style->stroke_colour, dotted, dashed);
}
return NSERROR_OK;
}
@@ -259,7 +261,6 @@ framebuffer_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -268,7 +269,6 @@ framebuffer_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
NSLOG(netsurf, INFO, "path unimplemented");
diff --git a/frontends/gtk/layout_pango.c b/frontends/gtk/layout_pango.c
index a5964eb..9e8e94d 100644
--- a/frontends/gtk/layout_pango.c
+++ b/frontends/gtk/layout_pango.c
@@ -277,7 +277,7 @@ nsfont_style_to_description(const plot_font_style_t *fstyle)
break;
}
- size = (fstyle->size * PANGO_SCALE) / FONT_SIZE_SCALE;
+ size = (fstyle->size * PANGO_SCALE) / PLOT_STYLE_SCALE;
if (fstyle->flags & FONTF_ITALIC)
style = PANGO_STYLE_ITALIC;
diff --git a/frontends/gtk/plotters.c b/frontends/gtk/plotters.c
index 88e7760..4a5ef51 100644
--- a/frontends/gtk/plotters.c
+++ b/frontends/gtk/plotters.c
@@ -89,6 +89,20 @@ static inline void nsgtk_set_dashed(void)
/**
+ * Set cairo context line width.
+ */
+static inline void nsgtk_set_line_width(plot_style_fixed width)
+{
+ if (width == 0) {
+ cairo_set_line_width(current_cr, 1);
+ } else {
+ cairo_set_line_width(current_cr,
+ plot_style_fixed_to_double(width));
+ }
+}
+
+
+/**
* \brief Sets a clip rectangle for subsequent plot operations.
*
* \param ctx The current redraw context.
@@ -191,10 +205,7 @@ nsgtk_plot_disc(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(current_cr, 1);
- else
- cairo_set_line_width(current_cr, style->stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
cairo_arc(current_cr, x, y, radius, 0, M_PI * 2);
@@ -242,10 +253,7 @@ nsgtk_plot_line(const struct redraw_context *ctx,
nsgtk_set_colour(style->stroke_colour);
}
- if (style->stroke_width == 0)
- cairo_set_line_width(current_cr, 1);
- else
- cairo_set_line_width(current_cr, style->stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
/* core expects horizontal and vertical lines to be on pixels, not
* between pixels
@@ -331,10 +339,7 @@ nsgtk_plot_rectangle(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(current_cr, 1);
- else
- cairo_set_line_width(current_cr, style->stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
cairo_rectangle(current_cr,
rect->x0 + 0.5,
@@ -394,7 +399,6 @@ nsgtk_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -403,7 +407,6 @@ nsgtk_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
unsigned int i;
@@ -421,7 +424,7 @@ nsgtk_plot_path(const struct redraw_context *ctx,
cairo_get_matrix(current_cr, &old_ctm);
/* Set up line style and width */
- cairo_set_line_width(current_cr, 1);
+ nsgtk_set_line_width(pstyle->stroke_width);
nsgtk_set_solid();
/* Load new CTM */
diff --git a/frontends/gtk/print.c b/frontends/gtk/print.c
index 8f71230..c4f1b0f 100644
--- a/frontends/gtk/print.c
+++ b/frontends/gtk/print.c
@@ -133,6 +133,17 @@ static inline void nsgtk_print_set_dashed(void)
cairo_set_dash(gtk_print_current_cr, cdashes, 1, 0);
}
+/** Set cairo context line width. */
+static inline void nsgtk_set_line_width(plot_style_fixed width)
+{
+ if (width == 0) {
+ cairo_set_line_width(gtk_print_current_cr, 1);
+ } else {
+ cairo_set_line_width(gtk_print_current_cr,
+ plot_style_fixed_to_double(width));
+ }
+}
+
/**
* \brief Sets a clip rectangle for subsequent plot operations.
@@ -248,10 +259,7 @@ nsgtk_print_plot_disc(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(gtk_print_current_cr, 1);
- else
- cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
cairo_arc(gtk_print_current_cr, x, y, radius, 0, M_PI * 2);
@@ -294,10 +302,7 @@ nsgtk_print_plot_line(const struct redraw_context *ctx,
break;
}
- if (style->stroke_width == 0)
- cairo_set_line_width(gtk_print_current_cr, 1);
- else
- cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
cairo_move_to(gtk_print_current_cr, line->x0 + 0.5, line->y0 + 0.5);
cairo_line_to(gtk_print_current_cr, line->x1 + 0.5, line->y1 + 0.5);
@@ -350,13 +355,6 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
}
if (style->stroke_type != PLOT_OP_TYPE_NONE) {
- int stroke_width;
-
- /* ensure minimum stroke width */
- stroke_width = style->stroke_width;
- if (stroke_width == 0) {
- stroke_width = 1;
- }
nsgtk_print_set_colour(style->stroke_colour);
@@ -375,7 +373,7 @@ nsgtk_print_plot_rectangle(const struct redraw_context *ctx,
break;
}
- cairo_set_line_width(gtk_print_current_cr, stroke_width);
+ nsgtk_set_line_width(style->stroke_width);
cairo_rectangle(gtk_print_current_cr,
rect->x0, rect->y0,
@@ -429,7 +427,6 @@ nsgtk_print_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -438,7 +435,6 @@ nsgtk_print_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
/* Only the internal SVG renderer uses this plot call currently,
diff --git a/frontends/monkey/layout.c b/frontends/monkey/layout.c
index 7b72231..0d6a3b4 100644
--- a/frontends/monkey/layout.c
+++ b/frontends/monkey/layout.c
@@ -33,7 +33,7 @@ static nserror nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
{
- *width = (fstyle->size * utf8_bounded_length(string, length)) / FONT_SIZE_SCALE;
+ *width = (fstyle->size * utf8_bounded_length(string, length)) / PLOT_STYLE_SCALE;
return NSERROR_OK;
}
@@ -53,10 +53,10 @@ static nserror nsfont_position_in_string(const plot_font_style_t
*fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
- *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+ *char_offset = x / (fstyle->size / PLOT_STYLE_SCALE);
if (*char_offset > length)
*char_offset = length;
- *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+ *actual_x = *char_offset * (fstyle->size / PLOT_STYLE_SCALE);
return NSERROR_OK;
}
@@ -88,7 +88,7 @@ static nserror nsfont_split(const plot_font_style_t *fstyle,
const char *string, size_t length,
int x, size_t *char_offset, int *actual_x)
{
- int c_off = *char_offset = x / (fstyle->size / FONT_SIZE_SCALE);
+ int c_off = *char_offset = x / (fstyle->size / PLOT_STYLE_SCALE);
if (*char_offset > length) {
*char_offset = length;
} else {
@@ -104,7 +104,7 @@ static nserror nsfont_split(const plot_font_style_t *fstyle,
}
}
}
- *actual_x = *char_offset * (fstyle->size / FONT_SIZE_SCALE);
+ *actual_x = *char_offset * (fstyle->size / PLOT_STYLE_SCALE);
return NSERROR_OK;
}
diff --git a/frontends/monkey/plot.c b/frontends/monkey/plot.c
index d00dca7..2fc9a3c 100644
--- a/frontends/monkey/plot.c
+++ b/frontends/monkey/plot.c
@@ -177,7 +177,6 @@ monkey_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -186,12 +185,11 @@ monkey_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
fprintf(stdout,
"PLOT PATH VERTICIES %d WIDTH %f\n",
- n, width);
+ n, plot_style_fixed_to_float(pstyle->stroke_width));
return NSERROR_OK;
}
@@ -273,7 +271,7 @@ static const struct plotter_table plotters = {
.path = monkey_plot_path,
.bitmap = monkey_plot_bitmap,
.text = monkey_plot_text,
- .option_knockout = true,
+ .option_knockout = true,
};
const struct plotter_table* monkey_plotters = &plotters;
diff --git a/frontends/riscos/font.c b/frontends/riscos/font.c
index 8913efe..2ff3090 100644
--- a/frontends/riscos/font.c
+++ b/frontends/riscos/font.c
@@ -469,7 +469,7 @@ void nsfont_read_style(const plot_font_style_t *fstyle,
rufl_WEIGHT_900
};
- *font_size = (fstyle->size * 16) / FONT_SIZE_SCALE;
+ *font_size = (fstyle->size * 16) / PLOT_STYLE_SCALE;
if (1600 < *font_size)
*font_size = 1600;
diff --git a/frontends/riscos/plotters.c b/frontends/riscos/plotters.c
index 2fbd12a..2b30682 100644
--- a/frontends/riscos/plotters.c
+++ b/frontends/riscos/plotters.c
@@ -324,9 +324,9 @@ ro_plot_line(const struct redraw_context *ctx,
dashed = true;
return ro_plot_draw_path((const draw_path *)path,
- style->stroke_width,
- style->stroke_colour,
- dotted, dashed);
+ plot_style_fixed_to_int(style->stroke_width),
+ style->stroke_colour,
+ dotted, dashed);
}
return NSERROR_OK;
}
@@ -412,10 +412,10 @@ ro_plot_rectangle(const struct redraw_context *ctx,
dashed = true;
ro_plot_draw_path((const draw_path *)path,
- style->stroke_width,
- style->stroke_colour,
- dotted,
- dashed);
+ plot_style_fixed_to_int(style->stroke_width),
+ style->stroke_colour,
+ dotted,
+ dashed);
}
return NSERROR_OK;
@@ -483,7 +483,6 @@ ro_plot_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -492,7 +491,6 @@ ro_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
static const draw_line_style line_style = {
@@ -591,7 +589,9 @@ ro_plot_path(const struct redraw_context *ctx,
}
error = xdraw_stroke((draw_path *) path, 0, &trfm, 0,
- width * 2 * 256, &line_style, 0);
+ plot_style_fixed_to_int(
+ pstyle->stroke_width) * 2 * 256,
+ &line_style, 0);
if (error) {
NSLOG(netsurf, INFO, "xdraw_stroke: 0x%x: %s",
error->errnum, error->errmess);
diff --git a/frontends/riscos/print.c b/frontends/riscos/print.c
index d965baf..b390c69 100644
--- a/frontends/riscos/print.c
+++ b/frontends/riscos/print.c
@@ -831,7 +831,6 @@ print_fonts_plot_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
return NSERROR_OK;
diff --git a/frontends/riscos/save_draw.c b/frontends/riscos/save_draw.c
index 9ee7304..28880e5 100644
--- a/frontends/riscos/save_draw.c
+++ b/frontends/riscos/save_draw.c
@@ -168,7 +168,7 @@ ro_save_draw_line(const struct redraw_context *ctx,
sizeof path / sizeof path[0],
pencil_TRANSPARENT,
style->stroke_colour << 8,
- style->stroke_width,
+ plot_style_fixed_to_int(style->stroke_width),
pencil_JOIN_MITRED,
pencil_CAP_BUTT,
pencil_CAP_BUTT,
@@ -235,7 +235,7 @@ ro_save_draw_rectangle(const struct redraw_context *ctx,
sizeof path / sizeof path[0],
pencil_TRANSPARENT,
style->stroke_colour << 8,
- style->stroke_width,
+ plot_style_fixed_to_int(style->stroke_width),
pencil_JOIN_MITRED,
pencil_CAP_BUTT,
pencil_CAP_BUTT,
@@ -312,7 +312,6 @@ ro_save_draw_polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -321,7 +320,6 @@ ro_save_draw_path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
pencil_code code;
@@ -409,7 +407,8 @@ ro_save_draw_path(const struct redraw_context *ctx,
pstyle->stroke_colour == NS_TRANSPARENT ?
pencil_TRANSPARENT :
pstyle->stroke_colour << 8,
- width, pencil_JOIN_MITRED,
+ plot_style_fixed_to_int(style->stroke_width),
+ pencil_JOIN_MITRED,
pencil_CAP_BUTT,
pencil_CAP_BUTT,
0,
diff --git a/frontends/windows/font.c b/frontends/windows/font.c
index 37ccf23..7389bd8 100644
--- a/frontends/windows/font.c
+++ b/frontends/windows/font.c
@@ -120,7 +120,7 @@ HFONT get_font(const plot_font_style_t *style)
int nHeight = -10;
HDC hdc = GetDC(font_hwnd);
- nHeight = -MulDiv(style->size, GetDeviceCaps(hdc, LOGPIXELSY), 72 *
FONT_SIZE_SCALE);
+ nHeight = -MulDiv(style->size, GetDeviceCaps(hdc, LOGPIXELSY), 72 *
PLOT_STYLE_SCALE);
ReleaseDC(font_hwnd, hdc);
HFONT font = CreateFont(
diff --git a/frontends/windows/plot.c b/frontends/windows/plot.c
index 3668e4b..4d9096d 100644
--- a/frontends/windows/plot.c
+++ b/frontends/windows/plot.c
@@ -601,7 +601,9 @@ line(const struct redraw_context *ctx,
(style->stroke_type == PLOT_OP_TYPE_DASH) ? PS_DASH:
0);
LOGBRUSH lb = {BS_SOLID, col, 0};
- HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
+ HPEN pen = ExtCreatePen(penstyle,
+ plot_style_fixed_to_int(style->stroke_width),
+ &lb, 0, NULL);
if (pen == NULL) {
DeleteObject(clipregion);
return NSERROR_INVALID;
@@ -672,7 +674,9 @@ rectangle(const struct redraw_context *ctx,
if (style->fill_type == PLOT_OP_TYPE_NONE)
lb1.lbStyle = BS_HOLLOW;
- HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
+ HPEN pen = ExtCreatePen(penstyle,
+ plot_style_fixed_to_int(style->stroke_width),
+ &lb, 0, NULL);
if (pen == NULL) {
return NSERROR_INVALID;
}
@@ -810,7 +814,6 @@ polygon(const struct redraw_context *ctx,
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
@@ -819,7 +822,6 @@ path(const struct redraw_context *ctx,
const plot_style_t *pstyle,
const float *p,
unsigned int n,
- float width,
const float transform[6])
{
NSLOG(plot, DEEPDEBUG, "path unimplemented");
diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h
index 30db366..f1b6172 100644
--- a/include/netsurf/plot_style.h
+++ b/include/netsurf/plot_style.h
@@ -25,6 +25,8 @@
#define NETSURF_PLOT_STYLE_H
#include <stdint.h>
+#include <stdint.h>
+#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/types.h"
/** light grey widget base colour */
@@ -36,8 +38,26 @@
/** Transparent colour value. */
#define NS_TRANSPARENT 0x01000000
-/** Scaling factor for font sizes */
-#define FONT_SIZE_SCALE 1024
+/** 22:10 fixed point */
+#define PLOT_STYLE_RADIX (10)
+
+/** Scaling factor for plot styles */
+#define PLOT_STYLE_SCALE (1 << PLOT_STYLE_RADIX)
+
+/* type for fixed point numbers */
+typedef int32_t plot_style_fixed;
+
+/* Convert an int to fixed point */
+#define plot_style_int_to_fixed(v) ((v) << PLOT_STYLE_RADIX)
+
+/* Convert fixed point to int */
+#define plot_style_fixed_to_int(v) ((v) >> PLOT_STYLE_RADIX)
+
+/* Convert fixed point to float */
+#define plot_style_fixed_to_float(v) (((float)v) / PLOT_STYLE_SCALE)
+
+/* Convert fixed point to double */
+#define plot_style_fixed_to_double(v) (((double)v) / PLOT_STYLE_SCALE)
/**
* Type of plot operation
@@ -55,7 +75,7 @@ typedef enum {
*/
typedef struct plot_style_s {
plot_operation_type_t stroke_type; /**< Stroke plot type */
- int stroke_width; /**< Width of stroke, in pixels */
+ plot_style_fixed stroke_width; /**< Width of stroke, in pixels */
colour stroke_colour; /**< Colour of stroke */
plot_operation_type_t fill_type; /**< Fill plot type */
colour fill_colour; /**< Colour of fill */
@@ -89,8 +109,14 @@ typedef enum {
* Font style for plotting
*/
typedef struct plot_font_style {
+ /**
+ * Array of pointers to font families.
+ *
+ * May be NULL. Array is NULL terminated.
+ */
+ lwc_string * const * families;
plot_font_generic_family_t family; /**< Generic family to plot with */
- int size; /**< Font size, in points * FONT_SIZE_SCALE */
+ plot_style_fixed size; /**< Font size, in pt */
int weight; /**< Font weight: value in range [100,900] as per CSS */
plot_font_flags_t flags; /**< Font flags */
colour background; /**< Background colour to blend to, if appropriate */
diff --git a/include/netsurf/plotters.h b/include/netsurf/plotters.h
index 87fbd9a..2fd507a 100644
--- a/include/netsurf/plotters.h
+++ b/include/netsurf/plotters.h
@@ -108,7 +108,9 @@ struct plotter_table {
* operations within.
* \return NSERROR_OK on success else error code.
*/
- nserror (*clip)(const struct redraw_context *ctx, const struct rect *clip);
+ nserror (*clip)(
+ const struct redraw_context *ctx,
+ const struct rect *clip);
/**
* Plots an arc
@@ -126,7 +128,14 @@ struct plotter_table {
* \param angle2 The finish angle of the arc.
* \return NSERROR_OK on success else error code.
*/
- nserror (*arc)(const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int
y, int radius, int angle1, int angle2);
+ nserror (*arc)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ int x,
+ int y,
+ int radius,
+ int angle1,
+ int angle2);
/**
* Plots a circle
@@ -140,7 +149,12 @@ struct plotter_table {
* \param radius The radius of the circle.
* \return NSERROR_OK on success else error code.
*/
- nserror (*disc)(const struct redraw_context *ctx, const plot_style_t *pstyle, int x, int
y, int radius);
+ nserror (*disc)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ int x,
+ int y,
+ int radius);
/**
* Plots a line
@@ -153,7 +167,10 @@ struct plotter_table {
* \param line A rectangle defining the line to be drawn
* \return NSERROR_OK on success else error code.
*/
- nserror (*line)(const struct redraw_context *ctx, const plot_style_t *pstyle, const
struct rect *line);
+ nserror (*line)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const struct rect *line);
/**
* Plots a rectangle.
@@ -168,7 +185,10 @@ struct plotter_table {
* \param rect A rectangle defining the line to be drawn
* \return NSERROR_OK on success else error code.
*/
- nserror (*rectangle)(const struct redraw_context *ctx, const plot_style_t *pstyle, const
struct rect *rectangle);
+ nserror (*rectangle)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const struct rect *rectangle);
/**
* Plot a polygon
@@ -184,7 +204,11 @@ struct plotter_table {
* \param n number of verticies.
* \return NSERROR_OK on success else error code.
*/
- nserror (*polygon)(const struct redraw_context *ctx, const plot_style_t *pstyle, const
int *p, unsigned int n);
+ nserror (*polygon)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const int *p,
+ unsigned int n);
/**
* Plots a path.
@@ -196,11 +220,15 @@ struct plotter_table {
* \param pstyle Style controlling the path plot.
* \param p elements of path
* \param n nunber of elements on path
- * \param width The width of the path
* \param transform A transform to apply to the path.
* \return NSERROR_OK on success else error code.
*/
- nserror (*path)(const struct redraw_context *ctx, const plot_style_t *pstyle, const
float *p, unsigned int n, float width, const float transform[6]);
+ nserror (*path)(
+ const struct redraw_context *ctx,
+ const plot_style_t *pstyle,
+ const float *p,
+ unsigned int n,
+ const float transform[6]);
/**
* Plot a bitmap
@@ -226,7 +254,15 @@ struct plotter_table {
* \param flags the flags controlling the type of plot operation
* \return NSERROR_OK on success else error code.
*/
- nserror (*bitmap)(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y,
int width, int height, colour bg, bitmap_flags_t flags);
+ nserror (*bitmap)(
+ const struct redraw_context *ctx,
+ struct bitmap *bitmap,
+ int x,
+ int y,
+ int width,
+ int height,
+ colour bg,
+ bitmap_flags_t flags);
/**
* Text plotting.
@@ -239,7 +275,13 @@ struct plotter_table {
* \param length length of string, in bytes
* \return NSERROR_OK on success else error code.
*/
- nserror (*text)(const struct redraw_context *ctx, const plot_font_style_t *fstyle, int
x, int y, const char *text, size_t length);
+ nserror (*text)(
+ const struct redraw_context *ctx,
+ const plot_font_style_t *fstyle,
+ int x,
+ int y,
+ const char *text,
+ size_t length);
/**
* Start of a group of objects.
@@ -250,7 +292,9 @@ struct plotter_table {
* \param ctx The current redraw context.
* \return NSERROR_OK on success else error code.
*/
- nserror (*group_start)(const struct redraw_context *ctx, const char *name);
+ nserror (*group_start)(
+ const struct redraw_context *ctx,
+ const char *name);
/**
* End of the most recently started group.
@@ -260,7 +304,8 @@ struct plotter_table {
* \param ctx The current redraw context.
* \return NSERROR_OK on success else error code.
*/
- nserror (*group_end)(const struct redraw_context *ctx);
+ nserror (*group_end)(
+ const struct redraw_context *ctx);
/**
* Only used internally by the knockout code. Must be NULL in
@@ -269,7 +314,8 @@ struct plotter_table {
* \param ctx The current redraw context.
* \return NSERROR_OK on success else error code.
*/
- nserror (*flush)(const struct redraw_context *ctx);
+ nserror (*flush)(
+ const struct redraw_context *ctx);
/* flags */
/**
--
NetSurf Browser