Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
I have half the battle won-- I understand the .TEX format, as there really isnt anything there really---
I need help with the .FNT format, which apparently references the .TEX file, and tells the game engine what areas of the 'texture' is associated with what character.
For the interested parties, here is how the .TEX file is constructed:
8 byte header
Raw bitmap image data consisting of: 4 8-bit channels, interleaved
Image size appears to always be a power of 2.
(Daedric font map pixel resolution is 128x128, All other fonts appear to be 256x256)
Photoshop cannot properly parse the files, I think--- I reads the 4 channel RAW data as CMYK, rather than what I think it is-- which is RGBA.
Despite that fact, I can give you the results of what photoshop loads, dumped into easy to view PNG files---
.TEX font map dumps in PNG format
The .FNT file references locations in the TEX file, and makes the necessary associations between characters, and their symbols.
Maybe if I can give these image files out, somebody can be more intuitive than me, in getting the font format broken.
Edited by Wierd (06/14/04 04:25 AM)
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Ok, This is what I know so far about the FNT format-
There is a 12 byte header, followed by the TEX image name, starting on address 0x0000000C.
There is then a difficult to define field of 00 bytes, as this COULD be parts of the data blocks that follow, OR be part of the address space useable by the TEX image name. There are no landmarks in the feild for me to make this decision.
Discernable datablocks begin to appear at address 0x0000015B, and appear to be 56 bytes in length. There appears to be 248 entries.
After the datablocks, there is another very large "00" byte filled feild, which lasts until the end of the file.
The file is ALWAYS 14,632 bytes long.
I am not good at programming-- If somebody would please take this trifle of information, and put it to good use, I would be overhwelmed with joy and admiration.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Interesting problem. The first thing that jumps out at me, looking at the FNT file with a hex editor is the repeating aptern of the number 64 (40 in HEX, or the @ sign in ASCII) every 56 bytes with only zeros (nulls) in between for large parts of the file. My guess is that each 56 byte segment is a letter and the parts with only 64 and a bunch of zeros are the letters the font doesn't have. Some segments also have very minimal data like `A and a then zeros. For example, take a look at about positon 5200 in the daedric font. See that gap? I'm guessing that's X and Y.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
That jumped out at me too-- and I agree- If you cut out most of the "special" formatting characters from the ASCII character set, you end up with 240 some "displaying" characters, which would explain the number of entries.
I now need to know the composition of the data in these 56 byte blocks. I suppose the only thing to do, is to try manipulating an existing font, and seeing what happens?
The Daedric font looks like a good candidate, because of that 'gap', as you mentioned.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Okay, the one field which often has data while the others do not is width. (Which makes sense, since it's the only thing that would be meaningful alone). It's a floating point number and I can made it bigger or smaller, but I figured out what the units are exactly.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
I am glad you had some success with it-- I havent been able to make heads or tails of the data--- Been operating under the premise that character # is based on the position's order in the file, and that the data block references a coordinate value inside the TEX bitmap-- but none of the values made any sense.
So you say it is a float value, and that the first one is width? That would make some sense-- X axis is always written first in a coordinate pair-- which would be width.
Again, I am not good at programming-- I am trying to dissect the file format, so that somebody else can pick up the pieces, and just start writing.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
It's width in terms of how much space it takes up on a page anyway. I don't know how this relates to which slice of the TEX file it uses, not yet at least. The weird thing is the 56 bytes seems like way to much data for what it has to do. One would assume it stored thet X and Y of the upper left corner of the character, and either X and Y the lower right cover or the height and width. Even if Width ont he page is seperate, adn they used a double precision float for every value (a big waste), that's only 40 bytes.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
hmmm... Some potential ideas here--
Width of character, Hight of character XY coord of top left corner in TEX, XY coord of bottom right in TEX baseline/center of symbol
All that data could be useful with a raster based font. Some of the data in the block could be such things.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Hmm, I just noticed that the field that I said controls width is only for characters that don't exist, the ones with other data have either a 0 or -1 there. Also I think the header (including whatever the fist 12 bytes are, the name and all those nulls) is 300 bytes long, and all the values are 4-byte floats. That's 14 fields per character if true. It still just seems like alot.
P.S. Isn't anyone else going to help us?
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
I made a quick and dirty program for viewing the FNT files a little easier, if anyone else would like to have a go at it. It needs the .NET framework though. I can't make any sense for the first 8 numbers, they're all less than 1. I can only assume they somehow refer to a position in the TEX file, but it's really not clear how.
Since I didn't both to write a readme, I'll just explain it real quick. Extract the exe anywhere, run it, File-->Open , open the FNT file then use Back and Next to browser characters, or type the postion in the box at the bottom, 'A' is 65, just like in ASCII.
The Exit comamnd doesn't work, I forgot to code it , just use the X in the corner of the window.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Thanks Mana! I will see if I can make better sense of this interpereted data---
If I can figure it out, I might be able to try and produce a test version of Daedric font, that has an 'easily' identifiable character for X and Y.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
WTF?? Ok- The hight and width guesses seem accurate-- I just compared the values given, against the actual sizes of the characters in the image dump-- It jives.
Hight and width appear to be in pixels.
Further, it seems that the character order guess is pretty accurate also.
As for the top 8 floats.......... here is what I am suspecting:
I think they are "percentages": Values 1 & 2: Boundy location of top left corner, using % of tex image space as the unit---
(Clarification-- a value of 0.5/0.5, would be the exact center of the image, becase you cut the image in half, then in half again-- 50/50-- get it?)
Values 3 & 4: Boundry location at bottom left corner, same method
Values 5 & 6: Boundy location at Top right corner, same method
Values 7 & 8: Boundy location at bottom right corner, same method
This would explain why the TEX image map must be a power of 2.
EDIT-
After coming up with this speculation, I decided to look at the math, to make sure--
From the few characters I looked at, this appears to be the case- they *ARE* percentages.
For instance, Character number 2, for century gothic bold:
The image location in the TEX map (in pixels) is:
26,160 <-top left 38,160 <-bottom left 26,176 <-top right 38,176 <-bottom right
The values for the 8 floats are:
Top-Left X,Y 0.1015625 0.625
Bottom-left X,Y 0.1484375 0.625
Top-Right X,Y 0.1015625 0.6875
Bottom-Right X,Y 0.1484375 0.6875
In this instance, the TEX image map is 256x256 pixeles-- a perfect square. This makes the math *REALLY* easy--
256 * 0.1015625 = 26 256 * 0.625 = 160
256 * 0.1484375 = 38 256 * 0.625 = 160
256 * 0.1015625 = 26 256 * 0.6875 = 176
256 * 0.1484375 = 38 256 * 0.6875 = 176
Now, my obvious question is--- WHY FRIGGEN PERCENTAGES!? Oh well-- At least I know what they are now.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
bump
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Great! That certainly does make sense, though why they would do it that way eludes me. I wondered if the floats could refer to percentages of the image size, but it didn't guess that it would be as simple as defining each corner. There's still a few values we haven't figured out completely in the body of the FNT file. Mainly the second field I labeled "width?". Of course it could just be junk data. But I guess I can try upgrading my Font Reader to a Font Editor and see if we've really figured it out right.
BTW I see the first 8 bytes of the TEX are height and width (or width and height) of the image. The first 12 bytes of the FNT are a float and 2 integers I think, each 4 bytes long. In these fontsm the float is either 16 or 20 and the integers are always 1.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Yeah, it eludes me also-- I personally would have just defined the pixel coordinates using 1 byte integers--- would have dramatically reduced processing time (since you dont have to calculate the coordinates), and also drastically reduced the file's size.....
Perhaps they had plans on creating 'larger' font maps, and wanted a "one size fits all" approach? (like say, if you had a 4096x4096 TEX map area--- You could still define the areas using the same floating point percentage system, as you use on the 256x256 TEX maps---)
Just a theory though.
I look forward to the next iteration of the "Down and dirty" font viewer, so we can work out the remaining values.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
That was quick an dirty.
BTW, can you think of any reason I shouldn't convert the percentages to pixal positions before displaying them? It seems like it would be alot easier to look at.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Not really--I can't think of any.
What would be the REAL treat-- would be if the font viewer would parse the TEX file, and then display the regions defined by those values--- That would make it LOADS easier to make sure that our character/symbol matching guess is totally accurate.
Edited by Wierd (06/15/04 11:59 AM)
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Uh-oh.
I knew this was too easy. The main attraction of editing fonts would be creating a new one, right? I knew the fonts were listed in Morrowind.ini so I figured it would be easy, but now that I look... Morrowind.ini has the file names, but those aren't the names you use in books. As far as I can tell the association between the two is dreaded words: Hard Coded. The only good news is that one of the fonts, Century Gothic isn't used in any of the original books or menus, only for the console. So if someone wanted to commandeer that for some other use, wouldn't cause any problems as long at it was a readable font.
And yes, I was planing to have the font editor read tex files, but in light of this, do you think it's still worth making?
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
I hex-edited, and even dissassembled morrowind.exe, and could not find any mention towards the low-level font names, OR to the high level ones either.
I think we should probably create the font editor, and create a test font, and see if the game will see it when registered.
That is the best test.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
From what I can tell, (but then again, I am no authority) it looks like morrowind.exe references its fonts by number, rather than by name-- It has a stub to read morrowind.ini, and then enumberates the fonts.
Internally, it seems to rely on font number, rather than font name.
I am honestly in the dark when it comes to how it handles the book text's HTML <FONT> tags....
*EDIT
What do you think would happen, if we used the font number, rather than the font name in the HTML tags?
Edited by Wierd (06/15/04 01:25 PM)
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
My brain's wheels are turning here--
Based on what I saw in the disassembler, this is how morrowind hashes out the high level font names:
It starts reading the file name as a text string, and then hashes that against a naming convention, of which there are a few key-words.
Base font keyword: "regular" Bold font keyword: "big" "non-special" keyword: "font"
The way this is hashed, is like this--- The routine reads the filename as a string, then compares it to an operator that looked like this:
"_%s_%s.fnt"
I suspect that it stores elements between the underscores into string variables, and then uses them to generate the face names on-the-fly. Certain keywords make the font get treated differently, however-- at least that is what I suspect. Should one of the elements in the filename match a keyword, it is omitted from the font face name.
Instances:
Daedric_Font.fnt --> "Daedric" Magic_Cards_Regular.fnt -->"Magic Cards"
So, in theory, if you created a font named "Norse_Runes_Regular.fnt", the game would give it the face name "Norse Runes".
I would VERY much like to create a custom font to test this out.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Well, I'll go ahead and finsih the program, at least a rough version. But in until then (probably tomorrow) couldn't this be tested just by renaming an existing font?
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
probably--- I will test that right now with a renamed Daedric font.
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
ok--- "Bittersweet" news:
Apparently, the game doesnt want to enumerate more than 3 fonts--
I altered the first font line in morrowind.ini to point to my renamed daedric font, instead of magic cards. Lo and behold, all the menus and mouse over text in the game suddenly showed up in the Daedric typeface!
Apparently, the game is hard coded on the font NUMBER, not the font name.
Font #0 is the "Default" font for menus, books, stats, etc.
Font #1 is the console font typeface.
Font #2 is the Daedric font typeface.
I guess for people that dont like the "Magic Cards" font, you can change the Font 0= line to point to a different font, and the game will happily and readily use it.
This just reinforces my view that the game treats the fonts internally as a font number, and not a typeface name-- however, my suggestion on how it hashes the name is apparently incorrect. I moved the entry for my renamed daedric font down on the list to the console position, and tried pointing books to that location, but no success.
*EDIT---
The font names apparently (and sadly) ARE hard coded, but only to the font #. Here is the lineup-
Font 0 = "Magic Cards"
Font 1 = "Century Gothic"
Font 2 = "Daedric"
the "Century Gothic" font *WILL* show up in books, if you directly specify it--- So, using these tools, we can make a better console font, that can also be used in books, just under the name "Century Gothic". It doesnt matter what the filename is, for either the .FNT or the .TEX (just as long as the .FNT references the .TEX properly)
So-- Bittersweet news, but we arent totally hopeless. We can make a better console font replacement! (and put in ALL the euro-accent characters, and common symbols (like the copyright symbol )-- I am sure people would make use of it.
Also, these tools could be useful for people doing total conversion mods, who want to make new typefaces.
Edited by Wierd (06/15/04 03:23 PM)
Post Extras:
|
lochnarus
|
Diviner
|
|
|
Reged: 07/24/03
|
Posts: 2771
|
|
|
|
Quote:
I guess for people that dont like the "Magic Cards" font, you can change the Font 0= line to point to a different font, and the game will happily and readily use it.
That's all I needed to hear. Even if you cant change the menu font (which I've seen done, in screenshots mind you) it's cool that you can change the console font.
Here's some different ones:
.FNT format fonts- about 25 of them
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Yeah, it's not useless, just not as good as I hoped at first. Another nice use would be to make a daedric font with X and Y, and maybe a little punctuation, like Dongle's has.
[Edit] lochnarus, those don't seem to be in the same format, they just happen to share a file extension. (A rather obvious one for fonts I guess.)
Post Extras:
|
|
|
You might want to search this site:
http://www.wotsit.org/
It's a web site that has explanaions of many file formats. I did a quick search within that site:
http://www.wotsit.org/search.asp?s=font
And then it returned a page with many font formats, including the fnt format. Hope this helps.
--------------------
Meanwhile, at the dance party
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Microsoft has a .fnt format, but it is not the same as the morrowind .fnt format.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
A little update on the program: It now reads TEX files and highlights the selected character. Still to do is graphically selecting a block of the TEX file as a character, converting between TEX and BMP (.VB has save and load functions for BMP built in so that shouldn't be too hard) and saving back to the FNT file, again, no big deal, I hope.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Okay, all the basics are done. You can Download it now, but be warned it's... well just be warned. It doesn't come with instructions yet either. I'll work on it more tomorrow and maybe even try to explain how to use it.
It does work though.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Okay, I've fixed it up some (same link). Here's a brief description of how to use it:
First, the easy part. On the tools menu you will fint commands to convert TEX to BMP and BMP to TEX. Bitmaps should be white on black.
The FNT file really isn't that bad either I guess. You just load the FNT (making sure the correct TEX is int he same folder) and then switch to the symbol you want to change, change one or more values, repeat, then File-->Save once you edit all the symbols you want.
There are 3 ways to navigate between simbols. Use the Back and Next buttons, type the ASCII Number between them, or type the symbol (case matters) in the Go To Symbol box.
If you make a mistake you can use Revert Symbol on the Tools menu to restore the currently selected symbol to the last saved version.
The most complicated part is the graphical TEX box. That shows you which part of the TEX goes with the selected symbol, and allows you to change this without fiddling with all the boxes.
To select a symbol from the TEX window. Position your cursor at it's upper-left corner, (note the zoom window above and the crop marks) and click-and-drag down and right until you have the area you want (again the zoom window helps). Once you release the mouse button the text boxes are updated.
I think this tool is just about ready to really use.
By the way, if anyone has an international version of the game, I'd be interested in finding out if your TNF and TEX files are the same.
Edited by ManaUser (06/17/04 01:13 PM)
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
There is a problem with the character selector-
Apparently your program attempts to define character number by the windows ANSI character set, rather than actual DOS ASCII character set. It seems the font itself is geared more toward ASCII than ANSI.
I am in the process of creating a mono-spaced console font replacement, that has *ALL* displayable ASCII characters in it, and discovered this while working. For shits and giggles, I might put in the non-displaying ones too-- like ^C and the like-- but I doubt the game would have much use for such things....
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Hmm, I'm not sure how to fix that. VB doesn't seem to give me the choice to put a textbox in the system font. It works for the regular characters, right? (like A, 3, $, " and so on)
Post Extras:
|
Wierd
|
Adept
|
|
|
Reged: 04/04/03
|
Posts: 342
|
|
|
|
Most of the characters are allright, up until you get to the "accented" characters. I think this starts at around ASCII character 127?
While I personally speak english, and dont live in europe, that isnt the case for everybody-- That is kinda the reason I want to make a font that has *ALL* the accented characters in it, not just a handfull. I have several characters done, but I am having to rely more on windows character map to give me the proper character order....
You might end up having to hard-code the character reference information to make it work though... *sigh*
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
Meh, that's probably what I'll have to do. At least the fonts are in some kind of standard order. When I started I was afraid it would just be a random made up order I'd have to figure out by trial and error.
Post Extras:
|
Coyote
|
Initiate
|
|
|
Reged: 09/14/03
|
Posts: 50
|
|
|
|
Sorry to bump such an old thread, but have you guys made any more progress on the fonts? The progress made so far was great, and the font reader is a nifty tool.
Would it be possible to make the "magic cards" font appear bigger in-game? It gets to be really hard to read at high resolutions.
Post Extras:
|
ManaUser
|
Master
|
|
|
Reged: 06/01/00
|
Posts: 6095
|
Loc: Long Beach, CA, USA
|
|
|
No, 'fraid I haven't done any more work on this. But yes you can make the font bigger. You could either actually edit Magic Cards, or just change the [Fonts] section of Morrowind.ini so it uses a larger font. For example: Change Font 0=magic_cards_regular to Font 0=century_gothic_big
I just tried it and there are a few problems, like how the numbers on the health/magicka/fatigue bars hang down funny, but it would be perfectly playable. Certainly better than not being able to read the text.
Post Extras:
|