ComfyUI_Comfyroll_CustomNodes icon indicating copy to clipboard operation
ComfyUI_Comfyroll_CustomNodes copied to clipboard

Incorrect Font Directory Path for Manjaro Linux in CR_SelectFont Class

Open itsmeherefolks opened this issue 1 year ago • 5 comments

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!

itsmeherefolks avatar Jan 23 '24 07:01 itsmeherefolks

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

voyageur avatar Jan 25 '24 15:01 voyageur

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 avatar Jan 31 '24 16:01 wutipong

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

wutipong avatar Jan 31 '24 17:01 wutipong

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.

WeeBull avatar Feb 11 '24 12:02 WeeBull

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

I like wutipong's suggestion because the path /usr/share/fonts is not available on all systems and a hard-coded path may cause problems on some systems. The merge request will not work everywhere.

An example would be NixOS, see also my comment to issue #186.

zierf avatar Aug 21 '24 23:08 zierf