Skip to content

Commit

Permalink
Merge pull request #43 from miiton/iss41
Browse files Browse the repository at this point in the history
3点リーダー対応 #41
  • Loading branch information
miiton authored May 27, 2019
2 parents 7bab364 + 6992b23 commit c71fd73
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion cica.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def log(str):
logger.debug(str)

def remove_glyph_from_hack(_font):
u"""Rounded Mgen+を採用したいグリフをHackから削除
"""Rounded Mgen+を採用したいグリフをHackから削除
"""
log('remove_ambiguous() : %s' % _font.fontname)

Expand Down Expand Up @@ -267,6 +267,7 @@ def add_dejavu(_f, conf):
_f.selection.select(g.encoding)
_f.paste()
# 0x2190 - 0x21ff Arrows
# TODO: 矢印を全角のままにしたパターンも生成したい
for g in dejavu.glyphs():
if g.encoding < 0x2190 or g.encoding > 0x21ff:
continue
Expand Down Expand Up @@ -626,6 +627,7 @@ def build_font(_f, emoji):
cica = emdash_to_broken_dash(cica)
cica = reiwa(cica, _f.get('weight_name'))
cica = add_gopher(cica)
cica = modify_ellipsis(cica)
if emoji:
cica = add_notoemoji(cica)
cica = add_smalltriangle(cica)
Expand Down Expand Up @@ -863,6 +865,53 @@ def scripts_from(encoding, scripts):
return s["src"]
raise ValueError

def modify_ellipsis(_f):
"""3点リーダーを半角にする
DejaVuSansMono の U+22EF(⋯) をU+2026(…)、U+22EE(⋮)、U+22F0(⋰)、U+22F1(⋱)
にコピーした上で回転させて生成
三点リーダの文字幅について · Issue #41 · miiton/Cica https://github.com/miiton/Cica/issues/41
"""
_f.selection.select(0x22ef)
_f.copy()
_f.selection.select(0x2026)
_f.paste()
_f.selection.select(0x22ee)
_f.paste()
_f.selection.select(0x22f0)
_f.paste()
_f.selection.select(0x22f1)
_f.paste()
for g in _f.glyphs("encoding"):
if g.encoding < 0x22ee:
continue
elif g.encoding > 0x22f1:
break
elif g.encoding == 0x22ee:
bb = g.boundingBox()
cx = (bb[2] + bb[0]) / 2
cy = (bb[3] + bb[1]) / 2
trcen = psMat.translate(-cx, -cy)
rotcen = psMat.compose(trcen, psMat.compose(psMat.rotate(math.radians(90)), psMat.inverse(trcen)))
g.transform(rotcen)
elif g.encoding == 0x22f0:
bb = g.boundingBox()
cx = (bb[2] + bb[0]) / 2
cy = (bb[3] + bb[1]) / 2
trcen = psMat.translate(-cx, -cy)
rotcen = psMat.compose(trcen, psMat.compose(psMat.rotate(math.radians(45)), psMat.inverse(trcen)))
g.transform(rotcen)
elif g.encoding == 0x22f1:
bb = g.boundingBox()
cx = (bb[2] + bb[0]) / 2
cy = (bb[3] + bb[1]) / 2
trcen = psMat.translate(-cx, -cy)
rotcen = psMat.compose(trcen, psMat.compose(psMat.rotate(math.radians(-45)), psMat.inverse(trcen)))
g.transform(rotcen)
return _f



def main():
print('')
print('### Generating Cica started. ###')
Expand Down

0 comments on commit c71fd73

Please sign in to comment.