ref: 9ca2a22e5a79f562d1f808280165e816ca972d61
parent: 3a477760bd317b3dae19bf2bdcfe680da5975b30
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Sep 3 08:25:37 EDT 2020
pdf: reset line width when font size changes
--- a/pdf.c
+++ b/pdf.c
@@ -32,7 +32,6 @@
static int o_i, p_i; /* output and pdf fonts (indices into pfont[]) */
static int p_f, p_s, p_m; /* output font */
static int o_queued; /* queued character type */
-static int o_drawreset; /* drawing variables should be reset */
static char o_iset[1024]; /* fonts accesssed in this page */
static int xobj[128]; /* page xobject object ids */
static int xobj_n; /* number of xobjects in this page */
@@ -841,7 +840,6 @@
pdf_linecap = atoi(val);
if (!strcmp("linejoin", var))
pdf_linejoin = atoi(val);
- o_drawreset = 1;
}
void outpage(void)
@@ -855,7 +853,6 @@
p_f = 0;
p_m = 0;
o_i = -1;
- o_drawreset = 1;
}
void outmnt(int f)
@@ -880,6 +877,8 @@
sbuf_printf(pg, "%s m\n", pdfpos(o_h, o_v));
}
+static int l_page, l_size, l_wid, l_cap, l_join; /* drawing line properties */
+
void drawend(int close, int fill)
{
if (draw_path)
@@ -886,11 +885,16 @@
return;
draw_point = 0;
fill = !fill ? 2 : fill;
- if (o_drawreset) {
+ if (l_page != page_n || l_size != o_s || l_wid != pdf_linewid ||
+ l_cap != pdf_linecap || l_join != pdf_linejoin) {
int lwid = pdf_linewid * o_s;
sbuf_printf(pg, "%d.%03d w\n", lwid / 1000, lwid % 1000);
sbuf_printf(pg, "%d J %d j\n", pdf_linecap, pdf_linejoin);
- o_drawreset = 0;
+ l_page = page_n;
+ l_size = o_s;
+ l_wid = pdf_linewid;
+ l_cap = pdf_linecap;
+ l_join = pdf_linejoin;
}
if (fill & 2) /* stroking color */
sbuf_printf(pg, "%s RG\n", pdfcolor(o_m));