diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2018-05-23 15:46:39 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2018-05-23 15:46:39 +0100 |
commit | a40dca49e8493802d7064bd8e6aaab03436568ee (patch) | |
tree | 5a036a8ddc33423d3564b046837ff42bd46d8f61 /frontends | |
parent | 6cabd4cd628833afa32aeb7c614ef153b4a1c985 (diff) | |
parent | 8a931f01b958ad5862433ece6024bbde0aa4ecb8 (diff) | |
download | netsurf-a40dca49e8493802d7064bd8e6aaab03436568ee.tar.gz netsurf-a40dca49e8493802d7064bd8e6aaab03436568ee.tar.bz2 |
Merge branch 'tlsa/plotter-polish'
Diffstat (limited to 'frontends')
26 files changed, 95 insertions, 104 deletions
diff --git a/frontends/amiga/dt_sound.c b/frontends/amiga/dt_sound.c index ae313bb51..f3b365ddb 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 c8ad34c04..62c2dde08 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 2da3f0038..a587d6eaf 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 b8485430f..4623afad2 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 4fd1f03f7..5d7ec19c1 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 1688e978b..f8109f6f2 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 7cd82ddc9..556c08e82 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 14c670352..4935b1776 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 fdfedcbee..b8f42267f 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 81113032d..5e7e78228 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 c4903e045..2c50f9497 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 4f3a2385d..9c96dcef4 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 9e47e4b99..744ac6281 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 ff3471d1d..d755681c6 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 2ccc75062..52afdbf5d 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 a5964eb37..9e8e94d48 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 88e7760c6..4a5ef510c 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 8f71230a6..c4f1b0f7a 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 7b7223144..0d6a3b4dc 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 d00dca754..2fc9a3cb6 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 8913efeeb..2ff309043 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 2fbd12aeb..2b306827d 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 d965baff4..b390c693d 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 9ee730434..28880e530 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 37ccf23fe..7389bd8c1 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 3668e4bb6..4d9096d75 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"); |