Line Breaks added to Charpath, Kern, and Text_svg
Thanks to a cool hack discovered by Tolifox, I have added the line_break node to my library. Details here:
http://support.nodebox.net/discussions/nodebox-2-3/7216-creating-a-...
I then realized that I would need to modify some of my other text nodes to work with this new capability. I identified three nodes that required modifications to accept line break characters: charpath, kern, and text_svg.
I have updated all three of these nodes. Demo attached!
By using the line_break node, you can now create strings with line breaks. You can even create strings with both line breaks and unicode characters by using the add_unicode node. I made such a string with an ancient Japanese haiku and an extra line that says "I heart Nodebox" with a unicode heart.
If you plug this string into an ordinary textpath node, you can see that it renders just fine.
You can also plug it into the new charpath node. This node will generate a separate path for each character in the multi-line string, which allows you to color the characters independently or perform other mischief.
If you plug the same string into the kern node. you can adjust character and word spacing. The updated kern node now has an additional parameter port, leading. If your text has no line breaks, leading is ignored. But if it does have line breaks, the leading value can be used to adjust the vertical leading between lines. This gives you much more control over your text layout than was possible before.
If you want to use the kern node to control both kerning and leading, but ALSO want to color each character separately, there is a way of combining these two nodes, shown in the demo:
- Feed the same multi-line string to both charpath and kern.
- Charpath produces one path per character; you can color them independently if you want using the colorize node.
- Kern produces one group per line. If you ungroup that list of lines, you will have the same characters as charpath, but positioned according to the parameters you entered into kern.
- Now just use the centroid node to find the kerned character positions, and feed those into an align node to reposition the colored characters.
I have also updated the text_svg node. This should make the lives of our plotting community a little easier. Just feed a multi-line string into text_svg to produce multi-line text that can be sent to a plotter. SVG fonts like hersheyfont are usually pretty minimal and are not likely to include special unicode characters, so you will have to do without those or handle them separately.
I also looked at my style_text node, which allows you to include bold, italic, and colored words in text. It is designed to output individual words which can then be fed into my arrange node to handle multi-line layout. This system works OK as is, so I decided not to try to retrofit it to handle strings with line breaks.
Together, these nodes now allow a variety of different ways to gain new levels of control over text layout in Nodebox. Until they are all published in the next release of my library, please use the versions in this demo. The three updated nodes all include a "v3.6" in their comments so that you can easily distinguish them from previous versions.
-
linebreak_capability_demo.png 573 KB
- charpath_kern_and_text_svg_demo.zip 21.5 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac