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 reference_transform(ref, glyph, deg): thatglyphname = ref[0] thisglyphname = glyph.glyphname r = ref[1] column_a = "%s's reference to %s:" % (thisglyphname, thatglyphname) column_b = str(r) ri = psMat.inverse(r) result = psMat.identity() result = psMat.compose(result, italic_shift_right(deg)) result = psMat.compose(result, italic_unskew(deg)) result = psMat.compose(result, r) result = psMat.compose(result, italic_skew(deg)) result = psMat.compose(result, italic_shift_left(deg)) return (ref[0], result)
def referenceTransform(ref, glyph, deg): thatglyphname = ref[0] thisglyphname = glyph.glyphname r = ref[1] columnA = "%s's reference to %s:" % (thisglyphname, thatglyphname) columnB = str(r) ri = psMat.inverse(r) result = psMat.identity() result = psMat.compose(result, italicShiftRight(deg)) result = psMat.compose(result, italicUnskew(deg)) result = psMat.compose(result, r) result = psMat.compose(result, italicSkew(deg)) result = psMat.compose(result, italicShiftLeft(deg)) return (ref[0], result)
def italic_untransform(deg): return psMat.inverse(italic_transform(deg))
def italic_shift_right(deg): return psMat.inverse(italic_shift_left(deg))
def italic_unskew(deg): return psMat.inverse(italic_skew(deg))
def italicUntransform(deg): return psMat.inverse(italicTransform(deg))
def italicShiftRight(deg): return psMat.inverse(italicShiftLeft(deg))
def italicUnskew(deg): return psMat.inverse(italicSkew(deg))