Skip to content

Commit

Permalink
Fix crash when launching on Linux
Browse files Browse the repository at this point in the history
"system_profiler" is not something in Linux.
  • Loading branch information
Eisaichen authored Aug 22, 2024
1 parent 652ac99 commit 9de6554
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion utils/get_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_font_data():
for font in fonts:
file.write(font + "\n")

elif system_type in ["Linux", "Darwin"]:
elif system_type in ["Darwin"]:
import subprocess
import re

Expand All @@ -34,6 +34,18 @@ def get_font_data():
with open(path, 'w', encoding='utf-8') as file:
for font in fonts:
file.write(font + "\n")

elif system_type in ["Linux"]:
import subprocess

result = subprocess.run(['fc-list', ':', 'family'], capture_output=True, text=True)
output = result.stdout
fonts = output.split('\n')
path = os.path.join(os.getcwd().replace("utils", ""), 'config', 'font.txt')
with open(path, 'w', encoding='utf-8') as file:
for font in fonts:
if font:
file.write(font + "\n")

else:
print(f"获取字体失败!尚未支持的操作系统: {system_type}")

0 comments on commit 9de6554

Please sign in to comment.