diff --git a/src-python/controller.py b/src-python/controller.py index f40a25ae..d5322134 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1136,7 +1136,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1178,7 +1177,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1203,7 +1201,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1228,7 +1225,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1319,7 +1315,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1360,7 +1355,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1385,7 +1379,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ @@ -1411,7 +1404,6 @@ class Controller: else: raise ValueError() except Exception: - errorLogging() response = { "status":400, "result":{ diff --git a/src-python/models/overlay/overlay_image.py b/src-python/models/overlay/overlay_image.py index fec4c741..708ad11c 100644 --- a/src-python/models/overlay/overlay_image.py +++ b/src-python/models/overlay/overlay_image.py @@ -67,9 +67,16 @@ class OverlayImage: font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) - font = ImageFont.truetype(font_path, font_size) + # overlayフォルダから操作している場合 + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", font_family)): + # src-pythonフォルダから操作している場合 + font_path = os_path.join(os_path.dirname(__file__), "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {font_family}") text_width = draw.textlength(text, font) character_width = text_width // len(text) @@ -171,9 +178,14 @@ class OverlayImage: font_path = os_path.join(self.root_path, font_family) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) - font = ImageFont.truetype(font_path, font_size) + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", font_family)): + font_path = os_path.join(os_path.dirname(__file__), "fonts", font_family) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {font_family}") # 改行を含んだtextの最大の文字数を計算する text_width = max(draw.textlength(line, font) for line in text.split("\n")) @@ -207,9 +219,16 @@ class OverlayImage: font_path = os_path.join(self.root_path, self.LANGUAGES["Default"]) font = ImageFont.truetype(font_path, font_size) except Exception: - errorLogging() - font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"]) - font = ImageFont.truetype(font_path, font_size) + # overlayフォルダから操作している場合 + if os_path.exists(os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"])): + font_path = os_path.join(os_path.dirname(__file__), "..", "..", "..", "fonts", self.LANGUAGES["Default"]) + font = ImageFont.truetype(font_path, font_size) + elif os_path.exists(os_path.join(os_path.dirname(__file__), "fonts", self.LANGUAGES["Default"])): + # src-pythonフォルダから操作している場合 + font_path = os_path.join(os_path.dirname(__file__), "fonts", self.LANGUAGES["Default"]) + font = ImageFont.truetype(font_path, font_size) + else: + raise FileNotFoundError(f"Font file not found: {self.LANGUAGES['Default']}") text_height = font_size + ui_padding text_width = draw.textlength(date_time, font)