Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

自定义原始字体 #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
BUCKET_API_KEY = ''
BUCKET_API_SECRET = ''

# 原始字体
BASE_FONT_FILE = 'base-font/KaiGenGothicCN-Regular.ttf'

# 字体名
FAMILY_NAME = 'MyAwesomeFont'
STYLE_NAME = 'Regular'
Expand Down
6 changes: 3 additions & 3 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

# <class 'dict'>: {32: 'cid00001', 33: 'cid00002', 34: 'cid00003'...}
Expand Down Expand Up @@ -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

# <class 'dict'>: {32: 'cid00001', 33: 'cid00002', 34: 'cid00003'...}
Expand Down