Skip to content

feat: Implement basic text overlay node (CORE-137)#14610

Open
drozbay wants to merge 6 commits into
Comfy-Org:masterfrom
drozbay:20260623a_text_overlay
Open

feat: Implement basic text overlay node (CORE-137)#14610
drozbay wants to merge 6 commits into
Comfy-Org:masterfrom
drozbay:20260623a_text_overlay

Conversation

@drozbay

@drozbay drozbay commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Implements a basic native Text Overlay node:

image

Currently uses standard built-in PIL default font and draws an overlay with an outline on top of the image or video at the desired position. Compatible with newline escape characters (\n).

Example workflow that creates a grid of test images with different settings:

droz_textoverlay_test_C137_1.json

Image example:

textoverlay_grid_test_00017_

Video example:

textoverlay_grid_test_00020_

drozbay added 6 commits June 28, 2026 12:28
Overlay text along the top of an image or image batch (video) without
resizing it. Takes just an image and the text; the font scales with
resolution and wraps to fit, long text fills and overflows rather than
truncating, and a translucent banner with a contrasting outline keeps it
legible on any background.

CORE-137
@drozbay drozbay force-pushed the 20260623a_text_overlay branch from 34ec04d to d8711f0 Compare June 29, 2026 00:46
@drozbay drozbay marked this pull request as ready for review June 29, 2026 00:48
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new file comfy_extras/nodes_text_overlay.py is added, implementing a TextOverlay ComfyUI node that renders text onto image tensors (including batches). It exposes inputs for text content, vertical position, horizontal alignment, font size as a percentage of image height, line spacing, text color, and outline color. Rendering uses PIL on a transparent RGBA layer with adaptive font sizing and optional background band, then alpha-composites the result onto the input tensor. A TextOverlayExtension registers the node, and nodes.py adds the file to the builtin extras load list.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a basic text overlay node.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description matches the new native Text Overlay node and its image/video overlay behavior.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@comfy_extras/nodes_text_overlay.py`:
- Around line 125-126: The text wrapping logic in the overlay renderer is
collapsing user-entered whitespace because `split()` is used in the loop inside
`nodes_text_overlay.py`, which destroys repeated spaces and tabs before drawing.
Update the wrapping path in the text processing function that iterates over
`raw_line` so it preserves literal spacing and tab characters from the original
caption instead of tokenizing on all whitespace; keep the existing `\t` handling
from the earlier text normalization intact while changing the wrapping
implementation to work with the raw line content.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bb2ee910-d7f8-4730-87c9-8287e7f216af

📥 Commits

Reviewing files that changed from the base of the PR and between f197357 and d8711f0.

📒 Files selected for processing (2)
  • comfy_extras/nodes_text_overlay.py
  • nodes.py

Comment on lines +125 to +126
for raw_line in text.split("\n"):
words = raw_line.split()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve literal spacing when wrapping text.

Line 126 uses split(), which collapses repeated spaces and removes tabs. That rewrites the user’s caption before rendering, so indentation, double-spaces, and the escaped \t handling from Line 37 never survive to the image.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@comfy_extras/nodes_text_overlay.py` around lines 125 - 126, The text wrapping
logic in the overlay renderer is collapsing user-entered whitespace because
`split()` is used in the loop inside `nodes_text_overlay.py`, which destroys
repeated spaces and tabs before drawing. Update the wrapping path in the text
processing function that iterates over `raw_line` so it preserves literal
spacing and tab characters from the original caption instead of tokenizing on
all whitespace; keep the existing `\t` handling from the earlier text
normalization intact while changing the wrapping implementation to work with the
raw line content.

@alexisrolland alexisrolland self-assigned this Jun 29, 2026
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

Successfully merging this pull request may close these issues.

2 participants