From 4de9cb0e318c23293c14e6096760f5cba95f0228 Mon Sep 17 00:00:00 2001 From: shy2052 Date: Thu, 22 Oct 2020 16:06:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 3 +++ src/core.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index aa2a74d..1ed5ee6 100644 --- a/config.py +++ b/config.py @@ -11,6 +11,9 @@ BUCKET_API_KEY = '' BUCKET_API_SECRET = '' +# 原始字体 +BASE_FONT_FILE = 'base-font/KaiGenGothicCN-Regular.ttf' + # 字体名 FAMILY_NAME = 'MyAwesomeFont' STYLE_NAME = 'Regular' diff --git a/src/core.py b/src/core.py index 499208d..e0af280 100644 --- a/src/core.py +++ b/src/core.py @@ -5,7 +5,7 @@ from fontTools.pens.ttGlyphPen import TTGlyphPen from fontTools.ttLib import TTFont -from config import NAME_STRING +from config import NAME_STRING, BASE_FONT_FILE from src.utils import str_has_whitespace, str_has_emoji, deduplicate_str, ensure_cmap_has_all_text, subset_ttf_font, \ get_project_root @@ -36,7 +36,7 @@ def obfuscate(plain_text, shadow_text, filename: str, only_ttf: bool, target_pat if len(plain_text) != len(shadow_text): raise Exception('阴书的有效长度需与明文一致') - original_font = TTFont(root / 'base-font/KaiGenGothicCN-Regular.ttf') + original_font = TTFont(root / BASE_FONT_FILE) # https://github.com/fonttools/fonttools/blob/4.0.1/Lib/fontTools/fontBuilder.py#L28 # : {32: 'cid00001', 33: 'cid00002', 34: 'cid00003'...} @@ -144,7 +144,7 @@ def obfuscate_plus(plain_text, filename: str, only_ttf: bool, target_path: str = plain_text = deduplicate_str(plain_text) - original_font = TTFont(root / 'base-font/KaiGenGothicCN-Regular.ttf') + original_font = TTFont(root / BASE_FONT_FILE) # https://github.com/fonttools/fonttools/blob/4.0.1/Lib/fontTools/fontBuilder.py#L28 # : {32: 'cid00001', 33: 'cid00002', 34: 'cid00003'...}