Created
July 16, 2020 18:27
-
-
Save tsukumijima/27b2e7d4027091e4dbee76922509a65c to your computer and use it in GitHub Desktop.
Tool to extract mojimo fonts from *.mobileconfig profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import glob | |
import plistlib | |
# パス | |
profile_folders = { | |
'mojimo-manga': os.environ['USERPROFILE'].replace('\\', '/') + '/Documents/mojimo-manga_profile', | |
'mojimo-livelite': os.environ['USERPROFILE'].replace('\\', '/') + '/Documents/mojimo-livelite_profile', | |
} | |
extract_folders = { | |
'mojimo-manga': os.environ['USERPROFILE'].replace('\\', '/') + '/Documents/mojimo-manga', | |
'mojimo-livelite': os.environ['USERPROFILE'].replace('\\', '/') + '/Documents/mojimo-livelite', | |
} | |
print('Extracting mojimo...') | |
for profile_type, profile_folder in profile_folders.items(): | |
# 抽出先のフォルダがなければ作成 | |
extract_folder = extract_folders[profile_type] | |
os.makedirs(extract_folder, exist_ok = True) | |
print('Extracting ' + profile_type + '...') | |
# プロファイル一覧 | |
profile_list = glob.glob(profile_folder + '/*.mobileconfig') | |
# プロファイルごとに | |
for profile_path in profile_list: | |
# プロファイルを読み込み | |
with open(profile_path, mode='rb') as fp: | |
# plist をロード | |
profile = plistlib.load(fp) | |
# フォントファイル | |
font = profile['PayloadContent'][0]['Font'] | |
# フォント名を取得 | |
fontname = profile['PayloadContent'][0]['PayloadDisplayName'] | |
fontfile = profile['PayloadContent'][0]['Name'] + '.otf' | |
# フォントを保存 | |
with open(extract_folder + '/' + fontfile, mode = 'wb') as fp: | |
fp.write(font) | |
print('Saved ' + profile_type + ' ' + fontname + ' (' + fontfile + ')') | |
print('Extracted ' + profile_type + '.') | |
print('Extracted.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment