Author Topic: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]  (Read 6658 times)

Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« on: December 12, 2013, 03:45:32 pm »
Hi all. I was referred this way from someone over at the FOnline forums. I've written a couple of ExtendScript scripts for Photoshop that should make creating custom fonts a little easier. I spent the better part of yesterday trying to figure out how FOFNT files were generated (assuming they were binary), and when I figured out they were text and, essentially, sprite sheets, I decided to go about adding some fonts to FOnline. It sucked.

These scripts aim to make generating FOFNT files much easier by way of two utilities: A text splitter script - takes a single text layer in Photoshop and makes a new layer for each individual character. These layers can then be placed in an image and used by the FOFNT Maker, which reads each layer's character and creates a corresponding entry for a FOFNT file.

For more details, you can look on the GitHub page https://github.com/phatsk/FOTools and feel free to ask questions or suggest fixes/enhancements.

JovankaB

  • Guest
Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #1 on: December 12, 2013, 06:40:13 pm »
Very nice and useful thing. Actually I needed a tool like that, so thanks for sharing it :)
I tested it in Photoshop CS2 and I managed to run the scripts, although it requires two small changes in order to make it work:

1. For some weird reason this is syntax error according to CS2:

Code: [Select]
// @TODO
Removing "@" in all the lines that start with // @TODO fixes it.

2. This is even more weird, in FoFntMaker.jsx file, the line 352:

Code: [Select]
if(f !== null)
is always false in CS2, resulting in alert("Error opening FOFNT file, nothing saved") even if you choose save.
I suppose there is something wrong with !== operator in CS2 JavaScript engine.
I fixed it by reversing the condition:

Code: [Select]
    if(f === null)
    {
        alert("Error opening FOFNT file, nothing saved");
    }
    else
    {
        if(f.open('w', 'TEXT', '???'))
        {
            f.write(o);
            f.close();
        }
        else
            alert("Could not open file for writing");
    }

alternative solution is to simply change "!==" to "!=".
« Last Edit: December 12, 2013, 06:51:18 pm by b__B »

Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #2 on: December 12, 2013, 06:53:41 pm »
Thanks for the tips! Does the != work fine in CS2? I'll update the scripts in GitHub now with the other fixes.

JovankaB

  • Guest
Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #3 on: December 12, 2013, 06:59:16 pm »
Yup, != seems to work fine.

Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #4 on: December 12, 2013, 07:05:16 pm »
Fantastic - version 0.2 updated on GitHub - thanks for the fixes! ExtendScript has been a rather un-fun experience so far...can't I get a built-in Array.indexOf, Adobe?  ::)

JovankaB

  • Guest
Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #5 on: December 13, 2013, 03:02:07 am »
One more fix for TextSplit.jsx:

There is a bug in line 32:
Code: [Select]
newLayer.antiAliasMethod = AntiAlias.NONE;
It doesn't work, because antiAliasMethod isn't property of layer object. It should be:
Code: [Select]
newLayer.textItem.antiAliasMethod = AntiAlias.NONE;
Although, I would suggest to copy anti-aliasing and font from the source layer instead of setting them in the script:

Code: [Select]
    newLayer.textItem.antiAliasMethod = layer.textItem.antiAliasMethod
    newLayer.textItem.font = layer.textItem.font;

I think it especially makes sense for the font property.


« Last Edit: December 13, 2013, 12:07:30 pm by b__B »

Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #6 on: December 13, 2013, 02:36:51 pm »
Well dang - good eye! I had a feeling I had missed something but for I just couldn't see it. Fixes pushed up again - thanks

Offline Wipe

  • Rotator
  • Random is god
Re: Font Utilities - FOFNT Maker/Text Splitter [PHOTOSHOP]
« Reply #7 on: December 14, 2013, 01:37:13 pm »
I have no idea what "YAdvance" does
I'm not very familiar with fonts code, but it looks like extra space used when client needs info about letter/line height (for example when calling GetTextInfo() script function). When building font, client calculates maximum height by scanning each Letter->Height property; later, when drawing, it "manually" adds YAdvance value to that.

If i guessed right (didn't check), you should see the difference in msgbox after changing Default.fofnt->YAdvance to some silly value like 20 or so.
« Last Edit: December 14, 2013, 01:39:20 pm by Wipe »
Games are meant to be created, not played...