Page 3 of 3

Re: Strokes in Pango vs. Complex scripts in IM

Posted: 2013-12-11T20:08:46-07:00
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.

Re: Strokes in Pango vs. Complex scripts in IM

Posted: 2014-09-08T02:19:28-07:00
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