Page 1 of 1

Dashed Stroke fails when drawing Fonts

Posted: 2011-08-18T00:05:06-07:00
by anthony

Code: Select all

  convert -size 180x80 xc: -font ArialBk -pointsize 72 \
          -gravity center -fill skyblue -stroke black \
          -draw 'stroke-dasharray 10 1 text 0,0 "Abc" ' font_dash_bug.gif
the dashed line gets draw when it is not supposed to.
Image

This is probably similar to two other bugs detailed in
http://www.imagemagick.org/Usage/bugs/testing/#polyline

But there are other draw bugs shown that have been previously reported too.

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T18:30:54-07:00
by olear
Old, but still an issue. Does there exists an fix/workaround when using text?
Image

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T19:10:19-07:00
by fmw42
olear wrote:Old, but still an issue. Does there exists an fix/workaround when using text?
What version of Imagemagick and what platform and what is your exact command line?

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T19:18:46-07:00
by olear
6.8.9->current, Windows/Linux, I use Magick++

Using the command from first post gives this:
Image
Version: ImageMagick 6.9.2-0 Q32 x86_64 2015-08-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): cairo fontconfig freetype pangocairo png rsvg xml zlib

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T19:30:42-07:00
by fmw42
It is producing a dashed stroke of 10 black pixels separated by 1 skip. I do not see anything in his command to say that it should not be drawing the stroked lines. However, there are excess lines connecting the characters, which should not be there. So this still would appear to be a bug.

I am using IM 6.9.2.0 Q16 Mac OSX Snow Leopard.

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T19:44:10-07:00
by fmw42
As a workaround, I tried to draw each letter separately and append them. (However, this probably would not be a universal solution including letters with negative y-min in the font metric, such as "y").

Nevertheless, the letter "b" still has an extraneous line in it.

Code: Select all

convert -font ArialBk -pointsize 72 \
-gravity center -fill skyblue -stroke black \
\( -size 180x80 xc: -draw 'stroke-dasharray 5 5 text 0,0 "A"' -trim +repage \) \
\( -size 180x80 xc: -draw 'stroke-dasharray 5 5 text 0,0 "b"' -trim +repage \) \
\( -size 180x80 xc: -draw 'stroke-dasharray 5 5 text 0,0 "c"' -trim +repage \) \
-bordercolor white -border 1 -gravity south +append dash_stroke_append.gif
Image

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T19:56:07-07:00
by fmw42
One other possibility is to use SVG to render your text. It has stroke dash array. But you may need to use RSVG or Inkscape rather than the internal IM MSVG, which, I think, is the default rendering engine for -draw. See http://www.w3.org/TR/2011/REC-SVG11-201 ... Properties and http://www.w3.org/TR/2011/REC-SVG11-20110816/text.html

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-28T20:12:42-07:00
by olear
Thanks for your replies.

Loading an SVG with dashed stroke on text works, sadly this is not an solution for me.

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-29T14:36:07-07:00
by magick
The ImageMagick native renderer does not support dashed strokes for text. We rely on the Freetype outline methods, they do not create separate paths for outer and inner outlines (e.g. the letter b). ImageMagick stroking supports ghostlines (the invisible line that connects inner and outer strokes), but the dashed strokes method does not have access to the ghostlines. We did not write the dashed stroked method and do not currently have solution for fixing this problem. As always, ImageMagick is open-source. We encourage you to review the magick/draw.c/DrawDashPolygon() method to fix this deficiency.

Re: Dashed Stroke fails when drawing Fonts

Posted: 2015-08-29T15:48:15-07:00
by olear
Thanks for clarifying, sadly I don't have enough knowledge of ImageMagick to add/fix the code, but will take a look when I get the time.

Re: Dashed Stroke fails when drawing Fonts

Posted: 2016-12-13T07:38:20-07:00
by manuel_songokuh
hi
are there any news for this issue (bug)..?

Re: Dashed Stroke fails when drawing Fonts

Posted: 2016-12-13T18:04:01-07:00
by anthony
I just tried the bug example with IM v6.9.3.0 (The default IM for fedora 25)

Code: Select all

  convert -size 180x80 xc: -font ArialBk -pointsize 72 \
          -gravity center -fill skyblue -stroke black \
          -draw 'stroke-dasharray 10 1 text 0,0 "Abc" '   show:
The result was that the letters were draw without dash stroke, just normal outlines.

This I think is better than the buggy output that was showing the ghostlines.

As freetype does not provide dashed outlines for letters, I doubt we will ever be able to correctly generate dashed outlines for letters.