Skip to content

Commit

Permalink
multi updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Suzie1 committed Dec 19, 2023
1 parent 2de3c4e commit fb32f30
Show file tree
Hide file tree
Showing 10 changed files with 1,058 additions and 72 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ __🔳 Aspect Ratio__
* CR SDXL Aspect Ratio
* CR SD1.5 Aspect Ratio
* CR Aspect Ratio (new 27/11/2023)
* CR Aspect Ratio Banners (new 18/12/2023)

__📜 List Nodes__
* CR Font File List (new 18/12/2023)
* CR Text List (new 19/12/2023)

__🌟 SDXL__
* CR SDXL Prompt Mix Presets
Expand All @@ -39,6 +44,8 @@ __💊 LoRA__
* CR Load LoRA
* CR LoRA Stack
* CR Apply LoRA Stack
* CR Random LoRA Stack (new 18/12/2023)
* CR Random Weight LoRA (new 18/12/2023)

__🕹️ ControlNet__
* CR Apply ControlNet
Expand Down Expand Up @@ -77,6 +84,8 @@ __👽 Graphics - Template__
* CR Simple Meme Template
* CR Simple Banner
* CR Comic Panel Templates
* CR Simple Banner (new 18/12/2023)
* CR Simple Image Compare (new 18/12/2023)

__🌁 Graphics - Layout__
* CR Image Panel
Expand Down Expand Up @@ -123,7 +132,7 @@ __🔢 Index__
* CR Trigger

__🔧 Conversion__
* CR String To Number
* CR String To Number (changed 18/12/2023)
* CR String To Combo
* CR Float To String
* CR Float To Integer
Expand Down Expand Up @@ -151,6 +160,7 @@ __🎲 Random__
* CR Random RGB Gradient (new 8/12/2023)

__📦 Other__
* CR Image Output (changed 18/12/2023)
* CR Latent Batch Size
* CR Prompt Text
* CR Split String
Expand Down
23 changes: 14 additions & 9 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
"CR Split String":CR_SplitString,
"CR Value": CR_Value,
"CR Conditioning Mixer":CR_ConditioningMixer,
"CR Select Model": CR_SelectModel,
"CR Select Model": CR_SelectModel,
### List Nodes
"CR Font File List": CR_FontFileList,
"CR Text List": CR_TextList,
### Aspect Ratio Nodes
"CR SD1.5 Aspect Ratio":CR_AspectRatioSD15,
"CR SDXL Aspect Ratio":CR_SDXLAspectRatio,
Expand All @@ -60,9 +63,9 @@
### LoRA Nodes
"CR Load LoRA": CR_LoraLoader,
"CR LoRA Stack": CR_LoRAStack,
"CR Apply LoRA Stack": CR_ApplyLoRAStack,
"CR Random LoRA Stack": CR_RandomLoRAStack,
"CR Random Weight LoRA": CR_RandomWeightLoRA,
"CR Random Weight LoRA": CR_RandomWeightLoRA,
"CR Apply LoRA Stack": CR_ApplyLoRAStack,
### Model Merge Nodes
"CR Apply Model Merge": CR_ApplyModelMerge,
"CR Model Merge Stack": CR_ModelMergeStack,
Expand Down Expand Up @@ -109,8 +112,7 @@
#"CR Arabic Text RTL": CR_ArabicTextRTL,
"CR Simple Text Watermark": CR_SimpleTextWatermark,
#"CR System TrueType Font": CR_SystemTrueTypeFont,
#"CR Display Font": CR_DisplayFont,
"CR Font File List": CR_FontFileList,
#"CR Display Font": CR_DisplayFont,
### Graphics Filter
"CR Halftone Filter": CR_HalftoneFilter,
"CR Color Tint": CR_ColorTint,
Expand Down Expand Up @@ -199,7 +201,7 @@
# Lists
"CR Model List": CR_ModelList,
"CR LoRA List": CR_LoRAList,
"CR Text List": CR_TextList,
#"CR Text List": CR_TextList,
"CR Text List Simple": CR_TextListSimple,
"CR Image List": CR_ImageList,
"CR Image List Simple": CR_ImageListSimple,
Expand All @@ -213,7 +215,7 @@
# Utils
"CR Debatch Frames": CR_DebatchFrames,
"CR Current Frame": CR_CurrentFrame,
"CR Input Text List": CR_InputTextList,
#"CR Input Text List": CR_InputTextList,
# IO
"CR Load Animation Frames": CR_LoadAnimationFrames,
"CR Load Flow Frames": CR_LoadFlowFrames,
Expand All @@ -231,6 +233,9 @@
"CR Value": "⚙️ CR Value",
"CR Conditioning Mixer": "⚙️ CR Conditioning Mixer",
"CR Select Model": "🔮 CR Select Model",
### List Nodes
"CR Font File List": "📜 CR Font File List",
"CR Text List": "📜 CR Text List",
### Aspect Ratio Nodes
"CR SD1.5 Aspect Ratio": "🔳 CR SD1.5 Aspect Ratio",
"CR SDXL Aspect Ratio": "🔳 CR SDXL Aspect Ratio",
Expand All @@ -247,7 +252,7 @@
"CR Load LoRA": "💊 CR Load LoRA",
"CR LoRA Stack": "💊 CR LoRA Stack",
"CR Random LoRA Stack": "💊 CR Random LoRA Stack",
"CR Random Weight LoRA": "💊 CR Random Weight LoRA",
"CR Random Weight LoRA": "💊 CR Random Weight LoRA",
"CR Apply LoRA Stack": "💊 CR Apply LoRA Stack",
### Model Merge Nodes
"CR Apply Model Merge": "⛏️ CR Apply Model Merge",
Expand Down Expand Up @@ -383,7 +388,7 @@
# Lists
"CR Model List": "📃 CR Model List",
"CR LoRA List": "📃 CR LoRA List",
"CR Text List": "📃 CR Text List",
#"CR Text List": "📃 CR Text List",
"CR Text List Simple": "📃 CR Text List Simple",
"CR Image List": "📃 CR Image List",
"CR Image List Simple": "📃 CR Image List Simple",
Expand Down
3 changes: 2 additions & 1 deletion animation_nodes/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def lora_list(self, lora_name1, model_strength_1, clip_strength_1, alias1,
return (loras, show_text, )

#---------------------------------------------------------------------------------------------------------------------#
'''
class CR_TextList:
@classmethod
Expand Down Expand Up @@ -221,7 +222,7 @@ def text_list(self, text_1, alias1, text_2, alias2, text_3, alias3, text_4, alia
show_text = "".join(showtext)
return (texts, show_text, )

'''
#---------------------------------------------------------------------------------------------------------------------#
class CR_TextListSimple:

Expand Down
1 change: 1 addition & 0 deletions categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Comfyroll/ControlNet": "🧩 Comfyroll/🕹️ ControlNet",
"Comfyroll/XY Grid": "🧩 Comfyroll/📉 XY Grid",
"Comfyroll/SDXL": "🧩 Comfyroll/🌟 SDXL",
"Comfyroll/List": "🧩 Comfyroll/📜 List",
"Comfyroll/Aspect Ratio": "🧩 Comfyroll/🔳 Aspect Ratio",
"Comfyroll/Pipe/Module": "🧩 Comfyroll/🎷 Pipe/✈️ Module",
"Comfyroll/Pipe/Image": "🧩 Comfyroll/🎷 Pipe/🛩️ Image",
Expand Down
23 changes: 0 additions & 23 deletions fonts/fonts.txt

This file was deleted.

119 changes: 87 additions & 32 deletions nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def INPUT_TYPES(s):
"output_type": (["Preview", "Save"],),
"filename_prefix": ("STRING", {"default": "CR"}),
"prefix_presets": (presets, ),
"file_format": (["webp", "jpg", "png", "tif"],),
"file_format": (["png", "jpg", "webp", "tif"],),
},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
"optional":
Expand Down Expand Up @@ -709,7 +709,9 @@ def select_model(self, ckpt_name1, ckpt_name2, ckpt_name3, ckpt_name4, ckpt_name
show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-select-model"

return (model, clip, vae, model_name, show_help, )


#---------------------------------------------------------------------------------------------------------------------#
# List Nodes
#---------------------------------------------------------------------------------------------------------------------#
class AnyType(str):
"""A special type that can be connected to any other types. Credit to pythongosssss"""
Expand All @@ -724,37 +726,88 @@ class CR_FontFileList:
@classmethod
def INPUT_TYPES(s):

system_root = os.environ.get('SystemRoot')
font_dir = os.path.join(system_root, 'Fonts')

return {"required": {}}
comfyroll_font_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "fonts")
comfyroll_file_list = [f for f in os.listdir(comfyroll_font_dir) if os.path.isfile(os.path.join(comfyroll_font_dir, f)) and f.lower().endswith(".ttf")]

sources = ["System", "Comfyroll"]

return {"required": {"source_folder": (sources,),
#"full_folder_path":
"start_index": ("INT", {"default": 0, "min": 0, "max": 9999}),
"max_rows": ("INT", {"default": 1000, "min": 1, "max": 9999}),
}
}

RETURN_TYPES = (any_type, any_type,)
RETURN_NAMES = ("LIST", "display_names", )
RETURN_TYPES = (any_type, "STRING", )
RETURN_NAMES = ("LIST", "show_help", )
OUTPUT_IS_LIST = (True,)
FUNCTION = "load_path"
CATEGORY = icons.get("Comfyroll/Other")
FUNCTION = "make_list"
CATEGORY = icons.get("Comfyroll/List")

def make_list(self, source_folder, start_index, max_rows):

if source_folder == "System":
system_root = os.environ.get('SystemRoot')
system_font_dir = os.path.join(system_root, 'Fonts')
file_list = [f for f in os.listdir(system_font_dir) if os.path.isfile(os.path.join(system_font_dir, f)) and f.lower().endswith(".ttf")]
#print(len(file_list))
elif source_folder == "Comfyroll":
comfyroll_font_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "fonts")
file_list = [f for f in os.listdir(comfyroll_font_dir) if os.path.isfile(os.path.join(comfyroll_font_dir, f)) and f.lower().endswith(".ttf")]
#print(len(comfyroll_file_list))
else:
pass

# Ensure start_index is within the bounds of the list
start_index = max(0, min(start_index, len(file_list) - 1))

# Calculate the end index based on max_rows
end_index = min(start_index + max_rows, len(file_list))

# Extract the desired portion of the list
selected_files = file_list[start_index:end_index]

show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-font-file-list"

return (selected_files, show_help, )

#---------------------------------------------------------------------------------------------------------------------#
class CR_TextList:

def load_path(self, path: str = "./input/", image_load_limit: int = 0, start_index: int = 0):
@classmethod
def INPUT_TYPES(s):

system_root = os.environ.get('SystemRoot')
font_dir = os.path.join(system_root, 'Fonts')
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")]
print(len(file_list))
return {"required": {"multiline_text": ("STRING", {"multiline": False, "default": "text"}),
"start_index": ("INT", {"default": 0, "min": 0, "max": 9999}),
"max_rows": ("INT", {"default": 1000, "min": 1, "max": 9999}),
}
}

import matplotlib.font_manager
RETURN_TYPES = ("STRING", "STRING", )
RETURN_NAMES = ("STRING", "show_help", )
OUTPUT_IS_LIST = (True,)
FUNCTION = "make_list"
CATEGORY = icons.get("Comfyroll/List")

# Get the list of available font names
font_list = matplotlib.font_manager.findSystemFonts(fontpaths=None, fontext='ttf')
def make_list(self, multiline_text, start_index, max_rows):

# Retrieve the font properties to access the user-friendly name
font_props = matplotlib.font_manager.FontProperties(fname=font_list[0])
font_names = font_props.get_name()

files = "\n".join(file_list)
lines = multiline_text.split('\n')

#return {"ui": {"text": files,}, "result": (file_list,),}
return (file_list, font_names, font_list, )
# Ensure start_index is within the bounds of the list
start_index = max(0, min(start_index, len(lines) - 1))

# Calculate the end index based on max_rows
end_index = min(start_index + max_rows, len(lines))

# Extract the desired portion of the list
selected_rows = lines[start_index:end_index]

# Join the selected portion into a multiline string
text_list = "\n".join(selected_rows)

show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Other-Nodes#cr-text-list"

return (selected_rows, show_help, )

#---------------------------------------------------------------------------------------------------------------------#
# MAPPINGS
Expand All @@ -764,20 +817,22 @@ def load_path(self, path: str = "./input/", image_load_limit: int = 0, start_ind
NODE_CLASS_MAPPINGS = {
### Aspect ratio
"CR SD1.5 Aspect Ratio": CR_AspectRatioSD15,
"CR SDXL Aspect Ratio":CR_SDXLAspectRatio,
"CR SDXL Aspect Ratio": CR_SDXLAspectRatio,
"CR Aspect Ratio": CR_AspectRatio,
"CR Aspect Ratio Banners":CR_AspectRatioBanners,
### List nodes
"CR Font File List": CR_FontFileList,
"CR Text List": CR_TextList,
### Other
"CR Image Output": CR_ImageOutput,
"CR Integer Multiple": CR_IntegerMultipleOf,
"CR Latent Batch Size":CR_LatentBatchSize
"CR Seed":CR_Seed,
"CR Prompt Text":CR_PromptText,
"CR Split String":CR_SplitString,
"CR Latent Batch Size": CR_LatentBatchSize,
"CR Seed": CR_Seed,
"CR Prompt Text": CR_PromptText,
"CR Split String": CR_SplitString,
"CR Value": CR_Value,
"CR Conditioning Mixer":CR_ConditioningMixer,
"CR Conditioning Mixer": CR_ConditioningMixer,
"CR Select Model": CR_SelectModel,
"CR Font File List": CR_FontFileList,
}
'''

15 changes: 9 additions & 6 deletions nodes/pil_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ def overlay_text(self, image, text, align,
draw = ImageDraw.Draw(textlayer)

# Load the font
font_file = "fonts\\" + str(font_name)
#font_file = "fonts\\" + str(font_name)
font_file = os.path.join("fonts", str(font_name))
resolved_font_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), font_file)
font = ImageFont.truetype(str(resolved_font_path), size=font_size)

Expand Down Expand Up @@ -452,6 +453,7 @@ def overlay_text(self, image, text, align,
return (images_out, show_help, )

#---------------------------------------------------------------------------------------------------------------------#
'''
class CR_SystemTrueTypeFont:
def __init__(self):
pass
Expand Down Expand Up @@ -499,8 +501,9 @@ def truetype_font(self, font_name, font_size):
show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Text-Nodes#cr-system-truetype-font"
return (font_out, preview, show_help,)

'''
#---------------------------------------------------------------------------------------------------------------------#
'''
class CR_DisplayFont:
@classmethod
Expand Down Expand Up @@ -535,7 +538,7 @@ def draw_font(self, font, text):
show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Text-Nodes#cr-display-font"
return (image_out, show_help,)
'''
#---------------------------------------------------------------------------------------------------------------------#
# MAPPINGS
#---------------------------------------------------------------------------------------------------------------------#
Expand All @@ -548,9 +551,9 @@ def draw_font(self, font, text):
"CR Composite Text":CR_CompositeText,
"CR Draw Perspective Text":CR_DrawPerspectiveText,
"CR Arabic Text RTL": CR_ArabicTextRTL,
"CR Simple Text Watermark": CR_SimpleTextWatermark,
"CR System TrueType Font": CR_SystemTrueTypeFont,
"CR Display Font": CR_DisplayFont,
#"CR Simple Text Watermark": CR_SimpleTextWatermark,
#"CR System TrueType Font": CR_SystemTrueTypeFont,
#"CR Display Font": CR_DisplayFont,
}
'''

Loading

0 comments on commit fb32f30

Please sign in to comment.