ComfyUI Node

Google Font Text Image

Turn any Google Font into a ComfyUI image with a real alpha mask

By ru4ls·Created 11 months ago·Updated 10 months ago· 1
Google Font Text Image
    • IMAGE
    • MASK
    font_family
    font_size48
    font_weight400
    font_style
    output_mode
    textSample Text
    text_align
    line_height1.2
    text_transform
    text_color#000000
    dimension_modeAuto
    width512
    height512
    padding_top20
    padding_right20
    padding_bottom20
    padding_left20
    background_color#FFFFFF
    transparent_backgroundtrue

    Most of ComfyUI treats text as a string that goes into a CLIP or LLM encoder. This node does the opposite: it turns text into pixels. Give it a font and some words, and it renders them to an actual image tensor with a proper alpha mask, ready to composite over anything.

    That sounds niche until you hit the workflows that need it. Watermarks on generated images. Titles and subtitles layered over video or stills. Typography experiments where you want a text image you can run through img2img or ControlNet. And the use case the author clearly cares about: generating font specimens - a sheet of every letter, digit and symbol in a typeface - to feed a multimodal model that's learning to recognize typography. There's even a "Standard Character Set" output mode built for exactly that.

    How it works

    Under the hood this is a headless browser, not a PIL renderer. On startup the node calls Google's webfonts API and loads the entire 1,500+ font catalog into the dropdown, cached for the session. When you queue, it builds an HTML page that loads your chosen family from fonts.googleapis.com via CSS, opens it in Playwright's Chromium, waits a second for the font to arrive, measures the text, and screenshots the page. That's the mechanism behind everything you'll notice: text wrapping, line-height, uppercase/lowercase transforms - they're all just CSS, so they behave like real typography instead of a crude raster.

    The variant handling is smarter than most text nodes too. Each font only ships certain weights and styles, so the node checks whether your requested font_weight / font_style combo actually exists and falls back to the closest available variant with a console warning rather than silently faking a bold.

    The inputs that matter

    You'll actually touch a handful:

    • font_family - dropdown of the full Google Fonts catalog, loaded at startup. If that fetch fails, it collapses to just "Arial".
    • text - your content, multiline; \n becomes a line break. Ignored in "Standard Character Set" mode, which renders A–Z, a–z, 0–9 and symbols instead - the specimen mode.
    • dimension_mode - Auto measures the rendered text and sizes the image to fit (plus padding); Define Manually uses width/height and wraps text to fit. Auto is the one to start with.
    • transparent_background - on by default, and keep it on: it makes the background genuinely transparent and puts the text shape in the MASK output.
    • text_color, background_color - plain hex strings, which is why wiring an external color-picker node into text_color works so cleanly.

    The two outputs are the point: IMAGE (RGB tensor) and MASK (the alpha channel, a 1×H×W float tensor). Composite them over a base image and you get crisp edges instead of a white box - the alpha is real from the start, no background removal in sight. One caveat: the MASK is only meaningful with transparent_background on; with it off the alpha channel is fully opaque and the mask is just a white rectangle.

    Installing it

    Easiest path is ComfyUI Manager - search "Google Font" - or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ru4ls/ComfyUI_Google-Fonts
    cd ComfyUI_Google-Fonts
    pip install -r requirements.txt
    playwright install   # run inside your ComfyUI venv
    

    Then restart ComfyUI and the node appears under Add Node → Ru4ls/Google Fonts. Two things to know going in: playwright install is mandatory - without the Chromium binary the node errors out immediately - and the README's own clone command is missing the final "s" (ComfyUI_Google-Font, a repo that doesn't exist). Use the URL above. A Google Fonts API key is optional; drop one in the .env file (the pack copies .env.example to .env for you on first load) to dodge rate-limit weirdness with the font list.

    Where people get burned

    The classic failure mode is text getting cut off, which is the bug the Playwright migration was built to kill. If it still bites, switch to Auto dimension mode first, then shrink font_size or raise the per-side paddings. The quieter gotchas: rendering needs internet at queue time, because the actual font files download from Google on every render - an offline ComfyUI silently falls back to a generic sans-serif. And this is a slow node. Each render boots a browser and waits a full second for fonts, so batch jobs of hundreds of titles take a while. It's a compositing tool, not a text factory. For that price you get real typography and a real mask, which is more than the lightweight text-image nodes offer.

    CategoryRu4ls/Google Fonts

    Inputs (19)

    NameTypeDefaultDescription
    font_familyCOMBO1 options: Arial
    font_sizeINT481–1024
    font_weightCOMBO4009 options: 100, 200, 300, 400, 500, 600, +3
    font_styleCOMBO2 options: normal, italic
    output_modeCOMBO2 options: Custom Text, Standard Character Set
    textSTRINGSample Text
    text_alignCOMBO3 options: center, left, right
    line_heightFLOAT1.20.1–5
    text_transformCOMBO4 options: none, uppercase, lowercase, capitalize
    text_colorSTRING#000000
    dimension_modeCOMBOAuto2 options: Auto, Define Manually
    widthINT51264–8192
    heightINT51264–8192
    padding_topINT200–200
    padding_rightINT200–200
    padding_bottomINT200–200
    padding_leftINT200–200
    background_colorSTRING#FFFFFF
    transparent_backgroundBOOLEANtrue

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK