H2 Font File Format

User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

H2 Font File Format

Post by troymac1ure »

I know we had another topic going on this, but I'm posting this to have a place that can be updated to reflect the format as the remaining parts <hopefully> get uncovered.

The font files are divided into 4 main sections:
  • [1] Header section
    [2] UTF Table
    [3] Index Table
    [4] Character Data
HEADER SECTION - Little is known about this section other than the following:
Address range: 0x0000 -> 0x03ff

Code: Select all

 0x0000 ->
 0x01ff = Always filled with 0x00
 0x0200 = [int32] Font File Identifier?
         Always 0x010000F0
 0x020c = [int32] Number of Index Table entries
 0x0220 = Number of ?Unknown? entries in header table
 0x0224 ->
 0x0224 + NumberOf?Unknown? = Unknown codes
UTF TABLE - Is always 65536 (0x10000) bytes in size.
Address range: 0x000400 -> 0x0403ff

Code: Select all

Each entry (0x04 bytes in size)
 Byte 0x00 [int32] = Entry number in Index Table
         Does not have to be unique, Index entries may be shared
INDEX TABLE - Size is equal to [Number of entries in Index Table] * 16 (0x10)
Address range: 0x040400 -> 0x040400 + NumberOfEntries * 0x10

Code: Select all

Each entry (0x10 bytes in size)
   Byte 0x00:   [int16]   Character Display Width
   Byte 0x02:   [int16]   Number of bytes used
   Byte 0x04:   [int16]   Width of byte runs
   Byte 0x06:   [int16]   Height of the byte runs
   Byte 0x08:   [int16]   Unknown
         Appears to usually be -1,0,1,2,3 although I have seen 5 and -3 as well
         This may be some kind of draw shift, allowing for overlapping of previous characters
   Byte 0x0A:   (short)   Unknown
         Seems to remain the same value for all characters in a font
   Byte 0x0C:   (int32)   Offset to data
CHARACTER DATA - Entry lengths are determined by SIZE in the index table pointer
Address range: 0x040400 + NumberOfEntries * 0x10 -> EndOfFile

Code: Select all

There are three methods used. The first is a color change, the second is a pixel run-length and the third is a coded run length.
Data Byte:
 0x00 = COLOR CHANGE + 1 pixel run (This is the only multi-byte code)
         The two bytes immediately following the 0x00 code are a4r4g4b4 data values.
         *NOTE* After the color change a single pixel is drawn.
 0x01->
 0x7f = PIXEL RUN LENGTH
         If bit 6 (0x40) is not set, the pixels are skipped.
         If bit 6 (0x40) is set, the pixels are drawn.
         bits 0 -> 5 (0x3f) = number of pixels to skip or draw
 0x80 ->
 0xff = CODED RUN-LENGTH
        These are individual codes that provide a run-length as well as a brightness
        *NOTE* The may possibly contain alpha changes as well
This is the H2 Font Viewer source (includes debug binary as well) link (currently v0.91):
http://www.remnantmods.com/archive/misc ... Viewer.rar
*v0.91 RELEASE NOTES*
-> This update fixes a massive memory leak. When shut down, memory was not released.
-> Changed loading method and discovered there are actually many unused characters (multiple duplicates at times)
-> Fixed mouse popup displays to show correct information.
Last edited by troymac1ure on Tue Feb 26, 2013 8:22 am, edited 3 times in total.
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

Image

:huh:
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: H2 Font File Format

Post by JacksonCougar »

:wonder:
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2 Font File Format

Post by XZodia »

custom font?
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

Sure. Custom emblems. Whatever.
It's not tested in game, but I'm confident.
Also, it's got almost no optimization, so the emblem above is 2673 bytes large (largest H2 emblem I've seen is around 1600 so far), but I will try to test it in-game tonight.
It accepts on A8R8G8B8 bitmap (I used a PNG image for above).
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2 Font File Format

Post by XZodia »

Awesome, what about the characters? is that one of the h2 fonts, a font file or images you loaded in?
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

That's the handel_gothic-24 font (used to display LOADING xx% when no videos are found at startup), but the selected image is my family clan's crest. It was loaded in from a PNG file and accessed through UTF code 0x1F (this is when the labels were still incorrectly labelling things)
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

Just testing the start of my new font character importer program:
Image

I noticed that the clan icon, which I imported over the "%" character, has some artifacts (looks like I didn't run the length to the end) and also a few on the "i", "n" and "g" letters as well.
I made those letters in an editor quickly and saved them as a .PNG file. Imported each one over the old letter and presto!

Also, in the program you can write text to see how your font will display. It looks as though it displays pretty much perfectly to the H2 display, although this is my first test.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2 Font File Format

Post by XZodia »

Awesome!
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: H2 Font File Format

Post by JacksonCougar »

This is really fucking sweet :p Considering making a Git repository for this?
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Re: H2 Font File Format

Post by Grimdoomer »

JacksonCougar wrote:This is really fucking sweet :p Considering making a Git repository for this?
Fuck git we're not on linux. Use svn.
Don't snort the magic, we need it for the network.
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

Re: H2 Font File Format

Post by JacksonCougar »

Grimdoomer wrote:
JacksonCougar wrote:This is really fucking sweet :p Considering making a Git repository for this?
Fuck git we're not on linux. Use svn.
I like git for windows more than tortoise-svn¹—which is the extent of my source-management experience.
¹Besides svn lost sunfish so fuck that guy ( and by association fuck me for forgetting to 'add' files to the svn... bleh )
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2 Font File Format

Post by XZodia »

I agree that git failz.
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

I'll u/l the code and someone else can do a git repository. I have only set one up and it was a hay-day. I don't use it enough to get to know it that well.
Anyways, the code is just class file and then a few procedures on a form to complete. Pretty straight forward.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2 Font File Format

Post by OwnZ joO »

XZodia wrote:I agree that git failz.
Git(or any distributed version control) is much better if you actually learn how to use it. That being said, Github for Windows makes it dead simple to use, so I would recommend that if you're having trouble.
User avatar
XZodia
Staff
Posts: 2208
Joined: Sun Dec 09, 2007 2:09 pm
Location: UK
Contact:

Re: H2 Font File Format

Post by XZodia »

I have tried that, its really bad...
Image
JacksonCougar wrote:I find you usually have great ideas.
JacksonCougar wrote:Ah fuck. Why must you always be right? Why.
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Re: H2 Font File Format

Post by Grimdoomer »

XZodia wrote:I have tried that, its really bad...
This.

I would recommend google code as a svn repository.
Don't snort the magic, we need it for the network.
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: H2 Font File Format

Post by Click16 »

Instead of arguing over these mediocre things, I'm gonna congratulate Troy. First custom/edited injected Halo 2 font I've seen. *applause*
Image
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

Thanks Click.
It needs tweaking, but the main base is there anyways. I only made the 7 letters that are seen on screen, the rest are still the regular handel-24 font letters, but a whole font could be customized.
Each letter took me a while to get saved in a .png format with transparency, but the injection takes a matter of a split second to inject after calculating the proper character code.

New options could include:
-Type character to overwrite (currently uses UTF code)
-GUI click to select character to overwrite
-Import whole font from single bitmap (each character in an even grid, auto-width adjusted if necessary or similar)

Anyways, if the main goal is for custom medals, this will inject those no problem (as soon as I fix the artifacts).
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2 Font File Format

Post by OwnZ joO »

Grimdoomer wrote:
XZodia wrote:I have tried that, its really bad...
This.

I would recommend google code as a svn repository.
What is bad about it, git's a different paradigm for sure so it takes some unlearning of svn, but it's worth it once you get it. I work with SVN at work for the record, and I do realize that the GUIs for SVN are more mature, but command line is better than a GUI anyway and Git on Windows uses powershell which is more similar to a linux shell than windows command line.

Also, good work Troy.
User avatar
Grimdoomer
Admin
Posts: 1835
Joined: Sun Dec 09, 2007 9:09 pm

Re: H2 Font File Format

Post by Grimdoomer »

OwnZ joO wrote: command line is better than a GUI anyway
Depends on the application and context of how it would be used. As far as SVN/git is concerned, I don't really see either being the better solution. If you usually clone the entire source tree then there really is no use for a gui application. However, if you don't or you would like more control over exactly what files/folders you are cloning then a gui application would be ideal over a command line one.
OwnZ joO wrote:Git on Windows uses powershell which is more similar to a linux shell than windows command line.
Why on earth would you give windows users an application that uses a linux style command prompt? GitHub for windows looks like a nice application, except there doesn't appear to be any way to clone a repository from the gui application or from the "Clone in Windows" button without a GitHub account. I shouldn't have to make an account to clone a repository, especially if I will not be committing anything back to it.

But seeing as you can clone a branch on github by clicking the "Zip" button I don't really care if git or svn is chosen.
Don't snort the magic, we need it for the network.
User avatar
OwnZ joO
Posts: 1197
Joined: Sun Dec 09, 2007 4:46 pm

Re: H2 Font File Format

Post by OwnZ joO »

Grimdoomer wrote:
OwnZ joO wrote:Git on Windows uses powershell which is more similar to a linux shell than windows command line.
Why on earth would you give windows users an application that uses a linux style command prompt? GitHub for windows looks like a nice application, except there doesn't appear to be any way to clone a repository from the gui application or from the "Clone in Windows" button without a GitHub account.
Because it's linux-like, not linux, and the linux command line is INCREDIBLY powerful and convenient. It's also included in Windows 7 and up and easily installable on other versions of Windows.

Yeah it doesn't appear that you can clone in windows using the GUI app without having an account. You can issue a git clone https://github.com/account/repository.git commant from powershell to clone one without an account though.
User avatar
CaptainPoopface
Posts: 714
Joined: Sat Feb 16, 2008 5:47 am

Re: H2 Font File Format

Post by CaptainPoopface »

This discussion does not belong in the H2 font format thread...
User avatar
Click16
Posts: 1941
Joined: Mon Dec 31, 2007 4:36 am
Location: United States

Re: H2 Font File Format

Post by Click16 »

CaptainPoopface wrote:This discussion does not belong in the H2 font format thread...
My thoughts exactly. I tried to change the subject a few posts back, but I was unsuccessful. On a side note: I was looking at the medals for Halo 3, and I noticed that they share the same style as Halo 2's. I am hoping to transfer a few over when I can.
Image
User avatar
troymac1ure
Keeper of Entity
Posts: 1282
Joined: Sat Aug 09, 2008 4:16 am
Location: British Columbia, Canada, eh
Contact:

Re: H2 Font File Format

Post by troymac1ure »

I was making the importing program more user friendly last night. Before it was basically a "can I get this to work?" scenario...
Post Reply