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
|
#! /usr/bin/fontforge
#
# stripttf - Strip TrueType font of unused characters
#
# Copyright (c) 2005 Hidetaka Iwai <tyuyu@debian.or.jp>
#
if ($argc < 4)
Print( "Usage: stripttf in out used_codepoint..." )
Quit()
endif
Open($1); shift
Reencode("unicode")
out = $1; shift
# Get the size of array from the last argument
# (to do this, the given list must be sorted)
num = Strtol($argv[$argc - 1]) + 1
# Create an array to select used characters.
used = Array(num)
# Select used characters according to the given list
i = 0
while (i < num && $argc > 1)
if (i == Strtol($1))
used[i] = 1; shift
else
used[i] = 0
endif
++i
endloop
# Remove unused characters.
Select(used); SelectInvert(); Clear()
size = Array(2)
# Bitmap point
size[0] = 12
size[1] = 16
# Output the result
BitmapsAvail(size)
Generate(out, "ttf")
Quit()
|