]> git.tdb.fi Git - libs/gl.git/blobdiff - makefont.py
Drop Id tags and copyright notices from files
[libs/gl.git] / makefont.py
index ac816633bca2fc6e6efed5c372fa8a4a813665c9..e0b587938a5b80a85187a5e21c75a5c6f364df6e 100755 (executable)
@@ -1,14 +1,12 @@
 #!/usr/bin/python
 
-# $Id$
-
 def convert_def(fn):
        src=file(fn)
 
        line=src.readline()
        tw,th,fh,fa,fd=map(int, line.split())
 
-       result="default_size %d;\n"%fh
+       result="native_size %d;\n"%fh
        result+="ascent %.3f;\n"%(float(fa)/fh)
        result+="descent %.3f;\n"%(float(fd)/fh)
 
@@ -23,14 +21,15 @@ def convert_def(fn):
 
        return result
 
-def make_font(fn):
+def make_font(fn, size):
        import maketex
        import os
 
-       if os.system("ttf2png \"%s\" -o makefont-tmp.png -d makefont-tmp.def -t -p"%sys.argv[1]):
+       if os.system("ttf2png \"%s\" -o makefont-tmp.png -d makefont-tmp.def -t -p -s %d"%(fn, size)):
                raise Exception("Could not execute ttf2png")
 
-       result="texture_inline\n{\n"
+       result="texture\n{\n"
+       result+="wrap CLAMP_TO_EDGE;\n"
        result+=maketex.make_tex("makefont-tmp.png")
        result+="};\n"
        result+=convert_def("makefont-tmp.def")
@@ -43,8 +42,9 @@ def make_font(fn):
 if __name__=="__main__":
        import sys
 
-       if len(sys.argv)<3:
-               print "Usage: %s <font.ttf> <outfile>"
+       if len(sys.argv)<4:
+               import os
+               print "Usage: %s <font.ttf> <outfile> <size>"%os.path.basename(sys.argv[0])
        else:
                out=file(sys.argv[2], "w")
-               out.write(make_font(sys.argv[1]))
+               out.write(make_font(sys.argv[1], int(sys.argv[3])))