Skip to content

Narrow CN character width #249

Closed
Closed
@subframe7536

Description

@subframe7536

Currently only supported in VSCode, have no effect in terminal and IDEA

maple-font/build.py

Lines 534 to 550 in ff02c20

def change_char_width(font: TTFont, match_width: int, target_width: int):
font["hhea"].advanceWidthMax = target_width
for name in font.getGlyphOrder():
glyph = font["glyf"][name]
width, lsb = font["hmtx"][name]
if width != match_width:
continue
if glyph.numberOfContours == 0:
font["hmtx"][name] = (target_width, lsb)
continue
delta = round((target_width - width) / 2)
glyph.coordinates.translate((delta, 0))
glyph.xMin, glyph.yMin, glyph.xMax, glyph.yMax = (
glyph.coordinates.calcIntBounds()
)
font["hmtx"][name] = (target_width, lsb + delta)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FAQCommon Question

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions