Text with special characters (ღ for example)

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
sheepherd
Posts: 3
Joined: 2012-06-08T06:53:21-07:00
Authentication code: 13

Text with special characters (ღ for example)

Post by sheepherd »

There are numerous images which I should annotate with text, some phrases have some special characters such as ღ and some others.

Code: Select all

convert label:ღтестღ image.jpg
тест - is test in Russian
as a result of this command i get image with text
?тест?
how can I make imagemagick draw such characters on images?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text with special characters (ღ for example)

Post by fmw42 »

I am not an expert on this, but perhaps the font you are using does not support that character.

also see
http://www.imagemagick.org/Usage/text/#unicode
sheepherd
Posts: 3
Joined: 2012-06-08T06:53:21-07:00
Authentication code: 13

Re: Text with special characters (ღ for example)

Post by sheepherd »

I tried to create image with such character in GIMP image editor using font 'Ubuntu' - it works. Then I tried to do same with imagemagick:

Code: Select all

$ convert -list font |grep -i ubuntu
  Font: Ubuntu-Bold
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf
  Font: Ubuntu-Bold-Italic
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf
  Font: Ubuntu-Condensed-Regular
    family: Ubuntu Condensed
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-C.ttf
  Font: Ubuntu-Italic
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf
  Font: Ubuntu-Light
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-L.ttf
  Font: Ubuntu-Light-Italic
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-LI.ttf
  Font: Ubuntu-Mono-Bold
    family: Ubuntu Mono
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-B.ttf
  Font: Ubuntu-Mono-Bold-Italic
    family: Ubuntu Mono
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-BI.ttf
  Font: Ubuntu-Mono-Italic
    family: Ubuntu Mono
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-RI.ttf
  Font: Ubuntu-Mono-Regular
    family: Ubuntu Mono
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf
  Font: Ubuntu-Regular
    family: Ubuntu
    glyphs: /usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf

Code: Select all

printf "тест \U10E6" | convert -font Ubuntu-Regular -background lightblue -fill blue -pointsize 36 label:@-  label_quotes.gif
still getting: тест?

\U10E6 - is unicode value of ღ
http://en.wikipedia.org/wiki/List_of_Unicode_characters
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text with special characters (ღ for example)

Post by fmw42 »

It fails for me using Arial and label: or caption:, but works if I use PANGO:. IM 6.7.7.6 Q16 Mac OSX SnowLeopard

convert -font Arial Pango:ღтестღ image.jpg

But you have to install the PANGO delegate. I have

convert -list format
...
PANGO* PANGO r-- Pango Markup Language (Pangocairo 1.30.0)


So it could be a bug in label: and captions:. The IM developers would have to assess that.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text with special characters (ღ for example)

Post by magick »

You need a font that has a glyph defined for \U10E6. We use Arial Unicode MS and the character renders properly:
  • convert -pointsize 48 -font arial-unicode.ttf label:ღтестღ label.png
sheepherd
Posts: 3
Joined: 2012-06-08T06:53:21-07:00
Authentication code: 13

Re: Text with special characters (ღ for example)

Post by sheepherd »

magick wrote:You need a font that has a glyph defined for \U10E6. We use Arial Unicode MS and the character renders properly:
  • convert -pointsize 48 -font arial-unicode.ttf label:ღтестღ label.png
Now it works with this font. Thank you very much :)
Post Reply