Strokes in Pango vs. Complex scripts in IM

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?".
User avatar
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

Post by fmw42 »

Bob Pickle wrote:Thank you for your reply. Could you explain why cairopango and cairo are listed as delegates?
You installed them at some point and IM sees them. I have no idea which is being used for PANGO, though I believe it requires Cairo in some way or cairopango.

I do not have it installed at this time and so cannot compare to my delegates.

If your command produces a meaningful resulting image, then it is properly using PANGO to render the text.
nwohaibi
Posts: 1
Joined: 2014-09-08T01:58:54-07:00
Authentication code: 6789

Re: Strokes in Pango vs. Complex scripts in IM

Post by nwohaibi »

For Arabic typography, you might want to use Inkscape 0.9 directly as follows (Window7):

Code: Select all

inkscape "ar.svg" --export-png="C:\Users\Path\TO\output\arabicthabit.png" --export-dpi="900,900" --export-background="rgb(100%,100%,100%)"
Where ar.svg is:

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:Tahoma;"
       x="10" y="90"
         ><tspan>لغةٌ عربية</tspan>
    </text>
</svg>
You can replace the font-family:Tahoma by any font in your system.
Also you can change the output format as stated in the man pages of Inkscape. Moreover, you can start in Inkscape GUI and save the SVG and change what you want in the SVG XML in any scripting language.
Inkscape 0.48 returned buggy Arabic typography.

As for ImageMagick 6.8.9-7, I used Python+Wand(Python Lib)+arabic_reshaper(Python Lib)+bidi.algorithme(Python LIB) to generate correct Arabic typography in images:

Code: Select all

from wand.image import Image as wImage
from wand.display import display as wdiplay
from wand.drawing import Drawing
from wand.color import Color
import arabic_reshaper
from bidi.algorithm import get_display

reshaped_text = arabic_reshaper.reshape(u'ناصرٌ مَنّصوْرٌ')
artext = get_display(reshaped_text)

fonts = ['C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\DroidNaskh-Bold.ttf',
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\Thabit.ttf',
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\Thabit-Bold-Oblique.ttf',
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\Thabit-Bold.ttf',
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\Thabit-Oblique.ttf',
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\majalla.ttf',         
         'C:\\Users\\PATH\\TO\\FONT\\Thabit-0.02\\majallab.ttf',
         
         ]
draw = Drawing()
img =  wImage(width=1200,height=(len(fonts)+2)*60,background=Color('#ffffff')) 
#draw.fill_color(Color('#000000'))
draw.text_alignment = 'right';
draw.text_antialias = True
draw.text_encoding = 'utf-8'
#draw.text_interline_spacing = 1
#draw.text_interword_spacing = 15.0
draw.text_kerning = 0.0
for i in range(len(fonts)):
    font =  fonts[i]
    draw.font = font
    draw.font_size = 40
    draw.text(img.width / 2, 40+(i*60),artext)
    print draw.get_font_metrics(img,artext)
    draw(img)
draw.text(img.width / 2, 40+((i+1)*60),u'ناصر test')
draw(img)
img.save(filename='C:\\PATH\\OUTPUT\\\\arabictest.png'.format(r))
wdiplay(img)
Best regards
Nasser
n.wohaibi.co
Post Reply