Nodes/ComfyUI_Anytext/AnyText FontImg
ComfyUI Node

AnyText FontImg

Render text glyphs into an image at masked positions

By zmwv823·Created 2 years ago·Updated about a year ago· 103
AnyText FontImg
  • pos_mask
  • font_img
font_nameNone
sort_radiotrue
font_color_namewhite
font_color_code00ffdd
font_color_codeR-1
font_color_codeG0
font_color_codeB0
font_color_codeA0
font_color_modetrue
bg_color_nametransparent
bg_color_code00ffdd
bg_color_modetrue
seperate_by---
prompt你好呀---Hello!
width
height

This node draws your text - real glyphs, in a real font - into an image, placed where a mask tells it to go. Think of it as the typesetting step: before AnyText diffuses anything, something has to lay the characters out on the canvas, and this is that something. The result is a "font image" you can preview, composite, or feed onward as a glyph hint.

It's the manual, controllable cousin of the glyph rendering the encoder does internally. When you want to see and shape the layout - colors, background, character order - before committing to a sampling pass, this is the node.

How it works

You give it a pos_mask marking where text should sit, a prompt containing the strings (split by a separator), and a font, and it renders the characters into an IMAGE at those positions. The seperate_by string (default ---) is how you delimit multiple text segments in one prompt: 你好呀---Hello! becomes two rendered pieces. sort_radio controls the ordering of how segments map to mask regions. Colors are set either by name, by hex code, or by explicit R/G/B/A - three ways in because different people reach for different ones.

The inputs and outputs that matter

  • pos_mask (MASK) - where the text goes. This is the load-bearing input; the mask's regions become the text boxes.
  • prompt (STRING) - the characters to render, segments split by seperate_by.
  • seperate_by (default ---) - the delimiter between text segments. Change it if your text literally contains ---.
  • font_name - the font to draw with. Shows None on this listing because the crawl box had no fonts installed; on your machine it lists ComfyUI/models/fonts.
  • width / height - the output canvas size.
  • Color controls come in three flavors: font_color_name (a named color), font_color_code (hex), and font_color_codeR/G/B/A (channels). font_color_mode and the bg_color_* set toggle which is used and style the background. Set font_color_codeR to −1 to defer to the name/hex instead of the channel values.

Output is font_img (IMAGE) - the rendered glyph image.

How to install it

ComfyUI Manager, search ComfyUI_Anytext, or:

cd ComfyUI/custom_nodes
git clone https://github.com/zmwv823/ComfyUI_Anytext

then restart. The one requirement here is fonts: drop your .ttf/.otf files (at minimum Arial_Unicode.ttf) into ComfyUI/models/fonts or the font_name dropdown stays empty.

Common issues & troubleshooting

font_name is empty / says only None. No fonts in models/fonts. This node can't render characters without a font file - install at least the base Arial Unicode font.

Segments land in the wrong boxes. That's the seperate_by split not matching your mask regions, or sort_radio ordering them unexpectedly. Count your segments, count your mask regions, and make them line up.

The color isn't what I set. The three color inputs interact. If the R/G/B/A channels are active they win; set font_color_codeR to −1 to fall back to the named color or hex code. Pick one method and don't fight all three at once.

UL_AnyTextFontImg vs UL_AnyText_FontImg. The pack ships both, with identical inputs and outputs - they're two names for the same node across revisions. Whichever one your workflow has is fine; there's no behavioral difference to chase.

CategoryUL Group/Image Generation

Inputs (17)

NameTypeDefaultDescription
font_nameCOMBONone1 options: None
pos_maskMASK
sort_radioBOOLEANtrue
font_color_nameCOMBOwhite149 options: transparent, red, green, blue, white, black, +143
font_color_codeSTRING00ffdd
font_color_codeRINT-1-1–255
font_color_codeGINT00–255
font_color_codeBINT00–255
font_color_codeAINT00–255
font_color_modeBOOLEANtrue
bg_color_nameCOMBOtransparent149 options: transparent, red, green, blue, white, black, +143
bg_color_codeSTRING00ffdd
bg_color_modeBOOLEANtrue
seperate_bySTRING---
promptSTRING你好呀---Hello!
widthINT
heightINT

Outputs (1)

NameTypeDescription
font_imgIMAGE