Positionig vowels in Hebrew Text using 'convert'

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Jonathan Allen
Posts: 4
Joined: 2012-06-28T11:37:32-07:00
Authentication code: 13

Positionig vowels in Hebrew Text using 'convert'

Post by Jonathan Allen »

I'm working to draw Hebrew words using 'convert' and a Hebrew font. So far, with all the consonants, everything is fine. However, I'm having a problem with the vowels. In Hebrew, the vowels are printed under (or sometimes over) the consonants. The letter 'vet', for example, in the font is represented by the character 'a'. The vowel 'shva', which goes underneath the consonant it follows, is represented by the character 0xa7. I am using 'convert' with the parameter 'label:....' to hold the string of characters to be printed in the Hebrew font. If I use the string 'label:a\xa7', they come out one after the other.

So here's the question: how can I tell 'convert' that the vowels are to be set under (or over) the previous character? In a printed document (from a Hebrew word processor) they actually occupy the same character space. To make matters slightly more complicated, some of the consonants have descenders, so the positioning of the vowel needs to be moved to one side or the other to look sensible and for both to be clearly seen.

Jonathan
Jonathan Allen
Posts: 4
Joined: 2012-06-28T11:37:32-07:00
Authentication code: 13

Re: Positionig vowels in Hebrew Text using 'convert'

Post by Jonathan Allen »

And, if you'll excuse the bad etiquette of replying to my own question, I'm running 'convert' in a .php file to generate an image directly into a browser:

$cmd = "convert -size x98 -pointsize 12 -font ../fonts/DFrank.ttf $font label:'$text' GIF:-";
header("Content-type: image/gif");
passthru($cmd, $retval);

I have already used strrev() to reverse the character flow (as Hebrew is RTL). The font file exists, the image appears, just not quite correctly vowelled.

Jonathan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Positionig vowels in Hebrew Text using 'convert'

Post by fmw42 »

you probably need a proper UTF-8 unicode font that has all the glyphs you need.

see
http://www.imagemagick.org/Usage/text/#unicode


search google for hebrew ttf fonts

for example
http://www.pement.org/hebfonts.htm


Also IM can reverse the text direction (on relatively newer versions). see
http://www.imagemagick.org/script/comma ... #direction
Last edited by fmw42 on 2012-06-28T19:25:13-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Positionig vowels in Hebrew Text using 'convert'

Post by anthony »

Also try the new text formating delegate pango: whcih can mix hebrew with english, and do the reversals correctly!

http://www.imagemagick.org/Usage/text/#pango
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jonathan Allen
Posts: 4
Joined: 2012-06-28T11:37:32-07:00
Authentication code: 13

Re: Positionig vowels in Hebrew Text using 'convert'

Post by Jonathan Allen »

Please correct me if I am wrong, but what you seem to be telling me is that 'convert' can't do what I want to do - the equivalent of a virtual back-space/over-strike combination - to map a vowel character over a consonant character. Is that correct?

The solution you are proposing is to use a (UTF) font that actually has all the consonant/vowel/accent combinations drawn out as individual characters?

This makes it terribly difficult to convert a spelled out hebrew word -

Code: Select all

vav patach yod dagesh patach ayin patach lamed
into a 'label' string that ''convert' can then accept because of the number of variants (22 consonants, 10 vowels, a dozen or more accents).

Jonathan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Positionig vowels in Hebrew Text using 'convert'

Post by fmw42 »

I don't know for sure about the vowel issue. But it certainly can deal with the right to left. I have no experience with the vowel issue, so cannot say for sure how that might be handled. Have you seen any other text process generate what you want? If so, what font were they using?

If I had more time, I would just download a variety of Hebrew fonts and give them a try in the latest image magick. So perhaps you may want to try that for at least one font and show us what you get and your command, along with the font. Then others can check your syntax and try other things.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Positionig vowels in Hebrew Text using 'convert'

Post by anthony »

There are converters that should be able to convert the text to UTF format.
On Linux try the command "iconv" or "recode"

I myself often need to convert the text format "GB2312" (mainland Chinese text) to Unicode for printing.
ASIDE: My wife is Chinese, and I often print things for her, even though I can;t read it myself.

Hmmm... it has 'HEBREW' as a text format, but it might be under some other text 'codename'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Jonathan Allen
Posts: 4
Joined: 2012-06-28T11:37:32-07:00
Authentication code: 13

Re: Positionig vowels in Hebrew Text using 'convert'

Post by Jonathan Allen »

Having done a lot more work, including following the example in "Text Examples" to use the Linux command 'printf' to generate Unicode characters, and checking the performance with a number of unicode fonts, I have come to the conclusion that 'convert' is still doing things wrong.

If you look at this Unicode document http://unicode.org/faq/char_combmark.html, at the Question "Do I always use U+0323 COMBINING DOT BELOW when I need to put a dot under a character?", you'll see that Unicode expects Hebrew vowels to follow their consonant, so that a letter 'alef' that has the vowel 'hiriq' below it would be represented by the two consecutive Unicode characters \u05d0 + \u05b4. Convert draws both characters perfectly, but refuses to place the vowel under the letter. If you swap, just for the sake of the exercise the HEBREW POINT HIRIQ for the COMBINING DOT BELOW, then the letter and the vowel swap order (ie the dot comes first), but they still don't combine.

Is 'convert' supposed to support the Unicode 'COMBINING' characters? And how do I move forward with Hebrew vowels?
Post Reply