Nyerguds

Westwood Font Editor [Development thread]

38 posts in this topic

Current version: 1.7.1 (2017/05/23 18:40)

fonteditor_20_vcr_1.7.1.png

The project is built on the .Net framework v3.5
Its code is licensed under the WTFPL.

Download:
Downloads folder
Full readme

Source code: (C#)
Sources folder

 

Full list of supported types / games:
 

WWFont v1:

  • Wargame Construction Set
  • A Nightmare On Elm Street
  • DragonStrike
  • Circuit's Edge

WWFont v2: (Note: the save routine for this type is currently set to optimise the size by removing duplicate image data, but I'm not sure if the games support this)

  • BattleTech: The Crescent Hawk's Revenge
  • Eye of the Beholder
  • Eye of the Beholder II: The Legend of Darkmoon

WWFont v3:

  • The Legend of Kyrandia
  • Dune II
  • Lands of Lore The Throne of Chaos
  • The Legend of Kyrandia Hand of Fate
  • The Legend of Kyrandia Malcolm's Revenge
  • The Legend of Kyrandia Malcolm's Revenge Installer
  • Command & Conquer
  • Command & Conquer Installer
  • Command & Conquer Red Alert
  • Command & Conquer Red Alert Installer
  • Lands of Lore Guardians of Destiny
  • Lands of Lore Guardians of Destiny Installer
  • Command & Conquer Sole Survivor
  • Lands of Lore III

WWFont v4:

  • Tiberian Sun
  • Tiberian Sun Installer
  • Tiberian Sun Firestorm
  • Tiberian Sun Firestorm Installer
  • Lands of Lore III Installer

IGFont (Dune 2000 was made by Intelligent Games, not by Westwood)

  • Dune 2000

 


Original first post:


As I sort of mentioned a while back, I got tired of the lack of font editor for C&C1, and even more tired of Siberian_GRemlin sitting on his (working) version for about 10 years now.

So I've decided to make my own in c#. With the help of the RA++ team (Omniblade, CCHyper & Tomsons26, anyway) I figured out the font format itself, and managed to make code to read it and show it as image. Apparently this format is used for quite a bit more than C&C1 and RA1; we used fonts from Legend of Kyrandia as test material as well, and apparently this should support Dune II too.

Fonts have no colour palette of their own. They are 4-bit (meaning, 16 colour) images that, much like SHP files, receive colours from the game at the moment they're drawn. So I started off by generating a simple black-to-white fade for the palette, with black as the background color. This version also already moved the character down according to the extra Y-offset in the file.

fonteditor_00.png

Next step: making an actual editor. I already had a zooming pixel image viewer from a little C&C-N64 project I worked on in the past few weeks, so that part was no problem (as already seen in the previous image). So the next step: drawing an editing grid on it. Well, I say "on it", but actually I needed three extra image layers positioned both behind and in front of the original image to pull it off, lol. Transparency is a strange thing in .Net controls.

fonteditor_02_grid.png

Next was getting a pixel drawn on that to indicate your editing position. That was easier than expected, really, and now I had a nifty giant pixel following my mouse around. Also note the fancy program icon; Tomsons26 made that :)

fonteditor_03_mousetrackpixel.png

I decided, around this time, to switch to a more colourful palette that would let you easily distinguish the different indices when editing. I just basically went over all hue values and made a nice little rainbow. I also coded in some extra behaviour to allow disabling the grid, and the red frame that shows you which part of it is actually editable.

fonteditor_05_rainbowpalette.png

Of course, an editor is utterly useless if it can't actually save files, a little detail Siberian_GRemlin seemed to forget when he released a "demo" of his editor... eight years ago now. So after editing worked, I went into the mess of trying to save the image data back to palette.

It took a few tries to get it right. :huh:

But, finally, I managed to get a saved file!

HO0ulQxp.png

No, wait, crap, that's one of the failed ones. Ahem. Anyway. The pic I linked before shows the final successful attempt. There's a little pixel I made transparent, in the middle, to prove it was actually edited. Trust me, it was orange originally :P

Now, there's just one thing still missing from the editor... and that's, well, the actual editing, more or less. I could only change the colour to one specific one with the left mouse button, and to background (transparency) with the right mouse button. So I dug up another nice control I had lying around for one of my older projects, namely a palette-loading colour selector. Took some time to adapt it, since the original was meant for 256 colours, but, I'm happy with the final result!

fonteditor_07_palette.png

It's starting to look good, no? :)

At this moment, it's still missing some vital features, though; you can't change the size of the images or their Y-offset, and you can't add new character images to a font. These will come later, but at this moment, I do actually have a working editor.

It's obviously still beta at the moment, but to anyone who wants to mess around with it, here it is:

Westwood Font Editor v0.4

The source code is in the folder too, for those who are interested.

0

Share this post


Link to post
Share on other sites

Not ANOTHER tool Nyer! You're hooked making extremely useful things for us all :P

 

I will try to resist the urge to make a new font for my C&C game as scope creep is a leading cause of death among mod developers but even so, sweet work dude! :cncsmirk:

 

Your 2 looks very Hotline Miami in that editor :P hehe

0

Share this post


Link to post
Share on other sites

I believe that's the "mission accomplished" font. It's greyscale ingame with a slight glow in the middle.

0

Share this post


Link to post
Share on other sites

Ah you are right, I see that now :) I've never tried putting numbers there. Heh, lose a mission and get "Error code: 2"? :P

0

Share this post


Link to post
Share on other sites

New progress: editable Y-offset! Also, a revert button to undo all changes to the current character. I also changed the internal architecture somewhat, by putting all different properties of one character entry into a single object, so I only have one list of internal data instead of four parallel ones. Much more manageable.

 

fonteditor_08_y_oh_y.png

 

After I implement editable width and height, and X and Y shifting of the image data, I'll make another public release :)

 

Dune 2000 fonts are not supported I guess?

I honestly have no idea, but given the fact that game barely uses any WW file formats, I suppose not. If you got any specs and test files, though, I might be able to implement it. You never know; might not be too hard. The current editor is focused on 4-bit fonts though.

0

Share this post


Link to post
Share on other sites

Two of the main features finished:

  • A real list of characters, replacing the small index based number selector.
  • A listing of text encodings, so you can immediately compare your characters with the target encoding.

Showcased on the Central European font used in the Polish language pack:

fonteditor_09_list.png

0

Share this post


Link to post
Share on other sites

A little experiment for possibly implementing Dune 2000 font support (since that's an 8-bit font)... dynamic changing of the palette control to adapt to a larger amount of colors. Basically, they're calculated to use 1/8th of the color label size as in-between spacing.

The hardest part was actually modifying the font size for the transparency/empty indicators so they'd still be visible.

fonteditor_10_eightbitpal.png

0

Share this post


Link to post
Share on other sites

v1.0 is finished! This adds pretty much all features I wanted for it:

  • Changing image dimensions
  • Shifting image data up/down/left/right
  • Copying/pasting entire characters
  • Color picker
  • Adding/removing characters
  • Changing the overall font's maximum size

Note that the mouse scroll wheel is specifically disabled in the main font's settings (number of character and max width & height) to avoid accidentally messing stuff up; decreasing the amount of characters simply removes the excess without prompt, and decreasing the font size cuts all characters in the entire font down to the new size.

fonteditor_11_firstrelease.png

The only thing still left to do for now is figuring out how to add some kind of real palette loading/saving support. Currently, colours can be edited by double-clicking them, but these palette changes can't be saved inside the program, and the only way to reset the palette is to restart the program.

0

Share this post


Link to post
Share on other sites

Added Tiberian Sun support... and fixed a couple of bugs that crashed the program.

fonteditor_12_tibsun.png

I'll see if I can get working on Dune 2000 support after this; the format is also 8-bit.

0

Share this post


Link to post
Share on other sites

Released v1.2.

  • Implemented support for older versions of the font format.
  • Split internal font versions off into separate classes.
  • Made unified reading and writing methods for 1, 4 and 8 bit data.

... and some bug fixes on manipulating small images.

0

Share this post


Link to post
Share on other sites

Cool

 

Dune 2000 fonts are not supported I guess?

I added experimental Dune 2000 support in the new version (1.2.1), but the format is pretty weird, and several of the letters in the font seem to have errors even when read exactly like the header describes, and there's no extra info anywhere in the file that could fix it. Could you give it a test run, and see if the game accepts the fonts produced by the editor?

 

It's possible that you need to edit the first byte in the file to 00 to make it work. Please test that too.

 

By the way, I couldn't match the characters to any existing text encoding... really weird. I even disabled my internal filtering on ascii-compatible and 1-byte-only encodings, and still nothing matched.

0

Share this post


Link to post
Share on other sites

Well, it's more like, 5 formats, now. I added the games list tomsons26 so kindly provided :P

We've been digging through some really ancient Westwood games, lol.

On 2016-11-28 at 1:51 AM, Kilkakon said:

Ah you are right, I see that now :) I've never tried putting numbers there. Heh, lose a mission and get "Error code: 2"? :P

I took the number 2 mostly because its center showed off all the colours nicely  :P

0

Share this post


Link to post
Share on other sites

And it's time for v1.2.2, finishing the Dune 2000 support.

 

fonteditor_14_d2k_encoding.png

 

tomsons26's little test:

dune2000_2016-12-01_19-58-26.png

0

Share this post


Link to post
Share on other sites

Added Tiberian Sun support... and fixed a couple of bugs that crashed the program.

 

fonteditor_12_tibsun.png

 

I'll see if I can get working on Dune 2000 support after this; the format is also 8-bit.

 

Yooo m8, where can these fonts be found at?

0

Share this post


Link to post
Share on other sites

Um. The TS ones? Inside the .mix files, where else? Anything ending with .fnt is a safe bet.

 

I just implemented a new feature: color tracking. In color picker mode, the palette will highlight the color entry you're currently hovering over in the image, and a popup with the color index and value will appear on the editing grid.

 

fonteditor_15_colorpicker_upgrade.png

 

Next is palette support. When that's finished I'll be making a new release.

0

Share this post


Link to post
Share on other sites

New version released: v1.3

 

I implemented pretty much everything that was still missing; custom palette support, and the ability to edit the program defaults of enabled options and editor colors.

 

fonteditor_16_custom_palettes.png

 

0

Share this post


Link to post
Share on other sites

Whoo, did some bug fixes, and ended up adding some new features.

v1.4:

  • Clipboard copy can now also be pasted as image in other applications.
  • The correct symbol will be opened even when the grid columns are reordered.
  • Added preview pane at the bottom.
  • Opening a file by double-clicking in the dialog can no longer paint a pixel.
  • The symbol image now refreshes correctly after a palette revert.
  • Symbols in the grid are no longer centered but drawn at the correct position.

fonteditor_17_preview.png

0

Share this post


Link to post
Share on other sites

lol. "Here's a test with special characters! Very pretty, isn't it?"

It's funny, actually; for the characters listing in the grid I only needed to make that Dune 2000 text encoding one-way (byte -> character), but I decided to implement the other way (character -> byte) while I was at it anyway. And because of that, this thing worked with it right away :D

Then again, the Dune 2000 reordering system was only ever meant for character -> byte (well, character to font index, but that's the same thing, really), so that one was easy compared to the one I originally needed.

On the actual preview generation side, the thing that took the longest was actually auto-wrapping (yes, it does auto-wrapping, though, character based, not word based) and support for line breaks, heh.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.