Generate Arabic alphabet to SVG

649 views Asked by At

I created letters based on ASCII codes in SVG. Each character in a separate file. This is for use as clipart in a drawing app. The following is an example of a script I used to generate the SVG:

cat <<EOF > f.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   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"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   version="1.1"
   width="512"
   height="512"
   id="svg3834"
   inkscape:version="0.48.4 r9939"
   sodipodi:docname="Perspective1.svg">
  <g id="board">
EOF

mkdir letters

i=32
while [ $i -lt 400 ]; do
    let "i++"

   OUT=$( printf "letters/%03d.svg" $i)
   echo $OUT
   cat f.svg > $OUT
   cat <<EOF >> $OUT
  <text x="32" y="256" 
        font-family="Verdana" font-size="256" fill="red" >
EOF
   printf "&#%d;" $i >> $OUT
   cat <<EOF >> $OUT
  </text>
  </g>
</svg>
EOF
done

echo ""
echo " Now convert  $( cygpath -w `pwd`)/letters/*.svg on http://www.fileformat.info/convert/image/svg2raster.htm "
echo

ls letters

How can I do the same/similar to get the Arabic alphabetic/numbers?

1

There are 1 answers

0
Mingye Wang On BEST ANSWER

You can look for the Unicode code ranges. From Wikipedia, I got:

  • Arabic (0600-06FF)
  • Arabic Supplement (0750-077F)
  • Arabic Extended-A (08A0-08FF)
  • Arabic Presentation Forms-A (FB50-FDFF)
  • Arabic Presentation Forms-B (FE70-FEFF)
  • Arabic Mathematical Alphabetic Symbols (1EE00-1EEFF)
  • Rumi Numeral Symbols (10E60-10E7F)

If you want, e.g., Arabic 0600-06FF, change your loop to:

for ((i=0x600;i<=0x6FF;i++)); do

And everything should work, except for your font. It seems that Verdana only supports pan-latin scripts, therefore you'd better change font-family="Verdana" to font-family="Verdana,sans-serif" so you can have a nice fallback.

P.S. Your current handling of glyph metrics may seem broken with the wider glyphs in Arabic script.

P.P.S. Your file naming with 3-digit decimals may be broken due to the ranges of $i.