Page 1 of 3
Right-to-left languages?
Posted: 2010-03-26T14:12:25-07:00
by IDtheTarget
I'm trying to learn Dari, and want to use IM to create image files of words. When I try the below command, I get the word backwards in the image:
convert -background white -fill black -size 320x320 -encoding Unicode -font AlHor -gravity center -pointsize 40 label:'ﺱﻼﻣ' test01.png
What am i doing wrong? The word looks right in the arabic above, but the image below is what I get:
Re: Right-to-left languages?
Posted: 2010-03-26T14:39:28-07:00
by fmw42
I am no expert, but I don't believe that IM can create an image from text in a right to left manner. I may be wrong about that. So hopefully an expert can correct me if I am wrong.
You can try putting your text into a utf-8 compatible file and then referencing it as label:@textfile.txt and see if that works.
Is your font a ttf font? If not, see if you can find one that is ttf
Re: Right-to-left languages?
Posted: 2010-03-26T14:50:01-07:00
by IDtheTarget
Yep, they're ttf fonts.
Tried the file option, but that didn't work.
I saw somewhere that the developers had claimed that they'd tried it with Hebrew, which is another RTL language, but they didn't say exactly how they did it...
Re: Right-to-left languages?
Posted: 2010-03-26T15:10:44-07:00
by fmw42
are you sure your text editor is utf-8 compatible or in utf-8 mode?
see
http://www.imagemagick.org/Usage/text/#unicode
Re: Right-to-left languages?
Posted: 2010-03-27T05:12:21-07:00
by snibgo
Workarounds:
1. Reverse the characters in the input text file. Yuck.
2. Write the text into an SVG file, and use Inkscape to create the PNG. This works fine. When IM creates the PNG file, it gets it wrong.
Re: Right-to-left languages?
Posted: 2010-03-27T05:54:22-07:00
by IDtheTarget
fwm42: I *think* so. I'm using VIM in a PUTTY session, and PUTTY is set to UTF-8. I'm accessing it using a Windows-7 box using the arabic online keyboard. It shows up correctly on the screen, and also when I import the text into a web page or flash-card program. You can see the same word pasted here
http://www.birdvet.org/Dari/test.html.
snibgo: I'm not sure how I'd do either one, to be honest. I guess I could use perl to reverse the letters, but that would be a pain. I don't have any idea how to create svg files, nor how to use Inkscape from the command line.
I'm trying to create 320x320 images of 750 different phrases that I have to learn, to put them on my iPod. I was ecstatic when I learned that IM would do that just the way I want, except that the letters are backwards! I can't believe that IM doesn't work for 1/2 the world...I've GOT to be doing something wrong...
Re: Right-to-left languages?
Posted: 2010-03-27T06:44:07-07:00
by snibgo
I fear you are not doing anything wrong.
Inkscape and SVG are beyond the scope of this forum, but just to get you going, paste this into arabic.svg:
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>Hello ﺱﻼﻣ World</tspan>
</text>
</svg>
Then run:
Code: Select all
inkscape -f arabic.svg -e arabic.png -y 1
(Edit: I wrote "paste this into arabic.txt" but meant "paste this into arabic.svg")
Re: Right-to-left languages?
Posted: 2010-03-27T08:31:36-07:00
by magick
You can convert the SVG file with the convert program:
- convert arabic.svg arabic.png
Make sure you have SVG support enabled. Use
- identify -list format | grep svg
Re: Right-to-left languages?
Posted: 2010-03-27T08:53:45-07:00
by snibgo
Yes, indeed. But the arabic letters come out the wrong direction.
Re: Right-to-left languages?
Posted: 2010-03-27T09:04:56-07:00
by magick
We verified that the letters are in the correct order, at least under Linux. We're using the RSVG 2.26.0 delegate library (identify -list format | grep SVG).
Re: Right-to-left languages?
Posted: 2010-03-27T09:39:48-07:00
by snibgo
Under Windows 7, IM 6.6.0-8
MSVG rw+ ImageMagick's own SVG internal renderer
SVG rw+ Scalable Vector Graphics (XML 2.4.19)
SVGZ rw+ Compressed Scalable Vector Graphics (XML 2.4.19)
Code: Select all
inkscape -f arabic.svg -e arabic_ink.png -y 1
Under Ubuntu 9.10, IM 6.5.9-6 (yes, it is a bit old)
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (XML 2.6.32)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.6.32)
Re: Right-to-left languages?
Posted: 2010-03-27T11:06:44-07:00
by IDtheTarget
I'm using Ubuntu 9.10 and the default libraries, whatever they are:
benjamin@www:/var/www/Dari$ identify -list format | grep SVG
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (XML 2.7.3)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.7.3)
Code: Select all
benjamin@www:/var/www/Dari$ sudo aptitude show librsvg2-2
Package: librsvg2-2
State: installed
Automatically installed: no
Version: 2.26.0-1
Priority: optional
Section: libs
Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Uncompressed Size: 303k
Depends: libc6 (>= 2.4), libcairo2 (>= 1.2.4), libcroco3 (>= 0.6.1), libfontconfig1 (>= 2.4.0), libfreetype6 (>= 2.2.1), libglib2.0-0 (>= 2.16.0),
libgsf-1-114 (>= 1.14.14), libgtk2.0-0 (>= 2.17.0), libpango1.0-0 (>= 1.14.0), libxml2 (>= 2.6.27)
Suggests: librsvg2-bin
Conflicts: librsvg2-common (< 2.12)
Description: SAX-based renderer library for SVG files (runtime)
The rsvg library is an efficient renderer for Scalable Vector Graphics (SVG) pictures.
This package contains the runtime library, necessary to run applications using librsvg.
Homepage: http://librsvg.sourceforge.net/
I've verified that the Inkscape works, and IM does not. Inkscape is giving me the letters in the correct order, IM is not. I'm using the same perl script to pull the dari words from the same database, and producing the same svg file (below), with the results pictured below.
Code: Select all
<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="320"
height="320"
xml:lang="fa"
direction="rtl"
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:AlHor"
x="10" y="90">
<tspan>ﺱﻼﻣ</tspan>
</text>
</svg>
Inkscape: inkscape -f dari_01.svg -e dari_01-i.png
Image Magic: convert dari_01.svg dari_01-im.png
Re: Right-to-left languages?
Posted: 2010-03-27T12:00:06-07:00
by magick
Your version of ImageMagick does not have built-in support for the RSVG delegate library. You must install the RSVG delegate and its development RPM (so the headers are installed). Then when you build ImageMagick from source or SRPM, ImageMagick finds RSVG and includes support when its installed. ImageMagick should then render the SVG image correctly.
Re: Right-to-left languages?
Posted: 2010-03-27T12:36:32-07:00
by magick
We'll add a patch to ImageMagick 6.6.1-0 beta to support right-to-left languages. Is there a way to auto detect right-to-left? If not we'll add a new option to support it.
Re: Right-to-left languages?
Posted: 2010-03-27T13:03:29-07:00
by snibgo
I think it's normally done by looking up each character in a Unicode Character Database:
http://www.unicode.org/ucd/