Strokes in Pango vs. Complex scripts in IM
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Strokes in Pango vs. Complex scripts in IM
Hi.
I have a need to use complex scripts, such as Arabic and Devangari, and thus need to use Pango since IM can't combine and rearrange the letters properly, as made clear on other threads.
But I also want to be able to produce outlined text, and cannot see any way to set stroke color and width in Pango, whether using markup or -define.
A workaround I tried was to superimpose multiple copies of the result from Pango, behind that result, using a different color. This worked great, except that the edges weren't rounded enough, because I couldn't offset these copies by a fraction of a pixel.The edge of a curve looks stair stepped if the offsetting is limited to integer values.
Is there any possible way to add the ability to set stroke width and color to the integration of Pango? Or is that something that is only available in connection with Pango when using Cairo? Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
Any suggestions?
Bob
Version: ImageMagick 6.7.6-3 2012-04-28 Q16
I have a need to use complex scripts, such as Arabic and Devangari, and thus need to use Pango since IM can't combine and rearrange the letters properly, as made clear on other threads.
But I also want to be able to produce outlined text, and cannot see any way to set stroke color and width in Pango, whether using markup or -define.
A workaround I tried was to superimpose multiple copies of the result from Pango, behind that result, using a different color. This worked great, except that the edges weren't rounded enough, because I couldn't offset these copies by a fraction of a pixel.The edge of a curve looks stair stepped if the offsetting is limited to integer values.
Is there any possible way to add the ability to set stroke width and color to the integration of Pango? Or is that something that is only available in connection with Pango when using Cairo? Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
Any suggestions?
Bob
Version: ImageMagick 6.7.6-3 2012-04-28 Q16
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
Another feature of IM that appears to be unavailable in IM's implementation of Pango is line spacing. Shouldn't there be a way to define a line height for Pango?
Re: Strokes in Pango vs. Complex scripts in IM
Use the Pango markup language, see http://www.imagemagick.org/Usage/text/#pango_markup.
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
magick,
My point is that I cannot see any way to use Pango's markup language to control stroke color, stroke width, or line spacing. Am I missing something?Bob Pickle wrote:But I also want to be able to produce outlined text, and cannot see any way to set stroke color and width in Pango, whether using markup or -define.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Strokes in Pango vs. Complex scripts in IM
Use an outline font or apply an edge operator afterwards to a normal font and colorize the edgesBut I also want to be able to produce outlined text
See -morphology edge/edgein/edgeout
http://www.imagemagick.org/Usage/morphology/#difference
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
Any suggestions on line spacing?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Strokes in Pango vs. Complex scripts in IM
All I can suggest is use Pango for each line of text and then composite all the lines with appropriate offsets. Otherwise, can you explain further why caption: does not do what you want?
As for PANGO, that is not under the control of Imagemagick. It is a delegate library. So you would need to contact the PANGO developers to get an enhancements. Does Pango already support those features? If so, the I suppose they could be made available in IM. But I am not a developer.
As for PANGO, that is not under the control of Imagemagick. It is a delegate library. So you would need to contact the PANGO developers to get an enhancements. Does Pango already support those features? If so, the I suppose they could be made available in IM. But I am not a developer.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Strokes in Pango vs. Complex scripts in IM
It can, by using "-distort SRT" and fractional values of NewX and NewY. See http://www.imagemagick.org/script/comma ... hp#distortBob Pickle wrote:Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
I don't use Pango as it isn't included in the Windows binary. An alternative you might want to explore is using SVG, with Inkscape as the delegate.
snibgo's IM pages: im.snibgo.com
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
Gladly. Caption and label do not handle these complex scripts correctly. Based on the position of the letter in a word, and what characters are near it, different glyphs are supposed to be used. The substitution of the correct glyph for the standalone glyph is done by the application, not the font. All caption and label return are the standalone glyphs, regardless of the position of the letter in the word, and regardless of what characters are next to the letterfmw42 wrote:Otherwise, can you explain further why caption: does not do what you want?
.
Thanks for the tip, and I'll explore using SVG.snibgo wrote:It can, by using "-distort SRT" and fractional values of NewX and NewY. See http://www.imagemagick.org/script/comma ... hp#distortBob Pickle wrote:Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
I don't use Pango as it isn't included in the Windows binary. An alternative you might want to explore is using SVG, with Inkscape as the delegate.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Strokes in Pango vs. Complex scripts in IM
Another possibility is to put the text in a PDF document. IM will delegate the resterising to Ghostscript, which might (or might not) use the correct glyphs.
If you find a good solution, do mention it here as it might help someone else.
If you find a good solution, do mention it here as it might help someone else.
snibgo's IM pages: im.snibgo.com
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
LaTeX vs. XeTeX/LuaLaTeX has the same issue as IM vs. Pango: The former has the bells and whistles of formatting/graphic abilities, and the latter works well with complex scripts. So if I used LuaLaTeX to create the PDF, the PDF should contain the correct glyphs. Sounds like a lot of work, but I'll think about it.snibgo wrote:Another possibility is to put the text in a PDF document. IM will delegate the resterising to Ghostscript, which might (or might not) use the correct glyphs.
If you find a good solution, do mention it here as it might help someone else.
It seems to me that the only way SVG would work is if the RSVG library can handle complex scripts.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Strokes in Pango vs. Complex scripts in IM
I do not work much with SVG, but I hear that Inkscape is more flexible than RSVG. Snibgo might know more about that, but check out Inkscape. If installed, IM will use that over RSVG.It seems to me that the only way SVG would work is if the RSVG library can handle complex scripts.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Strokes in Pango vs. Complex scripts in IM
Yes, Inkscape is usually better than RSVG.
@Bob: if you can put some Arabic or whatever text up, perhaps encoded in UTF-8, ideally with an image of what it should look like, and an image of the wrong output, I can see what Inkscape produces. You can put files somewhere like dropbox.com and paste the URLs here.
@Bob: if you can put some Arabic or whatever text up, perhaps encoded in UTF-8, ideally with an image of what it should look like, and an image of the wrong output, I can see what Inkscape produces. You can put files somewhere like dropbox.com and paste the URLs here.
snibgo's IM pages: im.snibgo.com
-
- Posts: 20
- Joined: 2013-11-11T08:52:56-07:00
- Authentication code: 6789
Re: Strokes in Pango vs. Complex scripts in IM
This is the Arabic from the template for CS4 Photoshop.
مرحبا
Is that what you need? You'd like to see the Arabic as it should be, and the above gives you that, since your browser should handle the character substitution correctly.
There are five characters there, and they read from right to left. The five characters are:
م رح ب ا
They appear as standalone characters because I put a space between each one. IM puts them in reverse order, unless you use -direction right-to-left. So, try the following, substituting whatever font you have or wish:
مرحبا
Is that what you need? You'd like to see the Arabic as it should be, and the above gives you that, since your browser should handle the character substitution correctly.
There are five characters there, and they read from right to left. The five characters are:
م رح ب ا
They appear as standalone characters because I put a space between each one. IM puts them in reverse order, unless you use -direction right-to-left. So, try the following, substituting whatever font you have or wish:
Code: Select all
convert -direction right-to-left -size 320x -font Simplified-Arabic-Regular -pointsize 32 caption:'مرحبا' caption_test.gif
convert -direction right-to-left -size 320x -font Simplified-Arabic-Regular -pointsize 32 label:'مرحبا' label_test.gif
convert -font Simplified-Arabic-Regular -pointsize 32 pango:'<span font="Simplified Arabic Regular">مرحبا</span>' pango_test.gif
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Strokes in Pango vs. Complex scripts in IM
Thanks. On Windows 7 I used Notepad to create a file called arabic3.svg, coded as UTF-8.
Then this command:
Here is arabic3.png:
I think it is exactly as you want.
This is with IM v6.8.7-0 using Inkscape 0.48 as delegate. MSVG gives the wrong result. I don't have RSVG.
http://www.w3.org/TR/SVG/text.html contains the SVG 1.1 text attributes. Inkscape can also deal with SVG 1.2 flowing text, http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html .
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="400"
height="100"
version="1.1">
<text
xml:space="preserve"
style="font-size:50px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
x="10" y="90"
><tspan>مرحبا</tspan>
</text>
</svg>
Code: Select all
convert -verbose arabic3.svg arabic3.png
I think it is exactly as you want.
This is with IM v6.8.7-0 using Inkscape 0.48 as delegate. MSVG gives the wrong result. I don't have RSVG.
http://www.w3.org/TR/SVG/text.html contains the SVG 1.1 text attributes. Inkscape can also deal with SVG 1.2 flowing text, http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html .
snibgo's IM pages: im.snibgo.com