1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Game Font Editor

Discussion in 'Civ4 - Utility Programs' started by Asaf, Jul 2, 2011.

  1. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Game Font Editor for Civilization IV

    Download version 0.6 Here (updated 15-Aug-2012)

    (Original development thread here)

    This utility allows for easy editing of GameFont.tga and GameFont_75.tga. It eliminates the need to directly touch the :evil: grid with its :evil: alpha channel and :evil: markers, and prevents corruption of the file.
    It supports the BUG gamefont file and the WOC extended gamefont files.

    It is currently in Beta version.

    Change Log:

    Version 0.6:
    - Bug fix (reported by stolenrays): Scrollbar jumps to its initial position after most actions when image file is large (e.g. WOC)

    Version 0.5 (Beta):
    - Bug fix: Could not find rows if 'rows fixing' was disabled (i.e. max corrupted pixels = 0), even if no corrupted pixels were found.
    - Bug fix: Image type is identified even if renamed and of unusual size - looks for '75' in the file name.

    Version 0.4 (Beta):
    - Feature: Added ability to add transparency to an opaque icon: 'Alpha!' button. Transparent color is determined by the image corners, and the sensitivity can be changed using a slider. (Useful, for example, when you've found an image online: Just do a 'copy image' from the browser - no need to even save it to file - then paste it into a cell, and add transparency.)
    - Feature: Can run an external image editor to specific slots from within the game font editor (click on 'Edit'), and then update the slot after saving in the external editor (click on 'Update').
    - Feature: Added config file which holds all the user's settings to be loaded for the next time. File is created and updated when exiting the program, and is saved in the Documents folder (or 'My Documents'). It's called Civ4GameFontEditor.cfg.
    - Feature: Enabled changing the background color for the font image when not showing the grid.
    - Bug fix: Changed UI colors to absolute colors
    - Bug fix: Fixed a bug that caused a crash when using 'Save As'
    - Bug fix: Fixed a bug where title did not change when using 'Save As'

    Version 0.3 (Still Beta):
    - Feature: Added undo/redo mechanism. There's no limit on number of actions.
    - Feature: Added cut/copy/paste of icons in the image. (Can also import/export that way from other applications, but it usually doesn't copy the alpha channel)
    - Feature: Added ability to add a 'Star Overlay' to an existing icon, to mark holy city and corp HQ. (Thanks to el_hidalgo for the star overlay textures!)
    - Feature: Added auto-backup for image. Happens once before saving it for the first time. Does not override previous backups.
    - Feature: Can optionally enable editing the actual fonts.
    - Feature: More settings to allow flexibilty of the auto-correction functionality.
    - Bug fix: Allows more flexibility for rows height and font position.
    - Bug fix: When clearing cell, cell image was not updated.
    - UI: Added tool bar icons.
    - UI: Added hidable settings panel.
    - UI: Added hotkeys:
    • Open/Save image (Ctrl-O,Ctrl-S)
    • Cut/Copy/Paste (Ctrl-X,Ctrl-C,Ctrl-V)
    • Undo/Redo (Ctrl-Z,Ctrl-Y)
    - UI: Added more tool tips
    - UI: Added an exception display dialog, in case the program crashes.

    Version 0.2 (Beta):
    - Bug fix: Editor didn't work on Windows 64 bit.
    - Bug fix: Corrupted huge WoC font files when loaded (See note below).
    - Bug fix: When not showing grid, changes were not displayed.

    Version 0.1 (Beta):
    - Feature: Opening and analyzing game font files.
    - Feature: Exporting individual slot images from the font file to image files (TGA, PNG).
    - Feature: Importing image files (TGA, PNG, DDS) into specific slots in the font files.
    - Feature: Clearing specific slots.
    - Feature: Editing the cyan marker - adding/removing and changing its position.
    - Feature: Automatic fix of corrupted game font files. Handles bad alpha and corrupted colors on the grid.
    - Feature: Saving your changes to a game font file (kinda obvious).
    - Feature: Displaying the game font image with and without the grid.

    The user interface for this utility is far from pretty, and I intend to continue working on it in the future.

    This utility requires .NET 2.0 framework installed on your PC. Most operating systems today should already have the .NET framework installed, but just in case yours doesn't, you can download it here.

    Source code of the utility is packed in the downloaded file.
    It was written in C# and uses the FreeImage open source library for image handling (see license information below).

    License information:
    Spoiler :
    This software is published and used under GNU GPL, version 2. See license-gpl.txt which comes with this program.
    (license source: http://www.opensource.org/licenses/gpl-2.0.php)

    This software uses the FreeImage open source image library. See http://freeimage.sourceforge.net for details.
    FreeImage is used under the GNU GPL, version 2. See license-gpl.txt which comes with this program.
    (license source: http://www.opensource.org/licenses/gpl-2.0.php)


    Screen shots:
    GFE1.PNG GFE2.PNG

    Any feedback is appreciated.

    A note regarding the WoC fix:
    I added a 'max corrupted pixels' parameter which is used when loading an image. The default setting (50 pixels) seems to work fine for most files, but if you have a really corrupted file (with more than 50 corrupted pixels on a single separator line) you might want to increase that.
    On the other hand, if you have a very short row of slots which gets identified as corrupted lines by mistake, you might want to decrease this number.
     
  2. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Optional features for the future: (updated for 0.3)
    - Adding automatic meta data: for example - read the religion/corporation XML files and display for each icon which religion/corporation it is used for.
    - Allow for adding slots to a row, and possibly add rows.
    - Drag/drop cells

    Your ideas are more than welcomed :)
     
  3. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,079
    Location:
    Germany / Netherlands
    OMG awesome, that's soooooooooooooo nice :goodjob:.
    Downloaded it, clicked a bit around, that works just nice, you even thought of such a comfort function like resizing imported images, great. That will make changing gamefonts a damn lot easier. Just wow.


    Minor, minor nitpick: A confirmation dialog for saving the file would probably be good, because else you might to easily overwrite your current file with a test or so.
    Okay, that's nearly no problem, because redoing the stuff is now a piece of cake :goodjob:.

    -> this tool is probably one of the best released things in the past years :goodjob:.
     
  4. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,316
    Gender:
    Male
    Location:
    Canberra, Australia
    Absolutely amazing! It found problems in my game fonts and fixed them.

    However , I was not able to do anything with the resource area of the fonts. Religions and corporations seem to work OK.

    Argh, fixes worked on the gamefont file but caused a ctd when I used the "fixed" GameFont_75 file. And I have to be elsewhere now. Anything I can provide that may help solve my problem?
     
  5. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    I'm trying to get this to run on my Mac via an installation of Windows7 Ultimate. .NET 2.0 is installed and GameFontEditor launches fine. However whenever I try to load an image, even the default BTS gamefont files, I get this error:

    Code:
    Failed loading image: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
    And then GameFontEditor exits. Any idea what could be causing this?
     
  6. stolenrays

    stolenrays Deity

    Joined:
    Aug 2, 2009
    Messages:
    2,061
  7. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    @The_J - Thanks :D Regarding confirmation dialog - there's 'Save' and 'Save As...', and I tried to follow the standard windows applications (when you click save it doesn't ask you for confirmation). I think that popuping a dialog whenever you save would be a little annoying. How about automatically creating a backup image?

    @Dancing Hoskuld - Can you attach the font file before and after the editing? I also have no idea why the resources area causes problems. I'll try it with your specific files. Anyone else has problems editing the resources?

    @Xyth - I have an idea - do you have a 64 bit OS? The program uses the free image 32 bit native DLL, and I didn't mark the application as 32 bit... I think I know how to fix this. I'll try doing it later today.

    @stolenrays - Great! :D
     
  8. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,316
    Gender:
    Male
    Location:
    Canberra, Australia
    Here are the current and fixed "new" font files. turned out that the new gamefont.tga did not work in game but it did not CTD either.
     
  9. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    It is indeed a 64bit OS. Thanks!
     
  10. el_hidalgo

    el_hidalgo Prince

    Joined:
    Dec 24, 2007
    Messages:
    354
    Location:
    Republic of Texas
    I got the same error as Xyth. 64 bit system as well. Still, this is an amazing idea for an application. It opens up a whole new world to those of us who had given up on this *&#$%@!! :evil::evil::evil: file. Thank you so much for this! :goodjob:
     
  11. NikNaks

    NikNaks Deity

    Joined:
    Jul 25, 2006
    Messages:
    2,972
    Location:
    England
    I've downloaded and will try it out at some point during the week! :)
     
  12. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    Update: Version 0.2 (still in beta) was uploaded to the same link.
    It should fix both the 64 bit OS and WoC problems.

    @Dancing Hoskuld - your files weren't corrupted at all. It's just that the editor thought these lines were corrupted since most of the line was in the separator color (the image is very wide).
    This caused a few rows (the last font row and a few more) to be deleted.

    This, in turn, caused the resource to be inactive because the editor stops scanning after two consecutive separator lines.

    I changed the 'corrupted line' sensitivity to be in pixels, and adjustable (see note in the end of the first post).
     
  13. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,316
    Gender:
    Male
    Location:
    Canberra, Australia
    Thank you, I am downloading the new one now t try out.

    looking good.
     
  14. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    0.2 is working for me, thanks! Seems I've trashed my alpha channels far worse than I imagined so I'm going to try rebuilding my gamefont files from scratch hehe. This tool should help immensely.

    Could I request cut/copy/paste support (of cells)? Or even swapping of cells via drag & drop?
     
  15. Asaf

    Asaf Sleep Deprived

    Joined:
    Mar 22, 2010
    Messages:
    1,326
    I added these to the list (post 2).

    It would help if people could vote on the features they want/need the most out of that list. That way I can prioritize them.
     
  16. Xyth

    Xyth History Rewritten

    Joined:
    Jul 14, 2004
    Messages:
    4,052
    Location:
    Aotearoa
    Here's my personal order of preference from the list:

    1. Cut/Copy/Paste of cell images
    2. Adding undo ability
    3. Automatically create an alpha channel for an icon from the image (using a "background color").
    4. Allow for adding slots to a row, and possibly add rows.
    5. Add option to automatically add a star to an icon to mark holy city or HQ.
    6. Adding automatic meta data: for example - read the religion/corporation XML files and display for each icon which religion/corporation it is used for.
    7. Drag/drop cells

    EDIT: Noticed a small bug. When you clear a cell the mouseover graphic near the top-left still shows the graphic that was there previously.
    EDIT2: Revised my list after some more thought and experimentation
     
  17. NikNaks

    NikNaks Deity

    Joined:
    Jul 25, 2006
    Messages:
    2,972
    Location:
    England
    I'd like to see the following (in this order):
    1. Backup the image before saving - Until you can guarantee the output, this is key
    2. Cut/Copy/Paste of cell images
    3. Adding undo ability - I think it'd be more necessary once copy-paste is there
    4. Option to automatically add a star to an icon to mark holy city or HQ
    5. Directly open an image editor from the utility (same way as DXTBmp does)
    Those other three would all be handy. As for the others, here are my thoughts:
    • Adding automatic meta data: for example - read the religion/corporation XML files and display for each icon which religion/corporation it is used for - Would be handy, but not as essential as the other image-based ones; if this was a full game editor, it might be different
    • Automatically create an alpha channel for an icon from the image (using a "background color") - Seems a bit too complicated to be really necessary; surely the images we'd be inserting would be transparent already
    • Drag/drop cells - Not essential, but could be useful, I guess
    • Allow for adding slots to a row, and possibly add rows - Considering how few mods would needs this, I'd put this at the bottom of the priority tree; the ability to recognise additional rows that had been inserted manually would work equally well
     
  18. stolenrays

    stolenrays Deity

    Joined:
    Aug 2, 2009
    Messages:
    2,061
  19. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    There no words in any language that can adequately describe how awesome this truly is. So I must make one up, a word like awesomecool. But even this potent word cannot truly describe its awesome.

    The goats of the world thank you.
     
  20. el_hidalgo

    el_hidalgo Prince

    Joined:
    Dec 24, 2007
    Messages:
    354
    Location:
    Republic of Texas
    This is really, really, really, really great (really!). :goodjob: Personally, in terms of features, all I need is copy/paste. I don't really even 'need' that, since I can work around it with the import/export functions, but it would be easier.
     

Share This Page