Text Margins
Keep your text layout config out of the Draw Text node
- MARGINS
If you've ever tried to lay out text on a ComfyUI-generated image, you know the pain: every font, position, and spacing setting is buried in one enormous text-rendering node, and changing one margin means opening the beast and hunting for the field. This pack's answer is to break those settings out into small helper nodes, and Text Margins is the first of them - a tiny node whose only job is to bundle four numbers into a MARGINS object you can hand to the pack's Draw Text node. Same pack, same "DreamBait/Text" category, deliberately coupled.
Think of it as a config object: you build a margins "profile" once, save it in your workflow, and wire the same MARGINS output into as many Draw Text nodes as you like. Change the profile, and every text node using it shifts together. That's the whole idea, and it's a good one - it's the difference between editing four fields in one node vs. hunting through five text nodes one at a time.
How it works
Boring by design: it takes left, right, top, bottom integers and packages them into a dict - {"left": 24, "right": 24, "top": 24, "bottom": 24} - which travels out as the custom MARGINS type. The Draw Text node consumes it via its optional margins input and applies it when laying out and wrapping text: the margins shrink the effective text area, so text wraps and aligns within width - left - right rather than edge to edge.
The defaults are all 24 pixels, and each value ranges from -4096 to 4096. The negatives are the feature hiding in plain sight: the tooltip notes that negative values "move text outside bounds," which is exactly how you'd intentionally push a label off the canvas edge - or use margins to do quick positioning without touching x/y percent.
The inputs that matter
- left / right - horizontal margins in pixels.
- top / bottom - vertical margins in pixels.
All four default to 24, all accept negatives, and the only output is MARGINS.
Installing
Text Margins ships in the drmbt/comfyui-dreambait-nodes pack. Install via ComfyUI Manager (search comfyui-dreambait-nodes) or:
cd ComfyUI/custom_nodes
git clone https://github.com/drmbt/comfyui-dreambait-nodes
# restart ComfyUI
Pure Python, no dependencies - this is a struct-packaging node, not a rendering node. The actual rendering happens in Draw Text.
Where it fits
Use it when you're building a card, poster, or title template with several text blocks: one Text Margins node per layout zone, each wired into the relevant Draw Text nodes, and you can retune the whole layout from a handful of small boxes instead of deep-editing the big node. It pairs with the pack's other config helpers - Text Shadow and the text-box style node - which follow the same "configure once, reuse everywhere" pattern.
The honest limitation: the MARGINS type is only understood by this pack's Draw Text node. It won't wire into other text-rendering packs, so if you're not using this pack's renderer, this node is decoration. And remember it's pixels - if you're thinking in percentages, that's Draw Text's x/y percent fields, not this node. Small, single-purpose, and it quietly makes text layout workflows much less annoying.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| left | INT | 24-4096–4096 | Left margin in pixels (negative values move text outside bounds) |
| right | INT | 24-4096–4096 | Right margin in pixels (negative values move text outside bounds) |
| top | INT | 24-4096–4096 | Top margin in pixels (negative values move text outside bounds) |
| bottom | INT | 24-4096–4096 | Bottom margin in pixels (negative values move text outside bounds) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MARGINS | MARGINS | — |