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

fix crash discovering fonts on Linux #123

Open blepping opened 5 months ago

blepping commented 5 months ago

currently the extension crashes on every startup and every time the browser refreshes the session on Linux due to the font directories it looks for not existing and it doesn't handle exceptions.

this pull reduces code duplication by moving font discovery into functions and it also adds error handling when discovering fonts. i set it up to search common font directories on Linux.

the diff is fairly large because my editor cleaned up a bunch of trailing whitespace. if you really want to keep it for whatever reason i can amend this pull to only affect the font discovery part.

i'm not sure why some nodes only used the builtin fonts and one of them used system fonts instead, i assume it's for a reason so i provided separate functions. if you wanted to just use all available fonts a simple function like:

def get_all_fonts():
  return get_builtin_fonts() + get_system_fonts()

would work.