add traditional chinese font tool and documents.
This commit is contained in:
parent
4c98939e3e
commit
d03f207bb8
4 changed files with 203 additions and 0 deletions
11
fonts/locale/zh_tw_docs/COPYING.txt
Normal file
11
fonts/locale/zh_tw_docs/COPYING.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
COPYING.txt for "tuxpaint-ttf-zh_tw"
|
||||
Traditional Chinese TrueType Font (TTF) for Tux Paint
|
||||
|
||||
The "zh_tw.ttf" font file is a subset of a "wp010-05.ttf" TrueType font.
|
||||
|
||||
The "wp010-05.ttf" by Hann-Tzong Wang <htwang@math.cycu.edu.tw>,
|
||||
and located at: http://www.ossacc.org/Download/misc/wangfont
|
||||
|
||||
The orig-font "wp010-05.ttf" is GPL licensed, so the subset font "zh_tw.ttf"
|
||||
is GPL, too.
|
||||
|
||||
68
fonts/locale/zh_tw_docs/README.txt
Normal file
68
fonts/locale/zh_tw_docs/README.txt
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
README.txt for "tuxpaint-ttf-zh_tw"
|
||||
Traditional Chinese TrueType Font (TTF) for Tux Paint
|
||||
|
||||
Song Huang
|
||||
song@song.idv.tw
|
||||
|
||||
Oct 23, 2005 - Oct 23, 2005
|
||||
|
||||
This font is required to run Tux Paint in Traditional Chinese.
|
||||
(e.g., with the "--lang zh_tw" option)
|
||||
|
||||
To install, run "make install" as the superuser ('root').
|
||||
The font file will be placed in the /usr/share/tuxpaint/fonts/locale/ directory.
|
||||
|
||||
---
|
||||
|
||||
----- Original Message -----
|
||||
From: "Song Huang" <Song@ossacc.org>
|
||||
To: "Developmental mailing list for Tux Paint, a drawing program for young children." <tuxpaint-dev@tux4kids.net>
|
||||
Sent: Tuesday, October 26, 2004 12:10 PM
|
||||
Subject: the font subset maker
|
||||
|
||||
|
||||
> Hi,
|
||||
>
|
||||
> The font mustly large, especially traditional chinese font more then 13 MB.
|
||||
>
|
||||
> I used python and fontforge to take PO file's msgstr, and generate a subset font file.
|
||||
> here is the files:
|
||||
> - python script:
|
||||
> http://www.ossacc.org/Members/song/DrWangFreeTTF/maketuxfont.py
|
||||
> - fontforge script:
|
||||
> http://www.ossacc.org/Members/song/DrWangFreeTTF/tuxpaintsubset.pe
|
||||
> - the traditional chinese font subset file:
|
||||
> http://www.ossacc.org/Members/song/DrWangFreeTTF/zh_tw.ttf
|
||||
>
|
||||
> Usage: (put the scripts together)
|
||||
>
|
||||
> $ ./maketuxfont.py -h
|
||||
> usage: ./maketuxfont.py [options] original_font_file
|
||||
>
|
||||
> options:
|
||||
> --version show program's version number and exit
|
||||
> -h, --help show this help message and exit
|
||||
> -lLOCALE, --locale=LOCALE
|
||||
> to make the locale fonts subset
|
||||
> -pPOFILE, --pofile=POFILE
|
||||
> parse the pofile to get strings
|
||||
>
|
||||
> Example:
|
||||
>
|
||||
> $ ./maketuxfont.py \
|
||||
> -l zh_tw \
|
||||
> -p tuxpaint/src/po/zh_tw.po \
|
||||
> -p tuxpaint-stamps/po/tuxpaint-stamps-zh_tw.po \
|
||||
> wp010-05.ttf
|
||||
>
|
||||
> then will get the "zh_tw.ttf" file.
|
||||
>
|
||||
> Best regards,
|
||||
> =============================================
|
||||
> Song Huang
|
||||
> OSSACC (OSS Application Consulting Center)
|
||||
> http://www.ossacc.org
|
||||
> =============================================
|
||||
>
|
||||
|
||||
|
||||
58
fonts/locale/zh_tw_docs/maketuxfont.py
Normal file
58
fonts/locale/zh_tw_docs/maketuxfont.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
# Copyright: Song Huang <song@song.idv.tw>
|
||||
# License: GUN GPL
|
||||
# 2004/10/26
|
||||
|
||||
import popen2
|
||||
from optparse import OptionParser
|
||||
from codecs import open as cOpen
|
||||
from string import letters, punctuation
|
||||
|
||||
def parsePO(po):
|
||||
try:
|
||||
poFile = cOpen(po, 'r', 'utf8')
|
||||
print '>> parse ', po
|
||||
for line in poFile.readlines():
|
||||
if line[:6] == 'msgstr':
|
||||
line = line.strip()
|
||||
for s in line[8:-1]:
|
||||
s = str(ord(s))
|
||||
if s not in stringList:
|
||||
stringList.append(s)
|
||||
poFile.close()
|
||||
except IOError, e:
|
||||
print "Unable to open the file:" , po, e
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse script arguments
|
||||
optparser = OptionParser(usage='./%prog [options] original_font_file', version="%prog 0.2")
|
||||
optparser.add_option("-l", "--locale", action="store", help="to make the locale fonts subset")
|
||||
optparser.add_option("-p", "--pofile", action="append", help="parse the pofile to get strings")
|
||||
(options, args) = optparser.parse_args()
|
||||
|
||||
# get all words
|
||||
if options.locale and options.pofile and args:
|
||||
stringList = []
|
||||
for c in list(letters + punctuation):
|
||||
stringList.append(str(ord(c)))
|
||||
for po in options.pofile:
|
||||
parsePO(po)
|
||||
stringList.sort()
|
||||
#print "poList = ", options.pofile, "\nstringList = ", stringList
|
||||
else:
|
||||
print "Error: lost some option or original font file, please run the script with --help argument."
|
||||
|
||||
# make font subset
|
||||
cmd = "./tuxpaintsubset.pe %s %s.ttf %s" % (args[0], options.locale, ' '.join(stringList))
|
||||
print cmd
|
||||
r, w, e = popen2.popen3(cmd)
|
||||
msg = r.read()
|
||||
if msg:
|
||||
print msg
|
||||
error = e.read()
|
||||
if error:
|
||||
print error
|
||||
r.close()
|
||||
w.close()
|
||||
e.close()
|
||||
66
fonts/locale/zh_tw_docs/tuxpaintsubset.pe
Normal file
66
fonts/locale/zh_tw_docs/tuxpaintsubset.pe
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env fontforge
|
||||
# >> The script first draft by Edward Lee<Edward.bbs@bbs.sayya.org>. <<
|
||||
# Copyright: Song Huang <song@song.idv.tw>
|
||||
# License: GUN GPL
|
||||
# 2004/10/26
|
||||
|
||||
if ($argc < 4)
|
||||
Print("usage: ", $0, " orig.ttf generate.ttf char_num [char_num ...]")
|
||||
Quit(1)
|
||||
endif
|
||||
|
||||
Print("Loading ", $1, "...")
|
||||
Open($1)
|
||||
|
||||
a=Array(($argc - 3))
|
||||
Print("argc = " + $argc)
|
||||
i=3
|
||||
while ( i < $argc )
|
||||
a[(i-3)]=Strtol($argv[i])
|
||||
# Print(">> " + $argv[i])
|
||||
i++
|
||||
endloop
|
||||
|
||||
i=$argc - 4
|
||||
while ( i >= 0 )
|
||||
SelectMore(a[i])
|
||||
i--
|
||||
endloop
|
||||
Copy()
|
||||
|
||||
fontName=GetTTFName(0x404, 6) + "[Subset for TuxPaint] "
|
||||
fontCopyRight=GetTTFName(0x404, 0)
|
||||
fontVersion=GetTTFName(0x404, 5) + "[Subset for TuxPaint] "
|
||||
fontMaker="TuxPaint's Font Subset Maker"
|
||||
fontSample="TuxPaint Font Subset."
|
||||
|
||||
Close()
|
||||
|
||||
New()
|
||||
Reencode("unicode")
|
||||
ScaleToEm(1024)
|
||||
# nameid=1 Font Family Name
|
||||
SetTTFName(0x404,1,fontName)
|
||||
# nameid=4 Full Font Name
|
||||
SetTTFName(0x404,4,fontName)
|
||||
# nameid=5 Version string
|
||||
SetTTFName(0x404,5,fontVersion)
|
||||
# nameid=6 Postscript name for the font
|
||||
SetTTFName(0x404,6,fontName)
|
||||
# nameid=8 Manufacturer Name
|
||||
SetTTFName(0x404,8,fontMaker)
|
||||
# nameid=19 Sample text
|
||||
SetTTFName(0x404,4,fontName)
|
||||
|
||||
i=$argc - 4
|
||||
while ( i >= 0 )
|
||||
SelectMore(a[i])
|
||||
i--
|
||||
endloop
|
||||
Paste()
|
||||
|
||||
Print("Generating fonts...")
|
||||
Generate($2)
|
||||
Close()
|
||||
|
||||
Quit(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue