@@ -1637,7 +1637,6 @@ struct jm_lineart_device
16371637 fz_rect pathrect = {};
16381638 int clips = {};
16391639 int linecount = {};
1640- float linewidth = {};
16411640 int path_type = {};
16421641 long depth = {};
16431642 size_t seqno = {};
@@ -1747,7 +1746,8 @@ static void jm_trace_text_span(
17471746 fz_colorspace* colorspace,
17481747 const float * color,
17491748 float alpha,
1750- size_t seqno
1749+ size_t seqno,
1750+ const fz_stroke_state* stroke
17511751 )
17521752{
17531753 // printf("extra.jm_trace_text_span(): seqno=%zi\n", seqno);
@@ -1900,24 +1900,22 @@ static void jm_trace_text_span(
19001900 {
19011901 rgb[0 ] = rgb[1 ] = rgb[2 ] = 0 ;
19021902 }
1903- double linewidth;
1904- if (dev->linewidth > 0 ) // width of character border
1903+ if (0 )
19051904 {
1906- linewidth = (double ) dev->linewidth ;
1907- }
1908- else
1909- {
1910- linewidth = fsize * 0.05 ; // default: 5% of font size
1905+ std::cout << " fsize=" << fsize;
1906+ if (stroke)
1907+ {
1908+ std::cout << " linewidth=" << stroke->linewidth ;
1909+ }
1910+ std::cout << " \n " ;
19111911 }
1912- if (0 ) std::cout
1913- << " dev->linewidth=" << dev->linewidth
1914- << " fsize=" << fsize
1915- << " linewidth=" << linewidth
1916- << " \n " ;
19171912 dict_setitem_drop (span_dict, dictkey_color, Py_BuildValue (" fff" , rgb[0 ], rgb[1 ], rgb[2 ]));
19181913 dict_setitem_drop (span_dict, dictkey_size, PyFloat_FromDouble (fsize));
19191914 dict_setitemstr_drop (span_dict, " opacity" , PyFloat_FromDouble ((double ) alpha));
1920- dict_setitemstr_drop (span_dict, " linewidth" , PyFloat_FromDouble ((double ) linewidth));
1915+ if (stroke)
1916+ dict_setitemstr_drop (span_dict, " linewidth" , PyFloat_FromDouble ((double ) stroke->linewidth ));
1917+ else
1918+ dict_setitemstr_drop (span_dict, " linewidth" , Py_None);
19211919 dict_setitemstr_drop (span_dict, " spacewidth" , PyFloat_FromDouble (space_adv));
19221920 dict_setitem_drop (span_dict, dictkey_type, PyLong_FromLong ((long ) type));
19231921 dict_setitem_drop (span_dict, dictkey_bbox, JM_py_from_rect (span_bbox));
@@ -1987,7 +1985,7 @@ static void jm_fill_image_mask(
19871985 jm_increase_seqno (ctx, dev);
19881986}
19891987
1990- static void jm_dev_linewidth (
1988+ static void jm_stroke_path (
19911989 fz_context* ctx,
19921990 fz_device* dev_,
19931991 const fz_path* path,
@@ -1999,11 +1997,6 @@ static void jm_dev_linewidth(
19991997 fz_color_params color_params
20001998 )
20011999{
2002- jm_tracedraw_device* dev = (jm_tracedraw_device*) dev_;
2003- if (0 ) std::cout << " jm_dev_linewidth(): changing dev->linewidth from " << dev->linewidth
2004- << " to stroke->linewidth=" << stroke->linewidth
2005- << " \n " ;
2006- dev->linewidth = stroke->linewidth ;
20072000 jm_increase_seqno (ctx, dev_);
20082001}
20092002
@@ -2015,13 +2008,14 @@ static void jm_trace_text(
20152008 fz_colorspace* colorspace,
20162009 const float * color,
20172010 float alpha,
2018- size_t seqno
2011+ size_t seqno,
2012+ const fz_stroke_state* stroke
20192013 )
20202014{
20212015 fz_text_span* span;
20222016 for (span = text->head ; span; span = span->next )
20232017 {
2024- jm_trace_text_span (dev, span, type, ctm, colorspace, color, alpha, seqno);
2018+ jm_trace_text_span (dev, span, type, ctm, colorspace, color, alpha, seqno, stroke );
20252019 }
20262020}
20272021
@@ -2044,7 +2038,7 @@ jm_tracedraw_fill_text(
20442038 )
20452039{
20462040 jm_tracedraw_device* dev = (jm_tracedraw_device*) dev_;
2047- jm_trace_text (dev, text, 0 , ctm, colorspace, color, alpha, dev->seqno );
2041+ jm_trace_text (dev, text, 0 , ctm, colorspace, color, alpha, dev->seqno , NULL );
20482042 dev->seqno += 1 ;
20492043}
20502044
@@ -2062,7 +2056,7 @@ jm_tracedraw_stroke_text(
20622056 )
20632057{
20642058 jm_tracedraw_device* dev = (jm_tracedraw_device*) dev_;
2065- jm_trace_text (dev, text, 1 , ctm, colorspace, color, alpha, dev->seqno );
2059+ jm_trace_text (dev, text, 1 , ctm, colorspace, color, alpha, dev->seqno , stroke );
20662060 dev->seqno += 1 ;
20672061}
20682062
@@ -2076,7 +2070,7 @@ jm_tracedraw_ignore_text(
20762070 )
20772071{
20782072 jm_tracedraw_device* dev = (jm_tracedraw_device*) dev_;
2079- jm_trace_text (dev, text, 3 , ctm, nullptr , nullptr , 1 , dev->seqno );
2073+ jm_trace_text (dev, text, 3 , ctm, nullptr , nullptr , 1 , dev->seqno , NULL );
20802074 dev->seqno += 1 ;
20812075}
20822076
@@ -2105,7 +2099,7 @@ mupdf::FzDevice JM_new_texttrace_device(PyObject* out)
21052099 dev->super .close_device = nullptr ;
21062100 dev->super .drop_device = jm_lineart_drop_device;
21072101 dev->super .fill_path = jm_fill_path;
2108- dev->super .stroke_path = jm_dev_linewidth ;
2102+ dev->super .stroke_path = jm_stroke_path ;
21092103 dev->super .clip_path = nullptr ;
21102104 dev->super .clip_stroke_path = nullptr ;
21112105
0 commit comments