2018-01-01 14:10:10 +00:00
|
|
|
# TODO:
|
|
|
|
# Look into using: https://github.com/adobe-fonts/adobe-blank
|
|
|
|
# It should both reduce the size of the font and support all possible UTF8 chars
|
|
|
|
|
|
|
|
import fontforge
|
|
|
|
|
2018-06-03 11:54:38 +00:00
|
|
|
def generate(name, block):
|
|
|
|
print("Generating " + name)
|
|
|
|
# TODO:
|
|
|
|
# This needs to reach 0x9FCF to complete the CJK Ideographs
|
|
|
|
# But above around 0x7f00, we get this error:
|
|
|
|
# `Internal Error: Attempt to output 81854 into a 16-bit field. It will be
|
|
|
|
# truncated and the file may not be useful.`
|
|
|
|
for i in range(0x0000, 0x7F00):
|
|
|
|
if i == codepoint: continue
|
|
|
|
glyph = blocks.createChar(i)
|
|
|
|
glyph.width = 600
|
|
|
|
glyph.addReference(block)
|
|
|
|
|
|
|
|
print(blocks[codepoint].foreground)
|
|
|
|
blocks.fontname = name
|
|
|
|
blocks.fullname = name
|
|
|
|
blocks.familyname = name
|
|
|
|
|
|
|
|
# Fontforge's WOFF output doesn't seem to work. No matter, this isn't for an actual
|
|
|
|
# remote production website. The font is served locally from the extension and doesn't
|
|
|
|
# even need to look good.
|
|
|
|
blocks.generate(name + '.ttf')
|
|
|
|
|
|
|
|
# A font with just the █ (0x2588) for all unicode characters
|
2018-01-01 14:10:10 +00:00
|
|
|
blocks = fontforge.font()
|
|
|
|
blocks.encoding = 'UnicodeFull'
|
|
|
|
|
|
|
|
codepoint = 0x2588
|
|
|
|
glyph = blocks.createChar(codepoint)
|
|
|
|
glyph.width = 600
|
|
|
|
|
|
|
|
pen = blocks[codepoint].glyphPen()
|
|
|
|
pen.moveTo((0, -200))
|
|
|
|
pen.lineTo((0, 800))
|
|
|
|
pen.lineTo((600, 800))
|
|
|
|
pen.lineTo((600, -200))
|
|
|
|
pen.closePath()
|
|
|
|
|
2018-06-03 11:54:38 +00:00
|
|
|
generate('BlockCharMono', blocks[codepoint].glyphname)
|
2018-01-01 14:10:10 +00:00
|
|
|
|
2018-06-03 11:54:38 +00:00
|
|
|
# A font with just the space character, used to hide all text
|
|
|
|
blocks = fontforge.font()
|
|
|
|
blocks.encoding = 'UnicodeFull'
|
2018-01-01 14:10:10 +00:00
|
|
|
|
2018-06-03 11:54:38 +00:00
|
|
|
codepoint = 0x2003
|
|
|
|
glyph = blocks.createChar(codepoint)
|
|
|
|
glyph.width = 600
|
|
|
|
|
|
|
|
pen = blocks[codepoint].glyphPen()
|
|
|
|
pen.moveTo((0, 0))
|
|
|
|
pen.lineTo((0, 0))
|
|
|
|
pen.closePath()
|
2018-01-01 14:10:10 +00:00
|
|
|
|
2018-06-03 11:54:38 +00:00
|
|
|
generate('BlankMono', blocks[codepoint].glyphname)
|