Editing .font with Hex editor?
Avatar

I was looking for a way to put any .ttp or.ftp font files into mod but i can't find anyway to fix it.
I searched lots of way to search but know nothing about modding, Hex editing or things like that.

I was wondering if anyone can help me with decrypting this file.

So, here's something i found out while i was working about .font files.
(BTW BAD ENGLISH+FORMAT)

-There is 3 type of files in fonts folder: (.merged_font) (.texture) (.font)

-.merged_font file is a script that merges 2~3 .font files.
you can open this file with normal editor like Notepad++.

-.texture file has image of all the letter which can be shown in-game.
Just like other files, this can be renamed into .dds file to modify picture of letters and icons.
If it's possible to modify .font files, you can add more image to make it possible to display in your pc, not others.

-.font file cannot be opened in normal way. but it shares many aspect with "bitmap font" as it seems to connect Text codes with image in .texture.
I searched about how to open files, and only way I could find was using Hex.
If we open .font file with Hex editor(I used 30-day trial 010 Editor), I couldn't understand at first, but I searched more about how to look it.

It seems to be consist of 4 part: (header), (stuffs i can't understand), (code that shows text), (original font info).

-Original font info is written in Hex at the bottom of file. When changed into text, it shows original font info(duh).
for example, font_digital.font says digital number font zS07
I have no idea what zS07(7A 53 30 37 in Hex) is, but i could find same image used in .texture by searching this info.

-Problem is I can't understand other part from now on. I tried everything...

  • Making .font file?
    If we use BMFont to make bitmap font, try setting font descriptor as binary, textures as dds /w compression dxt3. It will make .dds file and .fnt file.
    This .dds can be easily changed to .texture file. (COULDN'T CHECKED WHETHER IT CAN REPLACE ORIGINAL FILE OR NOT)
    However, .fnt file cannot be opened in simple editor.
    I tried Hex editor to open this, and it showed a lot like .font file.
    I'm assuming .font file is like mutant-brother of .fnt file.
    So maybe it's possible to change .fnt file into .font file?
Replies
Avatar

Ok, I managed to understand most of the HEX code in .font file.

.font is made of 5 part. but one of parts doesn't do much of thing.
btw this file uses little-endian; which means you must write bytes in BACKWORD (example: 17167054 in Dec = 0105F2CE in Hex -> CE F2 05 01)

-part 1. header
header is consist of 92 bytes. (0x0000~0x005B) header file explains places where most of info can be found.

this is example and explanation of one of the header, I divided to make it look easier. :
-BE 00 00 00 BE 00 00 00 5C 00 00 00
<- BE shows how many font images there are. In this case 190 pictures. 5C shows where starting point of part 2 is. (0x005C)
-78 73 F2 00 00 92 05 15 <- didn't figured out. but totally useless. just make all 00.
-BE 00 00 00 BE 00 00 00 C8 07 00 00
<- BE shows how many font letters there are. In this case 190 letters. It must match with the number of image since each letter has it's own image. C8 07 shows where starting point of part 3 is. (0x07C8 NOT 0xC807)
-78 73 F2 00 01 16 8E 00 D4 F8 18 00 <- again, useless.
-3A 00 00 00 3A 00 00 00 B8 0D 00 00
<- This part shows data about part 4. but part 4 is not important in running normally. You can make it all 00, but you must delete codes in part 4 to avoid any problem.
-78 73 F2 00 01 16 8E 00 78 73 F2 00 <- useless part.
-70 10 00 00
<- This shows where starting point of part 5 is. (0x1070)
-18 00 00 00 <- useless part.
-00 01 00 00 00 01 00 00
<- shows size of .texture file. this texture file had 256256 px. if it had 1024512 px, it's 400*200. so type 00 04 00 00 00 02 00 00 in this point
-16 00 00 00 19 00 00 00 <- useless part.

How to edit this part :
all the header in .font file can be explained just like example.
edit this part after you edited all the other parts.
change all the details which were changed by editing other parts.(like #n of letter, size of .texture)

-part 2. image tile part
This part explains about image each letter will use. This image comes from .texture file.
This part repeats 10 bytes of data. and shows which portion of .texture file was used in each image tile.

example: 00 0A 1C 09 FF FE 72 00 54 00
last 72 00 54 00 shows coordinates of upper-left corner of image (or just simply 'x','y'). In this case, it's at (114, 84)

  • first 00 means nothing. it just divides each image.
  • 0A 1C shows 'width' & 'height' of image. In this case, 15*28 px.
  • 09 FF FE shows 'advanceX', 'bearingX', and 'bearingY' of that font image. this is hard to explain but these are commonly used in other 'normal' font files. It shows how much gap there is between each letter, or something like that. FF in bearing means -1, FE means -2 and so on.

How to edit this part:
I used BMFont and made .fnt file font with descriptor as XML or text. this .fnt file showed all the data used in this part.

ex: <char id="32" x="0" y="0" width="19" height="18" xoffset="1" yoffset="2" xadvance="23" page="0" chnl="15" />
you can use x, y, width, height, xadvance, xoffst, yoffset from .fnt file.
but for 'x,y', you must check .texture to see if it matches.

Avatar

-part 3. letter-image part
This part shows which letter uses which image. This part repeats 8 bytes of data.

example: 50 00 00 00 10 00 00 00

  • first 4 byte shows unicode of the letter. in this case, it's U+0050, P
  • last 4 byte shows which image this letter uses. It uses data from part 2. 00 = 1st line in part 2, 05 = 6th line in part 2, 10 = 17th line in part 2, 02 01 = 258th(102 in Hex) line in part 2.

-how to edit this part:
first, check the 1st line in part 2. find out which letter does this line shows. find the unicode of this letter. and edit this part.
next, check the next line, same thing goes on and on until you ran out of part 2.

-part 4. ??? (I'm guessing it's kerning part)
This part seems to show data about kerning of the font. but you can erase this part and fix the header. there was no problem.
Still, this part was repeating 12 bytes of data. some of you guys might find what this part means...

-part 5. original font info.
Just like I found 3 days ago. this part explains name of the font. this part is only part which is written in text. it seems you can type anything you want in this part. but i suggest to end this part with zS07(7A 53 30 37 in Hex) to prevent any problem.

36 1257