textgen: Add kerning rules for new font.

These rules provide special cases that adjust the spacing between
certain pairs of characters so that they fit together better.
This commit is contained in:
Simon Howard 2014-06-29 22:54:02 +00:00
parent 07a1a5d71f
commit c06cb4478c
2 changed files with 51 additions and 28 deletions

View file

@ -241,8 +241,22 @@ def generate_graphics(graphics, color=COLOR_WHITE):
print("# %s.gif: '%s'" % (name, text))
font.render_text(text, '%s.gif' % name, color=color)
def generate_kerning_test():
pairs = []
for c1 in sorted(font.char_widths):
char1 = "%c" % c1
for c2 in sorted(font.char_widths):
char2 = "%c" % c2
if font.kerning_adjust(char1, char2) != 0:
pairs.append(char1 + char2)
font.render_text(" ".join(pairs), "kerning.gif")
font = Font('fontchars', kerning_table=FONT_KERNING_RULES)
# Enable to generate test image file for tweaking kerning values:
#generate_kerning_test()
generate_graphics(red_graphics, COLOR_RED)
generate_graphics(blue_graphics, COLOR_BLUE)
generate_graphics(white_graphics, COLOR_WHITE)