Author Topic: Final Fantasy VIII fonts width  (Read 20663 times)

Johnny_Doe

  • *
  • Posts: 7
    • View Profile
Final Fantasy VIII fonts width
« on: 2013-12-13 21:44:24 »
Hello there. I hope that's the right section for my question. Our team is translating Final Fantasy VIII into Russian and we've stuck at fonts reinsertion. Can somebody tell us where the table of width values for HiRes fonts of the PC version can be found? Our programmer needs those values for the following files:

\eng\menu\hires\sysfld00.tex
\eng\menu\hires\sysfld01.tex

We really would appreciate it if somebody could help us out.

Johnny_Doe

  • *
  • Posts: 7
    • View Profile
Re: Final Fantasy VIII fonts width (done)
« Reply #1 on: 2013-12-16 10:36:44 »
Alright, people, our programmer was cool enough to figure out the answer by himself. Here's the translation of what he wrote:

So we have two files:
main.fs  archive
\data\eng\sysfnt.tdw - this one is for HiRES fonts

menu.fs  archive
\data\eng\menu\sysfnt.tdw - that one is for regular fonts

Both of them have the SAME width tables
The values of "main.fs" archive's font width table should be multiplied by 1,67. The results are to be approximated to bigger values.
http://yadi.sk/d/4Tm5CiXNENrNL

The numbers are stored the same way - the width of symbols starts from the 8th byte with its description starting right after the "space" (I mean the space key on keyboard, if something) in "sysfnt.tdw" file. It takes half of a byte per symbol. The bytes from 0 to 4 - the 1st symbol, from 5 to 7 - 2nd symbol.
Suppose there are symbols of 22, 15, 11 and 7 pixels wide. In that case the values in the table would be the following:
22 / 1.67 = 13.19 => 14 (0xE)
15 / 1.67 = 8.999 => 9 (0x9)
11 / 1.67 = 6.599 => 7 (0x7)
07 / 1.67 = 4.199 => 5 (0x5)
---
9E57

As we can see the maximal absolute error is 1.66 pixels. Sometimes it is better to approximate the number to the lesser value in order to avoid leaving too big space between the symbols.
« Last Edit: 2013-12-16 21:48:28 by Johnny_Doe »

LeonhartGR

  • *
  • Posts: 2577
  • ~Whatever...~ Enjoy life!
    • View Profile
    • LeonhartGR Productions
Re: Final Fantasy VIII fonts width
« Reply #2 on: 2013-12-16 13:30:12 »
So is it possible to import custom fonts this way? If this is the case you should win the qhimm nobel prize for this because you are the only ones who managed to solve this riddle!

myst6re

  • *
  • Posts: 639
  • Light King of the Savegame - Field Master - FF8.fr
    • View Profile
    • FF8.fr
Re: Final Fantasy VIII fonts width
« Reply #3 on: 2013-12-16 18:34:23 »
Interesting.

Agahnim

  • *
  • Posts: 40
  • fourgive mii four baud iinglisch :D
    • View Profile
    • Rom Dom Greece
Re: Final Fantasy VIII fonts width
« Reply #4 on: 2013-12-16 18:46:38 »
awesome Johnny_Doe ! great discovery! now FF8 will be translated into Russian AND Greek language (by LeonhartGR and me). THANX!!

can you please make a guide with pics?
« Last Edit: 2013-12-16 18:57:07 by Agahnim »

Johnny_Doe

  • *
  • Posts: 7
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #5 on: 2013-12-16 21:37:50 »
Guys, first of all I should apologize because I wrote "divided" instead of "multiplied". That was my mistake because I looked at the example and decided to change the operation name because of my lack of knowledge. An hour later I was explained that I was wrong, so I've fixed the post.  Now everything should be correct.

Secondly, all the congratulations should be addressed to our programmer, whose nickname on forum is "Equilibrium Keeper". I'm just a guy who spent five years translating the script itself. It would be a waste of time if not for two people who helped me to proofread the text. Translation for me is interesting because it gets better with time going. I wish all of you guys to finish your projects because this game is my favorite one and it means a lot to me. If anybody is interested, you're welcome to visit "consolgames.ru".
Johnny_Doe.

UPD: I was asked to write here the following: "The best way to customize the width table is to use the "Cheat Engine", because you can see the changes you make in real time. It can be executed in windowed mode with "D3DWindower": http://f-page.ru/fp/8659674e05d54cbaab874cdf264d6434
« Last Edit: 2013-12-16 21:48:04 by Johnny_Doe »

LeonhartGR

  • *
  • Posts: 2577
  • ~Whatever...~ Enjoy life!
    • View Profile
    • LeonhartGR Productions
Re: Final Fantasy VIII fonts width
« Reply #6 on: 2013-12-16 23:07:52 »
...this game is my favorite one and it means a lot to me.

For us as well mate... for us as well! ;)

Johnny_Doe

  • *
  • Posts: 7
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #7 on: 2013-12-18 15:05:37 »
For those who asked for a tutorial, here it is:

1) Unpack ...\FinalFantasy8\Data\main.fs archive to get  \Data\eng\sysfnt.tdw file.
2) Unpack ...\FinalFantasy8\Data\menu.fs to get \Data\eng\menu\hires\sysfld00.TEX and \Data\eng\menu\hires\sysfld01.TEX files.
3) Unpack  ...\FinalFantasy8\Data\fields.fs and few more files that are inside. You need any .msd file. The dialogues from those files can be found in the game itself. Edit the dialogues by writing the complete codepage into them. Pack the archive back.
4) Convert TEX to BMP. Redraw the fonts. Put the BMP back into TEX.
5) Open \Data\eng\sysfnt.tdw file in any HEX-editor. You should see the header, something like: 080000006C0000008588888888B847757A779966554494779447898888885887 leave out the beginning, copy the rest (not everything, a small piece should be enough).
6) Download D3DWindower. Tweak the preferences. Launch the game in windowed mode.
7) Download CheatEngine. Hook it to the launched game process.
8 ) Play the game to get to the dialogue you need. You should see some crooked, misaligned letters.
9) Use CheatEngine to find the byte sequence you've copied before. It is most likely that you found only one entry. If it wasn't found, the mistake is either in the value, or it was made during the search (you need to find a byte array, the bytes should be separated with the spacebar symbols).
10) Add the address you've found to the list. Right click on the entry and choose "View in memory" option.
11) That's it. Now it's time to have some fun. You need to change a few bytes from "76" to "7F" - you'll see a huge space appearing after some of the characters. That's the quick way to find the beginning of the alphabet (or you can calculate it by yourself - it's glyph's index / 2) and then you can start adjusting the symbols width to make it look pretty.
12) After getting the result you want, copy your changes from Cheat Engine to \Data\eng\sysfnt.tdw. file. Save them. Pack the file. Launch the game and be happy.

Caution: It is STRONGLY recommended to copy your changes as often as possible, and not after everything is done, or use PrintScreen - when the game's closed or crashed (by accident) its memory will be unloaded and your changes will be gone so that you'll have to start it all over again.
One more thing: D3DWindower intercepts any key pressed even if its window is not active at the moment (or maybe it's just me who messed up the preferences), so it would be better to remap the keys which are responsible for in-game choice (to avoid a dialogue being closed) to some "safer" ones" which you won't press by accident (you will press them though, but who knows?)
A piece of advice: When changing values in memory, CheatEngine displays them in decimal format, so that "FF" value will be displayed as "255". But the font width data takes only half of a byte which is pretty inconvenient. BUT! It allows to enter the data in hexadecimal format. Thus if one symbol is floor(8*1,67) pixels wide and the other is floor(10*1,67), you won't need a calculator with bit offset support. You just have to write it the way it is: 0xA8 (don't forget the least significat bits are the 1st symbol, the most significant bits are for the next symbol).

Agahnim

  • *
  • Posts: 40
  • fourgive mii four baud iinglisch :D
    • View Profile
    • Rom Dom Greece
Re: Final Fantasy VIII fonts width
« Reply #8 on: 2013-12-18 22:43:34 »
here are the places (in hex editor) of widths of almost every character of font:

08 = 0SPACE
09 = 21
0A = 43
0B = 65
0C = 87
0D = %9
0E = :/
0F = ?!
10 = + @
11 = - @
12 = @@
13 = @@
14 = )(
15 = . @
16 = @ ,
17 = "(I) @
18 = @ '(I)
19 = '(O) @
1A = A @
1B = CB
1C = ED
1D = GF
1E = IH
1F = KJ
20 = ML
21 = ON
22 = QP
23 = SR
24 = UT
25 = WV
26 = YX
27 = aZ
28 = cb
29 = ed
2A = gf
2B = ih
2C = kj
2D = ml
2E = on
2F = qp
30 = sr
31 = ut
32 = wv
33 = yx
34 = @z


@ means 'width for unknown character'
(I) mean IN
(O) means OUT



very usefull informations if anyone want to change widths
« Last Edit: 2013-12-18 22:49:38 by Agahnim »

Agahnim

  • *
  • Posts: 40
  • fourgive mii four baud iinglisch :D
    • View Profile
    • Rom Dom Greece
Re: Final Fantasy VIII fonts width
« Reply #9 on: 2013-12-18 22:47:18 »
here are a hex-to-pixels converter for ff8 widths:

0 = 00px
1 = 01px
2 = 03px
3 = 05px
4 = 07px
5 = 09px
6 = 10px
7 = 12px
8 = 14px
9 = 15px
A = 17px
B = 19px
C = 20px
D = 22px
E = 24px
F = 25px

LeonhartGR

  • *
  • Posts: 2577
  • ~Whatever...~ Enjoy life!
    • View Profile
    • LeonhartGR Productions
Re: Final Fantasy VIII fonts width
« Reply #10 on: 2013-12-19 00:03:39 »
That's a lot of progress! Thanks!

Aavock

  • *
  • Posts: 303
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #11 on: 2013-12-21 16:11:16 »
Thanks Johnny_Doe, very interesting information.

I just noticed that all 4 "iconfl" menu textures in data\eng\menu\hires\ are inexistant in the french version (not sure about german, spanish and italian version but I'm pretty sure they don't exist either) so I was trying to re import a 200% resized texture. I try using Omega after resizing to 512x512px the "face_b00.tex" file but the size remains the same (256x256px):



Not sure but in the header, right before the palettes:

Texture weight:
0x3C = 80 00 = 128px
0x3C = 00 01 = 256px

Texture height:
0x40 = 80 00 = 128px
0x40 = 00 01 = 256px

So my guess for a 512x512px texture was 0x3C = 00 02 and 0x40 = 00 02 but Hyne is not showing the texture preview and the game will eventually crash. Does anyone have an idea on how to import resized *.tex files ?

Agahnim

  • *
  • Posts: 40
  • fourgive mii four baud iinglisch :D
    • View Profile
    • Rom Dom Greece
Re: Final Fantasy VIII fonts width
« Reply #12 on: 2013-12-21 17:10:00 »
you can convert image to tex with a hex editor

1) flip vertical and save the image you want to convert
2) in hex editor, open the image you want to convert and the iconfl.tex
3) compare the two files and you see that they have almost the same bytes except the header
4) now you must delete the header of the bitmap and copy the header of the tex to the bitmap

i hope that helps

Aavock

  • *
  • Posts: 303
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #13 on: 2013-12-21 20:43:16 »
But the texture sizes are in header, right ?

Somehow, I've managed to import a 512x512px resized icon.tex (the one the french version uses) in Deling 0.7b. The weight and height adresses from previous post are correct but the game still crash at the main menu, probably due to the fact that the texture lost his transparency and/or palettes?

Oddly, Omega only show one color palette (the first one) in the original icon.tex...


Agahnim

  • *
  • Posts: 40
  • fourgive mii four baud iinglisch :D
    • View Profile
    • Rom Dom Greece
Re: Final Fantasy VIII fonts width
« Reply #14 on: 2013-12-21 22:23:15 »
i dont think the problem is the transparency loss  neither the missing palettes. when i was having font convertion issues in ff7 (transparency loss/missing palettes)i could start the game but the text was always white due to the missing palettes.


what i suggest: convert a new iconfl.tex to .bmp and resize it with photoshop (not with paint or other image editors cause they have different type of saving system and may compress the file and corrupt the bytes)

Kaldarasha

  • *
  • Posts: 2449
  • Prince of Model Editing
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #15 on: 2013-12-21 22:33:52 »
Iros has made a nice tool for the tex files. It converts the images in png.
http://forums.qhimm.com/index.php

Aavock

  • *
  • Posts: 303
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #16 on: 2013-12-21 22:47:32 »
You mean TexTool Kaldarasha? All I get is "Unhandled Exception" using it; I also tried another Tex tool by Ficedula and I get "Acess violation" notification.

It work like a charm with FFVII Agahnim, I think all those tools were mainly tested with FFVII, the textures format are the same but the headers structure seems to be slightly different for FFVIII. At least I can get a resized texture preview on Deling wich is a good sign so far; maybe Johnny_Doe's team can provide new information.

LeonhartGR

  • *
  • Posts: 2577
  • ~Whatever...~ Enjoy life!
    • View Profile
    • LeonhartGR Productions
Re: Final Fantasy VIII fonts width
« Reply #17 on: 2013-12-22 00:59:58 »
If someone is using the upscaled menu mod I noticed that we need to edit the files inside the mod folder as well since it's reading through that path...
Final Fantasy VIII\mods\mods\data\eng\menu

Aavock

  • *
  • Posts: 303
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #18 on: 2013-12-22 03:51:55 »
I was able to import the resized 512x512 icon.tex using the correct header but the game is preserving the 256x256px X,Y positions; this is how it looks:


Aavock

  • *
  • Posts: 303
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #19 on: 2013-12-30 16:57:58 »
Nothing new yet but I'm uploading the upscaled face_b00.tex (colors doesn't matter at this point) for anyone who want to try to re-import correctly upscaled textures.

Tools:
Deling v0.7b
Omega v1.3b

Texture weight:
0x3C = 00 02 = 512px (already done)

Texture height:
0x3C = 00 02 = 512px (already done)

The issue is that the texture is preserving the 256x256px X,Y axis:


Yugisokubodai

  • *
  • Posts: 42
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #20 on: 2014-02-04 02:31:44 »
This post is useful for me as my translation has trouble with the font width.

I did as your tutorial, change the font width with Cheat engine, and it worked!
However, as you mentioned in the post that 2 characters share the same bite of width value. So if I change one value, it does not only work for 1 character but also affect the next character.

For example, in my translation the character "p" is next to "q", and the "p" has more space behind it. If I write the word "Ipsent q uit" it looks like "Ip sent q uit". So I reduced the space behind "p" by changing the width value bite. But then the "q" become too narrow to. So now the word become "Ipsent quit", which reduce the width of both "p" and "q".

Is there anyway just to change value for just one character?

Yugisokubodai

  • *
  • Posts: 42
    • View Profile
Re: Final Fantasy VIII fonts width
« Reply #21 on: 2014-02-04 09:51:18 »
Oh I just figured it out how to solve this. :P