Native Text and Symbol Support Added to My Illustrator to XAML Plug-In

Native Text and Symbol Support Added to My Illustrator to XAML Plug-In

Rate This
  • Comments 2

Wow! I can hardly believe that this is the third post on my Illustrator to XAML plug-in in the past month. After not touching the code for well over two years, it’s been fun digging back into the project. Adding Mac OS X support has been a brand new challenge for me, and I’ve enjoyed every minute. The response to the test version of the Mac plug-in has been fantastic. It’s clear to me that there are a lot of Illustrator users on the Mac who want to work with Silverlight and WPF! The good news is that the PC and Mac codebases for the plug-in are essentially in-sync, and any improvements that I make in the future should apply to both versions.

One of the more common requests I’ve received is for native text support. As a matter of fact, native text support was one of the first features I started to build way back in 2005. At the time, though, when I dug-in to the Adobe Text Engine (otherwise known as ATE), it seemed like I had teleported into another dimension. The text engine provides a lot of typographic flexibility, and the API is newer than many of the more traditional APIs in Illustrator. I was already in unfamiliar territory building a plug-in, let alone learning about yet another deep and complex API. So, I disabled my early text code, and it’s been dormant ever since. The workaround has always been “convert your text to outlines before you export.” Of course, this method offers very little flexibility when you want to dynamically change text at runtime, and the text outlines significantly bloat the XAML.

The new version of the plug-in exports native point text. However, it does not export text that has been fitted to a path (for an example of this limitation, check out the Yellowstone Map illustration on my updated Eye Candy page). Fortunately, most text in Illustrator is point text, so this shouldn’t present a problem for common cases. Illustrator also supports many advanced text features that are not currently exported, so you may notice differences in the way text is rendered. One of the text features that is not handled is the relative spacing between letters and words, otherwise known as tracking. Here’s an example of some Illustrator text with increased tracking (top) and how the exported XAML is rendered with WPF (bottom):

I added the red lines to show that the anchor point of each TextBlock element is correctly aligned. However, because the tracking value is not accommodated in the XAML, each text run falls out of alignment. By the way, the Illustrator API returns three individual glyph runs for this single word, which is why there are three TextBlock elements. Since all of the other attributes of this text run are identical (color, baseline, font size, font family), a future enhancement to the plug-in should combine all three of these glyph runs into one. For now, the manual solution would be to simply delete all but the first TextBlock.

While I was digging through the code, I also uncommented some early work I had begun on symbols. In Illustrator, a symbol is an art object that can be reused multiple times within a single document. So, after a symbol is created, instances of that symbol can be added to the document many times without having to create multiple copies of complex artwork. A great example of symbol use can be seen in the aforementioned Yellowstone Map on the Eye Candy page. I’ve included a small section of the map to the right showing square black symbols used to mark picnic areas, food, lodging, etc. Ideally, symbols would be exported to a ResourceDictionary and referenced in the exported XAML, though this is not the case in the current version.

The last tweak I made was to improve the behavior of the shift keys in the PC version. The keyboard detection logic I was using seemed unreliable, and often times, the XAML editor would launch even though the left shift key was not being held down. I’ve received a handful of e-mail inquiries about this behavior, and I’m happy to say that I was able to fix it in this version. Why shift keys instead of dialog box choices, you ask? Well, it’s mostly because I didn’t want to spend the time to learn how to use the Adobe Dialog Manager (ADM)…yet another complex API. Plus, I’ve grown to like the simplicity and ease of the shift key approach.

I updated the Adobe Illustrator to XAML Export Plug-In site to bring it a bit more up-to-date. Nothing radical, though I did use Robby Ingebretsen’s fantastic Kaxaml editor to create some new visuals (thanks, Robby!). There’s also installation instructions for both PC and Mac along with download links to the most recent version.

If you’re planning to attend MIX09 and want to chat about the plug-in (or anything, really), send me a tweet when you’re in Vegas, and I’m happy to hook-up. Otherwise, feel free to leave comments, feedback, and suggestions to this post or drop me a line directly.

Most of all, have fun! :-)

Leave a Comment
  • Please add 8 and 4 and type the answer here:
  • Post
Page 1 of 1 (2 items)