File size: 1,204 Bytes
913d3e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import vharfbuzz as hv

animal_names = [
  {"english": "cat", "arabic": "قطة"},
  {"english": "Lion", "arabic": "أسد"},
  {"english": "Elephant", "arabic": "فيل"},
  {"english": "Tiger", "arabic": "نمر"},
  {"english": "Cheetah", "arabic": "فهد"},
  {"english": "Monkey", "arabic": "قرد"},
  {"english": "Dolphin", "arabic": "دلفين"},
  {"english": "Penguin", "arabic": "بطريق"},
  {"english": "Kangaroo", "arabic": "كنغر"},
  {"english": "Fox", "arabic": "ثعلب"},
  {"english": "Eagle", "arabic": "نسر"},
  {"english": "Wolf", "arabic": "ذئب"},
  {"english": "Turtle", "arabic": "سلحفاة"},
  {"english": "Panda", "arabic": "باندا"},
  {"english": "Giraffe", "arabic": "زرافة"},
  {"english": "Bear", "arabic": "دب"},
  {"english": "Owl", "arabic": "بومة"}
]

fontpath = './data/fonts/ArefRuqaa.ttf'
vhb = hv.Vharfbuzz(fontpath)

path_templ = "/Users/bkhmsi/Desktop/Animal-Words/correct/{}.svg"

for animal in animal_names:
    txt = animal["arabic"]
    buf = vhb.shape(txt, {"features": {"kern": True, "liga": True}})
    svg = vhb.buf_to_svg(buf)
    with open(path_templ.format(animal["english"]), 'w') as fout:
        fout.write(svg)