[Fencommits] libvob: add a script to generate some fonts.
Matti J. Katila
majukati at cc.jyu.fi
Tue Mar 7 02:05:06 EET 2006
Wed Feb 8 22:14:02 EET 2006 Matti J. Katila <majukati at cc.jyu.fi>
* add a script to generate some fonts.
diff -rN -u libvob-old/vob/putil/font.py libvob-new/vob/putil/font.py
--- libvob-old/vob/putil/font.py 1970-01-01 02:00:00.000000000 +0200
+++ libvob-new/vob/putil/font.py 2006-03-07 02:05:06.069081961 +0200
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# (c): Matti J. Katila
+
+
+"""
+Creates a font image file from truetype fonts with pygame.
+:author: mkatila
+
+
+"""
+
+
+
+from pygame import font, image, Surface
+import sys
+
+
+
+chars = ' §½!"@#£¤$%&/{([)]=}?\\+`\'^*<>|;,:._-'+ \
+ '0123456789'+ \
+ 'abcdefghijklmnopqrstuvxyzåäöûüêëíì'+ \
+ 'ABCDEFGHIJKLMNOPQRSTUVXYZÅÄÖÛÜÊËÍÌ'
+
+font.init()
+
+#for fontFile in sys.argv[1:]:
+# print fontFile
+
+for fontFileShort in font.get_fonts():
+ print fontFileShort
+
+ if not fontFileShort.startswith('free'): continue
+
+ fontFile = font.match_font(fontFileShort)
+
+ f = font.Font(fontFile, 12)
+
+ maxHeight = f.size(chars)[1]
+
+ print maxHeight
+
+ width = 0
+
+ for ch in chars:
+ width += f.size(ch)[0]
+
+ print width, maxHeight
+
+ surface = Surface((width, maxHeight))
+ print surface
+
+ x,y = 0, 0
+ for ch in chars:
+ s = f.render(ch, 1, (255,255,255,255))
+ surface.blit(s, (x,y))
+ x += f.size(ch)[0]
+
+
+ image.save(surface, fontFileShort+".bmp")
+
+
More information about the Fencommits
mailing list