Evan Booth
posted this on October 07, 2011 02:46 pm
Hey,
I created quick-and-dirty utility for converting characters to render on Sifteo cubes. At this point, you have to do it one character at a time, and you have options for font (any font on your system), size, resolution, and a "threshold" control for fine tuning. Here's what the interface looks like: http://www.evanbooth.com/skitch/SifteoFontConverter-20111007-174340...
Pressing the "Generate Code" button will copy a block of code to your clipboard that will look something like this:
–––––––––––––––––––––––––––––––––––––
Color chr_clr = new Color(0, 0, 0); // the color of the text
int cX = 0; // y offset
int cY = 0; // y offest
cube.FillRect(chr_clr, cX+0, cY+30, 6, 6);
cube.FillRect(chr_clr, cX+6, cY+12, 6, 6);
cube.FillRect(chr_clr, cX+6, cY+18, 6, 6);
cube.FillRect(chr_clr, cX+6, cY+24, 6, 6);
cube.FillRect(chr_clr, cX+12, cY+0, 6, 6);
cube.FillRect(chr_clr, cX+12, cY+24, 6, 6);
cube.FillRect(chr_clr, cX+18, cY+12, 6, 6);
cube.FillRect(chr_clr, cX+18, cY+18, 6, 6);
cube.FillRect(chr_clr, cX+18, cY+24, 6, 6);
cube.FillRect(chr_clr, cX+24, cY+24, 6, 6);
cube.FillRect(chr_clr, cX+24, cY+30, 6, 6);
Don't forget to call .Paint()! ;)
I've invested ZERO time into this, so the possibilities for improvement are substantial, to say the least. Key improvements areas would include: storing the character data more efficiently (basically drawing each pixel right now), generate a class for an entire set of characters for a given typeface, etc. If you're interested in helping out, I'd be glad to release the source for this utility.
-E
Comments
Did you see my colors and text post. I am already working on a text class but I just sketched the characters out. Looks like a useful start, but I'm not sure what the generate code button does.
Nevermind ... just press ctrl + v and ... there it is. I think this will fit very nice with the direction I was going.
Awesome! Already did my first font manually, but this tool will certainly come in handy down the road. Also, props (from an Adobe engineer) for using AIR :)
Also, would be nice to have international (á, à, ñ, etc.) characters listed. (I need to write in French.) If you post your source somewhere (maybe Github?), I might help with some improvements.
Thanks, Sean. Actually, since you mention it (and you happen to be an Adobe engineer), the only reason that I'm using a dropdown component for the character selection is because adding a text field of any kind (static, dynamic, input) to the stage at this point would make the textfields that are rendering htmlText stop working altogether.
Quite an interesting bug...
That is cool idea to rasterize the font. But the tool has several issues to fix. ComboBox open up and the part of symbols stay behind the stage. Also if I will resize application window then all will scale instead of liquid layouting. Maybe actually will be better to put on gittub the source code?
There are quite a few things that need to be addressed in this utility. It's really just a shade above a proof-of-concept, so I haven't spent much time at all with it.
I'm going to push it up to github as soon as I get some time — will keep you posted.
@Evan: Odd bug. Not sure what's going on without seeing the code. But since it looks like you're using Flex, I'd just use a standard TextInput component.