summaryrefslogtreecommitdiff
path: root/language/chinese/CJK/cjk-4.8.5/utils/subfonts/subfonts.pe
blob: 347e53b6df4c369b10cf98fc30ebc70727f48481 (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
# Generate CJK subfonts from master font.
# The fonts are created in the current directory.
#
# $1: The master font (e.g., `bsmi00lp.ttf').
# $2: The name stem for the subfonts (e.g., `bsmilp').
# $3: The subfont definition file, mapping from Unicode to whatever
#     (e.g., `UBig5.sfd', which maps to Big 5).
#
# A collection of useful subfont definition files for CJK fonts can be found
# in the ttf2pk package.

# 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

if (Strtol($version) < 20071105)
  Print("Can't use FontForge version before 2007-11-05.  Aborting.");
  Quit(1);
endif;

if ($argc != 4)
  Print("usage: [fontforge -script] ", $0, " master-font name-stem SFD-file");
  Quit(1);
endif;

Print("Loading ", $1, "...");
Open($1);

if ($cidfontname != "")
  CIDFlatten();
endif;

Reencode("ucs4");

copyright = $copyright \
            + Chr(10) + Chr(10) \
            + "Subfont version " \
            + Strftime("%F", 1, "C") \
            + ".";
SetFontNames("", "", "", "", copyright, "");

Print("Ensure third order curves...");
SetFontOrder(3);

Print("Scaling to PostScript units...");
ScaleToEm(900, 100);

num_chars = CharCnt();
count = 0;
delta = 100;

while (count + delta < num_chars)
  Print(count, "/", num_chars - 1, ":");
  Select(count, count + delta);

  Print("  Add extrema...");
  AddExtrema();

  Print("  Simplifying outlines...");
  Simplify(0, 2);

  count += delta;
endloop;

Print(count, "/", num_chars - 1, ":");
Select(count, num_chars - 1);

Print("  Add extrema...");
AddExtrema();

Print("  Simplifying outlines...");
Simplify(0, 2);

SelectAll();

# generate AFM and TFM files, no PS hints, and rounded PS coordinates
Print("Generating subfonts...");
Generate($2 + "%s.pfb", "", \
         0x1 | 0x100 | 0x10000 | 0x80000 | 0x200000, \
         -1, $3);

Quit(0);