Rasterizing glyphs into a new font
Rasterize glyphs from an existing font into another font with a script.
Steps
-
Open the font you wish to rasterize.
-
Open the Scripting Window and paste the script below.
-
Adjust the values at the top of the script as needed.
-
If you wish to rasterize only some glyphs, select them in the Font Overview.
If the selection is empty, all glyphs in the font will be rasterized. -
Run the script to rasterize the glyphs into a new font.
Code
# menuTitle: rasterize selected glyphs into a new font
from hTools3_rasterizer.modules.rasterizer import RasterGlyph, drawElement
# --------
# settings
# --------
egrid = 30
esize = 25
eshape = 'super'
eround = 0.75
eglyph = '_element'
# ---------
# rasterize
# ---------
srcFont = CurrentFont()
dstFont = NewFont(showInterface=False)
bitGlyph = dstFont.newGlyph(eglyph)
drawElement(bitGlyph, esize, type=eshape, roundness=eround)
glyphNames = srcFont.selectedGlyphNames if len(srcFont.selectedGlyphNames) else srcFont.glyphOrder
for glyphName in glyphNames:
if glyphName == eglyph:
continue
srcGlyph = srcFont[glyphName]
dstGlyph = dstFont.newGlyph(glyphName)
R = RasterGlyph(srcGlyph)
R.elementGlyph = eglyph
R.elementSpace = egrid
R.elementSize = egrid
R.scan()
R.draw(dstGlyph, components=True)
dstGlyph.width = srcGlyph.width
dstGlyph.unicodes = srcGlyph.unicodes
dstFont.openInterface()