This is a node for use with InvokeAI and with the (advanced) text-font-image node for controlling where to put text.
This node takes as its input:
- The path to a TTF font file.
- A font size.
- A line of text.
It outputs the width and height of the bounding box of that text, when rendered in the given font at the given size (rounded to integers).
This is mostly useful in things like centering text in an image. A sample workflow (center-text.json) is included that will output an image with the text centered at any given height.
NOTE: The getbbox()
method from PIL apparently does not correctly deal with newlines, so attempting to make a multiline message using \\n
characters will not work. The text will simply be considered a longer single line.