···11+#!/usr/bin/env python3
22+33+import sys
44+55+from bdflib import reader, writer, model
66+77+88+def double_glyph_data(gd):
99+ ret = []
1010+ for gl in gd:
1111+ # get the bits in each line
1212+ glh = int(gl, 16)
1313+ bits = bin(glh)[2:]
1414+ double_bits = []
1515+ for bit in bits:
1616+ # output two bits for each bit in the line
1717+ double_bits.append(bit)
1818+ double_bits.append(bit)
1919+ double_bits = ''.join(double_bits)
2020+ double_glh = int(double_bits, 2)
2121+ double_gl = hex(double_glh)[2:].upper()
2222+ # must 0-pad to two times the length of the original lines
2323+ double_gl = "0" * (len(gl) * 2 - len(double_gl)) + double_gl
2424+ # output the line two times
2525+ ret.append(double_gl)
2626+ ret.append(double_gl)
2727+ return ret
2828+2929+3030+bdf = reader.read_bdf(sys.stdin)
3131+3232+double_bdf = model.Font(bdf['FACE_NAME'],
3333+ bdf['POINT_SIZE'],
3434+ bdf['RESOLUTION_X'],
3535+ bdf['RESOLUTION_Y'])
3636+3737+for g in bdf.glyphs_by_codepoint.values():
3838+ double_bdf.new_glyph_from_data(g.name,
3939+ double_glyph_data(g.get_data()),
4040+ g.bbX * 2,
4141+ g.bbY * 2,
4242+ g.bbW * 2,
4343+ g.bbH * 2,
4444+ g.advance * 2,
4545+ g.codepoint)
4646+4747+writer.write_bdf(double_bdf, sys.stdout)