ttfont - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       ttfont (1769B)
       ---
            1 #!/usr/local/plan9/bin/rc
            2 
            3 rm *.tpost *.troff *.pfb *.pfa *.afm map.sfd
            4 
            5 hex1=(0 1 2 3 4 5 6 7 8 9 A B C D E F)
            6 hex=()
            7 for(i in $hex1) for(j in $hex1) hex=($hex $i$j)
            8 {
            9         for(h in $hex)
           10                 echo $h 0x$h^00_0x$h^FF
           11 } >map.sfd
           12 for(font){
           13         f0=$font
           14         if(~ $font *.ttf)
           15                 font=`{9 basename $font .ttf}
           16         if not if(~ $font *.sfd)
           17                 font=`{9 basename $font .sfd}
           18         echo '
           19 import fontforge
           20 f = fontforge.open("'$f0'")
           21 ff = fontforge.open("./'$f0'")
           22 changed = True
           23 while changed:
           24         changed = False
           25         for i in range(0, len(f)):
           26                 try:
           27                         f[i].temporary = [ ]
           28                 except:
           29                         pass
           30         
           31         for i in range(0, len(f)):
           32                 try:
           33                         f[i].temporary.append(i)
           34                 except:
           35                         pass
           36         
           37         for i in range(0, len(f)):
           38                 try:
           39                         g = f[i]
           40                         codes = g.temporary
           41                         if len(codes) > 1:
           42                                 print "Doubled: ", g.temporary
           43                                 gg = ff[i]
           44                                 f.removeGlyph(g)
           45                                 for j in range(1, len(codes)):
           46                                         f.createMappedChar(codes[j])
           47                                 f.createInterpolatedGlyph(gg, gg, 0)
           48                                 changed = True
           49                 except:
           50                         pass
           51 
           52 f.generate("'$font^%s.pfb'", "", ("afm",), 72, "map.sfd")
           53 ' >fontforge.in
           54         fontforge '-lang=py' -script fontforge.in
           55         {
           56                 echo name $font
           57                 echo fontname $font
           58         } >$font.troff
           59         >$font.tpost
           60         for(h in $hex){
           61                 if(test -f $font$h.pfb){
           62                         pfb2pfa $font$h.pfb
           63                         mv $font$h.pfa /usr/local/plan9/postscript/font/$font$h
           64                         afm2troff -h -o 0x$h^00 $font$h.afm >>$font.troff
           65                         echo 0x$h^00 0x$h^FF $font$h >>$font.tpost
           66                 }
           67         }
           68         {
           69                 echo '0x0027 0x0027 0x19 '$font'20  # map apostrophe to right quote'
           70                 echo '0x0060 0x0060 0x18 '$font'20  # map grave to left quote'
           71         } >>$font.tpost
           72 
           73         sam -d $font.troff <$PLAN9/dist/troff/devutf.sam
           74         if(~ $font *Mono*)
           75                 sam -d $font.troff <$PLAN9/dist/troff/mono.sam
           76         cp $font.troff /usr/local/plan9/troff/font/devutf/$font
           77         cp $font.tpost /usr/local/plan9/postscript/troff/$font
           78 }