summaryrefslogtreecommitdiff
path: root/language/chinese/CJK/cjk-4.8.5/contrib/wadalab/makefont
blob: 98b20cd541a2b105319052691f64c6a4eee6b72d (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
#
# Copyright (C) 1994-2021  Werner Lemberg <wl@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in doc/COPYING; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301 USA

# Version 1.0
#
# This script transforms Wadalab PFA and AFM files created by the
# wftodm program into PFB and TFM files.  All files in the current
# directory and its subdirectories are converted.
#
# Additionally, it normalizes the font matrix so that the subfonts work
# with pdfTeX; for convenience, it also inserts `closepath' commands to
# end subpaths in glyphs.
#
# Note that an older version of this script (without a version number) has
# some flaws; you should either regenerate all Wadalab subfonts or use the
# `fixwada' script to fix PFB fonts which have already been created with
# this older version.
#
# The programs t1asm, t1disasm, and afm2tfm must be in the path.

for f in `find . -name '*.pfa' -print`; do
  echo processing $f
  name=`basename $f .pfa`
  t1disasm < $name.pfa > $name.old

  cat $name.old | \
  awk '
    {
      sub(/001\.001/, "001.002")
      sub(/\[.001 0 0 .001 0 -0.16\]/, "[.001 0 0 .001 0 0]")
      sub(/\[0 0 1000 1000\]/, "[0 -160 1000 840]")

      if (/%%Creation/) {
        print "%%CreationDate: 2003-Feb-07"
        next
      }

      if (/hsbw/)
        waiting_for_Xmoveto = 1

      if (waiting_for_Xmoveto) {
        if (/rmoveto/) {
          printf "\t%d %d rmoveto\n", $1, $2 - 160
          waiting_for_Xmoveto = 0
          next
        }
        if (/vmoveto/) {
          printf "\t%d vmoveto\n", $1 - 160
          waiting_for_Xmoveto = 0
          next
        }
        if (/hmoveto/) {
          printf "\t%d %d rmoveto\n", $1, -160
          waiting_for_Xmoveto = 0
          next
        }
      }

      if (/moveto/)
        print "\tclosepath"

      if (/hstem/) {
        printf "\t%d %d hstem\n", $1 - 160, $2
        next
      }

      print
    }
  ' > $name.asm
  rm $name.old

  t1asm < $name.asm > $name.pfb
  rm $name.asm
done

for f in `find . -name '*.afm' -print`; do
  echo processing $f
  name=`basename $f .afm`
  mv $name.afm $name.old

  cat $name.old | \
  sed -e "
      s/FontBBox 0 0 1000 1000/FontBBox 0 -160 1000 840/
      s/B 0 0 1000 1000/B 0 -160 1000 840/
  " > $name.afm

  rm $name.old

  afm2tfm $name.afm &> /dev/null
done

# EOF