The more I look at the OSX APIs …. the more I love them.
I am exploring the various possibilities of having text layers in ChocoFlop. I looked at the way an app like CoreImage Fun House does it but it’s rather limited. You can draw a string with the font you want, which is fine, but what do you do if you want a real text tool? By a real text tool I mean something like Photoshop has: the ability to create multiline, autowrapping text, with spell checking. I want to be able to pick one character and change it’s size, color, font and other atributes individually not to mention alignement and such things.
Well we have NSTextView. A NSTextView basically has all the editing features you can see in TextEdit. In case you’re not a Mac OSX user and think of TextEdit as of the old SimpleText on OS9 or Notepad on windows, believe me it’s not the same. TextEdit is basically a very lightweight word processor (it only misses headers/footers). One of the cool features is that TextEdit can load and save RTF documents, much like WordPad does on Windows. Well, an amazing feature of Cocoa is that NSTextView can also save it’s context as RTF data. It means that you can just add a NSTextView to your app and have rich text editing features out of the box.
Also, as you may (or not) already know any view in OSX can be captured as a PDF document, which in turn can easily saved as PDF document or translated into pixels.
What does this all mean in our particular app ? It means that every text layer in ChocoFlop will be a separate RTF document with all the attributes you want. This means really that inside the .chocoimg bundle (the native folder-based file format of ChocoFlop), you will have a .rtf file for each text layer that you can simply replace/modify with any RTF compatible editor.
That’s great because I always wanted the .chocoimg format to remain as simple as possible and I was wondering whether adding support for complex text would make it harder to understand. Going this way will ensure that a .chocoimg bundle will have only three type of elements in the folder:
- a TIFF file for every layer/mask (already the case)
- an XML file with the parameters for filters and layer ordering and modes
and soon:
- a RTF file for every text layer, as can be seen in this preliminary screenshot. The text is aligned on right, has different fonts and colors.

(click for a bigger image)
As usual some work is needed to integrate this in a nice way (the text in the screenshot is loaded from an RTF file) but be prepared to see this in the next release.
May the FSM bless the guys behind these APIs.