Debian Codegraph @

debian/scripts/strip_glyphs.pe

raw
1 #! /usr/bin/fontforge
2 #
3 # Copyright (C) 2005 Davide Viti <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public
16 # License along with this program; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 # MA 02111-1307 USA
19 #
20 # "glyphs_to_remove" argument can be a single code point
21 # or a range of codepoints separated by ":"
22 #
23 # code points can be specified both as integers and as unicode
24 # you can also mix the two formats (i.e "48:u54")
25 #
26 # example:
27 #
28 # "strip_glyphs in.ttf out.ttf 12 u20 100:150 u200:u230 u300:65000"
29
30 if ($argc < 4)
31 Print( "Usage: strip_glyphs in out glyphs_to_remove..." )
32 Quit()
33 endif
34
35
36 Open($1); shift
37 Reencode("unicode")
38 out = $1; shift
39
40 #
41 # Loop through the arguments and select the glyphs
42 # which need to be cleared
43 #
44 while ($argc > 1)
45 len = Strlen($1)
46 colon_idx = Strstr($1, ":")
47
48 #
49 # argument is a single glyph
50 #
51 if (colon_idx == -1)
52 if(Strstr($1, "u") == -1)
53 SelectMore(Strtol($1)) ## Integer
54 else
55 SelectMore($1) ## Unicode code point (i.e "u0027")
56 endif
57
58 #
59 # argument is a range low:high
60 #
61 else
62 low = Strsub($1, 0, colon_idx)
63 if(Strstr($1, "u") == -1)
64 low = Strtol(low) ## Integer
65 endif
66
67 high = Strsub($1, colon_idx+1, len)
68 if(Strstr($1, "u") == -1)
69 high = Strtol(high) ## Integer
70 endif
71
72 SelectMore(low, high);
73 endif
74
75 shift
76 endloop
77
78 Clear()
79
80 Generate(out, "")
81 Quit()