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