Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
itsmeherefolks opened this issue Jan 23, 2024 · 5 comments

Comments

@itsmeherefolks
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@WeeBull
Copy link

WeeBull commented Feb 11, 2024

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.

@zierf
Copy link

zierf commented Aug 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants