Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3点リーダー対応 #41 #43

Merged
merged 1 commit into from
May 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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