Page 1 of 3
Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T11:00:06-07:00
by Bob Pickle
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
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T11:12:51-07:00
by Bob Pickle
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
Posted: 2013-12-05T11:29:48-07:00
by magick
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T13:52:51-07:00
by Bob Pickle
magick,
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.
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?
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T14:03:48-07:00
by fmw42
But I also want to be able to produce outlined text
Use an outline font or apply an edge operator afterwards to a normal font and colorize the edges
See -morphology edge/edgein/edgeout
http://www.imagemagick.org/Usage/morphology/#difference
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T17:43:57-07:00
by Bob Pickle
Any suggestions on line spacing?
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T17:51:00-07:00
by fmw42
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.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T19:04:12-07:00
by snibgo
Bob Pickle wrote:Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
It can, by using "-distort SRT" and fractional values of NewX and NewY. See
http://www.imagemagick.org/script/comma ... hp#distort
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.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T20:33:20-07:00
by Bob Pickle
fmw42 wrote:Otherwise, can you explain further why caption: does not do what you want?
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 letter
.
snibgo wrote:Bob Pickle wrote:Or could IM be improved so that it can combine images that are offset by fractions of a pixel?
It can, by using "-distort SRT" and fractional values of NewX and NewY. See
http://www.imagemagick.org/script/comma ... hp#distort
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.
Thanks for the tip, and I'll explore using SVG.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T21:13:17-07:00
by snibgo
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.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T21:30:11-07:00
by Bob Pickle
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.
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.
It seems to me that the only way SVG would work is if the RSVG library can handle complex scripts.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T22:25:05-07:00
by fmw42
It seems to me that the only way SVG would work is if the RSVG library can handle complex scripts.
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.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-05T23:28:10-07:00
by snibgo
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.
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-06T05:07:10-07:00
by Bob Pickle
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:
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
Re: Strokes in Pango vs. Complex scripts in IM
Posted: 2013-12-06T06:54:31-07:00
by snibgo
Thanks. On Windows 7 I used Notepad to create a file called arabic3.svg, coded as UTF-8.
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>
Then this command:
Code: Select all
convert -verbose arabic3.svg arabic3.png
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 .