Create Text On Path(CreateTextOnPath)
This node receives a JSON string containing a list of coordinate points to define the baseline path of the text.
Create Text On Path
The Create Text On Path node creates a mask or batch of masks with the specified text. Locations are center locations.
The Create Text On Path node is used to generate text at specified positions on an image, outputting the image containing the text, a text mask, and its inverted mask. It allows users to define the center locations for each text instance via coordinate points, enabling the creation of text effects that are arranged at arbitrary positions.
Node Functionality
This node receives a JSON string containing a list of coordinate points to define the center locations for each text instance. It uses the Pillow library to render text on a canvas of specified dimensions, supports loading custom fonts from a dropdown list of available fonts, and can process batch coordinate inputs to generate multiple text images and masks. Its core functionality is to convert text color into grayscale values for the mask and generate the corresponding inverted mask.
Node Parameter Description - Create Text On Path
Connection Inputs (Inputs)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
font | COMBO | Yes | - | - | The font file used to render the text, selected from the available fonts. |
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Value Range/Options | Description |
|---|---|---|---|---|---|
alignment | COMBO | Yes | center | "left", "center", "right" | Determines the horizontal alignment of the text relative to the given coordinate point. |
coordinates | STRING | Yes | - | - | A list of coordinate points defining the center locations for each text instance. Must be a correctly formatted JSON string, e.g., "[[x1, y1], [x2, y2]]". |
text | STRING | Yes | text | - | The text content to be rendered onto the image, supports multi-line input. |
frame_width | INT | Yes | 512 | 16 - 4096 (Step: 1) | The width of the output image, ranging from 16 to 4096 with a step of 1. |
frame_height | INT | Yes | 512 | 16 - 4096 (Step: 1) | The height of the output image, ranging from 16 to 4096 with a step of 1. |
font_size | INT | Yes | 42 | - | The font size for rendering the text, in pixels. |
text_color | STRING | Yes | white | - | The color of the text, supports color names (e.g., "white") or hexadecimal codes (e.g., "#FFFFFF"). |
size_multiplier | FLOAT | No | [1] | - | Optional multiplier for the text size; when provided, the length of its list should match the coordinate batch size or be broadcastable. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| image | IMAGE | The RGB image with the text. |
| mask | MASK | A grayscale mask of the text area, where white represents the text. |
| mask_inverted | MASK | The inverted mask of the text area, where black represents the text. |
Usage Scenarios
When creating dynamic text titles or watermarks, the mask generated by this node can be connected to nodes like VAE Encode or Set Latent Noise Mask to control the area for image generation or editing. For example, you can use this node to generate a mask for text placed at specific positions, then use this mask to guide the AI to draw an image within that shape.
Notes
The input coordinates parameter must be a correctly formatted JSON string, e.g., "[[100, 200], [150, 180], [200, 200]]". size_multiplier is an optional parameter; when provided, the length of its list should match the coordinate batch size or be broadcastable.
Create Text On Path Node Source Code Link
The Create Text On Path node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.