balsamine.2014-2015
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

trace_alphabet-steph.sh
text/x-sh

Download raw (5.1 KB)

#!/bin/bash

 FONTFAMILY=${1}
 #FONTFAMILY="Ume P Gothic Balsa"
  #FONTFAMILY="Ume P Mincho"

  TRACEWIDTH=4000 

  OUTPUTDIR=o


  WNAME=`echo 00$WEIGHT | rev | cut -c 1-2 | rev`
  NAME=Umetra-P_`echo $FONTFAMILY | rev | cut -d " " -f 1 | rev`-stroke

# --------------------------------------------------------------------------- # 
  TMPDIR=tmp
  SHIFT=`expr 35`
  e() { echo $1 >> ${DUMP}; }
 
 
for LETTER in "!" """ "#" "$" "%" "&" "'" "(" ")" "*" "+" "," "-" "." "/" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" ":" "&#59;" "<" "=" ">" "?" "@" "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z" "[" "\" "]" "^" "_" "`" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" "{" "|" "}" "~" "" "€" "" "‚" "ƒ" "„" "…" "†" "‡" "ˆ" "‰" "Š" "‹" "Œ" "" "Ž" "" "" "‘" "’" "“" "”" "•" "–" "—" "˜" "™" "š" "›" "œ" "" "ž" "Ÿ" " " "¡" "¢" "£" "¤" "¥" "¦" "§" "¨" "©" "ª" "«" "¬" "­" "®" "¯" "°" "±" "²" "³" "´" "µ" "¶" "·" "¸" "¹" "º" "»" "¼" "½" "¾" "¿" "À" "Á" "Â" "Ã" "Ä" "Å" "Æ" "Ç" "È" "É" "Ê" "Ë" "Ì" "Í" "Î" "Ï" "Ð" "Ñ" "Ò" "Ó" "Ô" "Õ" "Ö" "×" "Ø" "Ù" "Ú" "Û" "Ü" "Ý" "Þ" "ß" "à" "á" "â" "ã" "ä" "å" "æ" "ç" "è" "é" "ê" "ë" "ì" "í" "î" "ï" "ð" "ñ" "ò" "ó" "ô" "õ" "ö" "÷" "ø" "ù" "ú" "û" "ü" "ý" "þ" "€" \
"Œ" "œ" "…" "–" "—" "‘" "’" "“" "”" "Ⅰ" "Ⅱ" "Ⅲ" "Ⅳ" "Ⅴ" "Ⅵ" "Ⅶ" "Ⅷ" "Ⅸ" "Ⅹ" "Ⅺ" "Ⅻ" "Ⅼ" "Ⅽ" "Ⅾ" "Ⅿ" "←" "↑" "→" "↓" "⓪" "①" "②" "③" "④" "⑤" "⑥" "⑦" "⑧" "⑨" "♩" "♪" "♫" "♬" "♭" "♮" "♯" \
"′" "″" "∢"
   do
 
      DUMP=$TMPDIR/${LETTER}.svg
 
      e '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'
      e '<svg width="4000" height="4500" id="svg" version="1.1"'
      e 'xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"'
      e '>'
      e '<g inkscape:label="letter" inkscape:groupmode="layer" id="X">'
      e '<flowRoot xml:space="preserve" id="flowRoot"'
 
      e "style=\"font-size:4000px;\
                 font-style:normal;\
                 font-variant:normal;\
                 font-weight:normal;\
                 font-stretch:normal;\
                 text-align:center;\
                 line-height:100%;\
                 letter-spacing:0px;\
                 word-spacing:0px;\
                 writing-mode:lr-tb;\
                 text-anchor:middle;\
                 fill:#000000;\
                 fill-opacity:1;\
                 stroke:none;\
                 font-family:$FONTFAMILY;\
                -inkscape-font-specification:$FONTFAMILY\""
      e '><flowRegion id="flowRegion">'
      e "<rect id=\"rect\" width=\"4000\" height=\"4500\" x=\"0\" y=\"-$SHIFT\" />"
      e "</flowRegion><flowPara id=\"flowPara\">$LETTER</flowPara></flowRoot>"
      e '</g>'
      e '</svg>'
 
      # Export SVG into PNG
      inkscape --export-png=${DUMP%%.*}.png \
               --export-background=#ffffff \
               --export-width=$TRACEWIDTH \
              $DUMP
        
      # This is only for Steph's machine which fails on autotracing png, but it makes the script super slow
      convert ${DUMP%%.*}.png ${DUMP%%.*}.gif

      # Vectorize bitmap with stroke
      autotrace -centerline \
                -color-count=2 \
                -background-color=ffffff \
                -output-file=$DUMP \
                ${DUMP%%.*}.gif

      # Setting "stroke" to "none" forces stroke import in Fontforge
      STYLE="style=\"stroke:none;fill:none;\""

      # Apply stroke style
      sed -i "s/style=\"[^\"]*\"/$STYLE/g" $DUMP

      # Removes png files
      #rm ${DUMP%%.*}.png

    done


    echo "Launching Ana and Ricardo's script"
    # Launches Ana and Ricardo's script (takes a set of SVG files and puts it into an sfd file)
    python2 svg2ttf-0.4.py ${1}

    # Moves "output.ttf" into "o" folder
    #mv output.ttf ${OUTPUTDIR}/${NAME}.ttf


    # Clean the "tmp" folder
    #rm $TMPDIR/*.*



exit 0;