Skip to content

Commit

Permalink
fix font conf format (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
honjow authored May 7, 2024
1 parent fa7911f commit 02361c1
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions py_modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import decky_plugin
from config import logger

FONT_CONFIG = """
<?xml version="1.0"?>
FONT_CONFIG = """<?xml version="1.0"?>
<!-- ToMoon -->
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
Expand Down Expand Up @@ -33,19 +32,32 @@
</alias>
</fontconfig>
"""
FONT_CONF_DIR = f"{decky_plugin.DECKY_USER_HOME}/.config/fontconfig/conf.d"
FONT_CONF_FILE = f"{FONT_CONF_DIR}/75-noto-cjk.conf"
FONT_CONF_DIR = f"{decky_plugin.DECKY_USER_HOME}/.config/fontconfig"
FONT_CONF_D_DIR = f"{FONT_CONF_DIR}/conf.d"
FONT_CONF_FILE = f"{FONT_CONF_D_DIR}/76-noto-cjk.conf"


def write_font_config():
if not os.path.exists(FONT_CONF_DIR):
logger.info(f"Creating fontconfig directory: {FONT_CONF_DIR}")
os.makedirs(FONT_CONF_DIR)
if not os.path.exists(FONT_CONF_D_DIR):
logger.info(f"Creating fontconfig directory: {FONT_CONF_D_DIR}")
os.makedirs(FONT_CONF_D_DIR)

if not os.path.exists(FONT_CONF_FILE):
logger.info(f"Creating fontconfig file: {FONT_CONF_FILE}")
with open(FONT_CONF_FILE, "w") as f:
f.write(FONT_CONFIG)
f.close()
else:
logger.info(f"Fontconfig file already exists: {FONT_CONF_FILE}")
with open(FONT_CONF_FILE, "r") as f:
content = f.read()
f.close()
# if different, overwrite it
if content != FONT_CONFIG:
logger.info(f"Overwriting fontconfig file: {FONT_CONF_FILE}")
with open(FONT_CONF_FILE, "w") as f:
f.write(FONT_CONFIG)
f.close()

user = decky_plugin.DECKY_USER
# change fontconfig owner
Expand Down

0 comments on commit 02361c1

Please sign in to comment.