Isolating text islands in Inkscape

I wanted to see if there was a clever way to isolate the cutouts from vector text, it can be useful in some situations. It all came from this discussion (scroll down for the relevant bits). Here’s how I did it.

A quick note: this is a fairly advanced set of boolean actions, nothing too complicated if you understand paths in Inkscape, but if you don’t, I’m about to go too fast for you (sorry). Read some more forum stuff and come back sometime.

Aww come on, tell us all the details!

Nope. Think of it like the Harry Potter movies. They got way better once they stopped trying to tell the newcomers about the backstory. At some point, you’re either ready for this or you aren’t. It’s not terribly hard, but it might read like greek if you’re really new to this.

A second note: this is a simple example. This technique is overkill for something like this, but if you have large amounts of text or other complicated nested shapes it will probably be faster than manually selecting each island. (Note added courtesy of rbtdanforth’s astute observation that I didn’t spell this bit out. So consider it spelled.)

In the first image I started with a text object, then converted to paths, ungrouped and combined them. Then set a stroke and removed the fill. The result is that top nice black outline text in a single path. Copy and paste two more copies, and give them different colors, I chose blue and red.


Like so. Three copies will make your life easier later.


You’ll end up here.

To get the blue outlines which represent the outer edges of the letters, it’s easy:

  1. Select the blue letters
  2. Break apart (control-shift K)
  3. Select all the broken apart text paths (in blue)
  4. Path->union (control-shift-plus)


Intermediate steps complete. You’ve just finished the blue part.

It’s that easy. Now you have outlines to your letters.

Next is a bit trickier, bear with me, some of the steps are going to seem dumb.

  1. Select your red text. Ensure that it’s one path, not grouped, not unioned (it should be if you followed all my steps). Use control-k to combine them if you have to.
  2. Copy it. (control-C)
  3. Follow all steps above for making the blue outlines above. You’ll now have red outlines.
  4. Go into your preferences and set your inset steps to something really small. I chose 0.001". If you don’t do an inset, there will be artifacting later because of Inkscape’s precision limits with path booleans.
  5. Go back to your red unioned outlines, and break apart (control-shift-K)
  6. Select all your red bits now, and do inset. This will make your overall red outlines slightly smaller.
  7. Select all your red bits, and combine them (control-k). They are now one path.
  8. Paste in place. (control-alt-v) You’ll now have a fresh set of red letters (from step 2 above) atop your slightly smaller outlines.
  9. Select all the red stuff (both the fresh red text and the slight smaller outlines underneath)
  10. Do path->difference.

That’s it, you’ll have all your islands.


More intermediate steps complete, now you have your red part.

Now you can use the original black text as a way to snap things into alignment, then delete the black text. Now you should have the end result:


Nicely color coded for you to do whatever things you wanted to with the separate parts.

14 Likes

Oh. You are such a tease.

Smh…or you could just break apart and without moving anything change the colors of all the internal bits perhaps even use the combine command to make them one thing. (Since they are not connected they can break apart again.

Now you do the same with all the outer parts of the letters and make the two things a group.

PS Mr Miyagi was paying homage to Mister Musashi and either by reading the book or seeing the movie that particular scene tossing flies out the window with chopsticks was far more impressive than anything in the Karate Kid movies.

2 Likes

While that may be true for my simple example here…

Manually selecting the islands on whole paragraphs of text or other more in depth shapes will not scale well. My way is more precise and faster than trying to pick the interiors out of each letter on a significant chunk of text.

I chose a simple example to make illustrating the concept simpler. I suppose I could have spelled that out… but I did say I wasn’t going to explain it to people who weren’t ready for it (or didn’t need it, as is your case).

If you need something this robust, you’ll know it.

2 Likes

Why go through the “inset” process to make “slightly smaller” islands?

See above:

If you try it and don’t inset you will (probably) get weird vestigial paths near the outer edges. Inkscape sometimes gets slightly confused by the slight changes to the paths from Boolean actions (union, etc), especially where curves are involved.

1 Like

Ah, I thought that the artifacting bit was in relation to setting the inset steps, not to performing the inset itself. I.e. “You need to run an inset, but if you don’t change the setting, you will get weird artifacting”. As opposed to “You need to run an inset. If you don’t you will get weird artifacting. This is the inset setting I use”.

I often run multiple boolean commands on objects all the time. I’ve never really had any issues that I’ve noticed. I hadn’t heard of the inset command though. I typically convert stroke to path and break apart… but inset seems like a more efficient way to achieve the same thing.

1 Like

This is what gets you. Unions and differences and the like will often give you new node positions and are (very close) approximations of the original paths. In some cases it’s enough to cause problems. (Precise inlay or butt joints, for example.)

You’ll also note the step where I broke apart prior to insetting. In my test if I didn’t do that first, weird behavior happened, the entire “e” in “the” disappeared. Breaking the shapes apart helped Inkscape make sense of each shape individually.

I would imagine that this is particular to my example, but I’d also speculate that the chances of weirdness like this go up in direct proportion to the complexity of your paths. I.e.: if you do this on more, longer text, I bet your chances for strangeness go way up.

2 Likes