#! /usr/bin/fontforge -script # # Copyright (C) 2005 Davide Viti # June 23, 2006 adapted for ttf-dejavu to operate on *.sfd instead # of *.ttf (Peter Cernak) # # 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; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # # "glyphs_to_remove" argument can be a single code point # or a range of codepoints separated by ":" # # code points can be specified both as integers and as unicode # you can also mix the two formats (i.e "48:u54") # # example: # # "strip_glyphs in.sfd out.sfd 12 u20 100:150 u200:u230 u300:65000" if ($argc < 4) Print( "Usage: strip_glyphs in out glyphs_to_remove..." ) Quit() endif Open($1); shift Reencode("unicodeFull") out = $1; shift # # Loop through the arguments and select the glyphs # which need to be cleared # while ($argc > 1) len = Strlen($1) colon_idx = Strstr($1, ":") # # argument is a single glyph # if (colon_idx == -1) if(Strstr($1, "u") == -1) SelectMore(Strtol($1)) ## Integer else SelectMore($1) ## Unicode code point (i.e "u0027") endif # # argument is a range low:high # else low = Strsub($1, 0, colon_idx) if(Strstr($1, "u") == -1) low = Strtol(low) ## Integer endif high = Strsub($1, colon_idx+1, len) if(Strstr($1, "u") == -1) high = Strtol(high) ## Integer endif SelectMore(low, high); endif shift endloop Clear() Save(out) Quit()