Suzie1 / ComfyUI_Comfyroll_CustomNodes

Custom nodes for SDXL and SD1.5 including Multi-ControlNet, LoRA, Aspect Ratio, Process Switches, and many more nodes.
https://civitai.com/models/183551/comfyui-comfyroll-custom-nodes
525 stars 68 forks source link

Incorrect Font Directory Path for Manjaro Linux in CR_SelectFont Class #111

Open itsmeherefolks opened 6 months ago

itsmeherefolks commented 6 months ago

Description

There appears to be an issue with the CR_SelectFont class in the ComfyUI Comfyroll CustomNodes. The class incorrectly specifies the font directory path for Manjaro Linux systems. This causes a FileNotFoundError since the script is unable to locate the correct font directory.

Issue Details

In the CR_SelectFont class, the font directory for Linux systems is set as "/usr/share/fonts/truetype". However, the standard path for system fonts in Manjaro Linux (an Arch-based distribution) is "/usr/share/fonts/TTF". This discrepancy leads to the script not finding the font files, thereby causing this error.

FETCH DATA from: /home/tom/AI/ComfyUI/custom_nodes/ComfyUI-Manager/extension-node-map.json
[ERROR] An error occurred while retrieving information for the 'CR Select Font' node.
Traceback (most recent call last):
  File "/home/tom/AI/ComfyUI/server.py", line 420, in get_object_info
    out[x] = node_info(x)
             ^^^^^^^^^^^^
  File "/home/tom/AI/ComfyUI/server.py", line 398, in node_info
    info['input'] = obj_class.INPUT_TYPES()
                    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tom/AI/ComfyUI/custom_nodes/ComfyUI_Comfyroll_CustomNodes/nodes/nodes_graphics_text.py", line 468, in INPUT_TYPES
    file_list = [f for f in os.listdir(font_dir) if os.path.isfile(os.path.join(font_dir, f)) and f.lower().endswith(".ttf")]
                            ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/fonts/truetype'

Hot Fix For Manjaro

To resolve this issue, I updated the font directory path for Linux systems in the CR_SelectFont class. The updated code snippet is:

elif platform.system() == "Linux":
    font_dir = "/usr/share/fonts/TTF"  # Updated path for Manjaro Linux

Additional Information

Operating System: Manjaro Linux
KDE Plasma Version: 5.27.10
KDE Frameworks Version: 5.113.0
Qt Version: 5.15.12
Kernel Version: 6.6.10-1-MANJARO (64-bit)
Graphics Platform: X11
Python Version: 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
ComfyUI Version: 1926 [f2d432f9] | Released on '2024-01-22'

A solution for this problem would ensure better compatibility with Manjaro Linux systems and potentially other Arch-based distributions.

Looking forward to the update, and thank you for your work on this project!

voyageur commented 6 months ago

A middle-ground solution would be to have this configurable - on Gentoo I do not have truetype or TFF in /usr/share/fonts, and packages have their own directories (dejavu, liberation-fonts, noto, …). Or go with the proper Linux font system and use fontconfig, but this is more complex fix

wutipong commented 5 months ago

Just noticed the same issue recently.

Personally I think, rather than populating system fonts, may be adding a separate path in the ComfyUI installation instead might be better.

wutipong commented 5 months ago

or maybe using command like fc-list to list font files in the system instead of read the font directory manually.

WeeBull commented 5 months ago

I've proposed a fix in #124 which just reads any directory under /usr/share/fonts. Maybe that's going to gather too many fonts, but at least it should be more robust.