Upgrade to Pro — share decks privately, control downloads, hide ads and more …

吉田を支える技術

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for cockscomb cockscomb
November 26, 2021

 吉田を支える技術

Avatar for cockscomb

cockscomb

November 26, 2021
Tweet

More Decks by cockscomb

Other Decks in Programming

Transcript

  1. def build_yoshida(base_font: ttLib.TTFont): masu = ord('૿') yoshi = ord('٢') cmap

    = base_font.getBestCmap() yoshi_cid = cmap[yoshi] head = base_font.get('head') fb = FontBuilder(head.unitsPerEm, isTTF=False) fb.setupGlyphOrder([".notdef", yoshi_cid]) fb.setupCharacterMap({masu: yoshi_cid})
  2. yoshi_glyph = base_font.getGlyphSet().get(yoshi_cid) yoshi_pen = T2CharStringPen(yoshi_glyph.width, None) yoshi_glyph.draw(yoshi_pen) char_strings =

    { ".notdef": ... , yoshi_cid: yoshi_pen.getCharString(), } fb.setupCFF( "Yoshida-Sans", {"FullName": "Yoshida-Sans"}, char_strings, {} )
  3. fb.addOpenTypeFeatures(f''' languagesystem DFLT dflt; feature liga {{ substitute {masu_cid} {da_cid}

    by {masuda_cid}; }} liga; ''') pen = T2CharStringPen(yoshi_glyph.width + da_glyph.width, None) yoshi_glyph.draw(pen) da_glyph.draw( TransformPen(pen, transform.Offset(yoshi_glyph.width)) )