diff options
Diffstat (limited to 'scripts/stamp-flow-version.py')
| -rw-r--r-- | scripts/stamp-flow-version.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/scripts/stamp-flow-version.py b/scripts/stamp-flow-version.py index 4a1247e..e1d3f68 100644 --- a/scripts/stamp-flow-version.py +++ b/scripts/stamp-flow-version.py @@ -22,8 +22,14 @@ SVGS = [ IMAGES / "ijime-judai-flow-private.svg", ] -# 「最終更新:」の行(右上・x=1796 y=56)を丸ごと置き換える +# 「最終更新:」の行(右上・x=1796 y=56)を丸ごと置き換える。 +# text-anchor="end" を忘れると、右端からはみ出して見えなくなるので注意 LINE_RE = re.compile(r'<text x="1796" y="56"[^>]*>.*?</text>') +LINE_TAG = ( + '<text x="1796" y="56" text-anchor="end" ' + "font-family=\"'Noto Sans JP','Yu Gothic','Hiragino Kaku Gothic ProN',Meiryo,sans-serif\" " + 'font-size="13" font-weight="700" fill="#37474F">' +) REIWA_START = 2019 # 令和元年 @@ -54,12 +60,7 @@ def main(): label = f"最終更新:{reiwa(last_change_date())}" for svg in SVGS: text = svg.read_text(encoding="utf-8") - new, n = LINE_RE.subn( - f'<text x="1796" y="56" font-family="\'Noto Sans JP\',\'Yu Gothic\',' - f"'Hiragino Kaku Gothic ProN',Meiryo,sans-serif\" font-size=\"13\" " - f'font-weight="700" fill="#37474F">{label}</text>', - text, - ) + new, n = LINE_RE.subn(LINE_TAG + label + "</text>", text) if n != 1: raise SystemExit(f"{svg}: 「最終更新」の行が {n} 箇所(1箇所のはず)") if new != text: |
