Dashed Stroke fails when drawing Fonts

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Dashed Stroke fails when drawing Fonts

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Dashed Stroke fails when drawing Fonts

Post by olear »

Old, but still an issue. Does there exists an fix/workaround when using text?
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Dashed Stroke fails when drawing Fonts

Post 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?
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Dashed Stroke fails when drawing Fonts

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Dashed Stroke fails when drawing Fonts

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Dashed Stroke fails when drawing Fonts

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Dashed Stroke fails when drawing Fonts

Post 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
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Dashed Stroke fails when drawing Fonts

Post by olear »

Thanks for your replies.

Loading an SVG with dashed stroke on text works, sadly this is not an solution for me.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Dashed Stroke fails when drawing Fonts

Post 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.
olear
Posts: 58
Joined: 2015-05-24T10:56:42-07:00
Authentication code: 6789

Re: Dashed Stroke fails when drawing Fonts

Post 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.
manuel_songokuh
Posts: 8
Joined: 2015-08-27T16:24:22-07:00
Authentication code: 1151

Re: Dashed Stroke fails when drawing Fonts

Post by manuel_songokuh »

hi
are there any news for this issue (bug)..?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Dashed Stroke fails when drawing Fonts

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply