Jump to content
The Dark Mod Forums

Ported font code from Doom3 BFG Edition


Zbyl

Recommended Posts

I experimented some with exporting font from BMFont, and I think I matched the size of original BFG glyphs. Could you please try converting my test and upload .dat file for me to test, as I don't have C# to compile your code ?

 

http://www.steel-sto...bft_an_test.zip

 

Thanks.

 

EDIT: Afaik BFG's dat file has no info about kerning, as it relies on kerning in Doom 3 .dat files. But I might be wrong.

Edited by motorsep
Link to comment
Share on other sites

I've uploaded your font's .dat file here:

https://drive.google.com/folderview?id=0B0pkDNTfAmoeOUZRWkYxMzBOSVU&usp=sharing

It does not match the parameters in original font from BFG exactly: descender is -10, in original it's -11. But descender is not used in font rendering. So the output, hopefuly, will be the same.

 

I've also created my own, alternative, parameters. My font is here:

https://drive.google.com/folderview?id=0B0pkDNTfAmoeRktUOElCRHlRZ00&usp=sharing

I think it's slightly worse (ascender is 46 instead of 45 - but ascender is actually used during rendering), but you can check it out too.

It has bigger spacing (4 pixels) so there should be no "boxing" artifacts.

 

I don't think we can get any better results with BMFont (it supports only integer font sizes). But I don't think it's needed.

 

I'm pretty sure you can compile my tool using VS2010 Express, or using gcc under Linux (should work on Mono without problems... except for the optional ImageMagick stuff).

I've also uploaded my tool under the first link. It's not overly useful, though.

Link to comment
Share on other sites

What I did was exporting bunch of variants and matching glyph heights. So the TGA atlas I provided matched the output produced by idFont +-1 px. So now what's important is to produce proper .dat file. It will not match exactly with the one produced by idFont. But as long as all relevant info is in it, it should work.

 

Also, BMFont has size in pixels. Pixels can't really be float ;) 1px is 1px So the atlas is file. It's how you convert fnt file into dat file.

 

EDIT: Almost there ! Awesome results: http://www.steel-storm.com/files/d3bfg_ArialNarrow_font_comparison_A.zip

 

Next, I am going to test with your alternative variant (the screenshots are with my atlas and dat file you generated using my .fnt)

Edited by motorsep
Link to comment
Share on other sites

Hmm.. Tried your font, no good: http://i.imgur.com/9pF5AA4.png

 

Oh, you need alpha to be "glyph" and RGB "one".

 

Got some interesting info, I hope it'll help: "The BFG (and Rage) font system is relatively simple. The exporter is only a few hundred lines total. It doesn't use kerning information at all. Each glyph just has an x, y, width, height, and an xSkip value. I believe the ascender/descender data from the font is not used, but rather it's calculated manually, but I don't remember for sure anymore."

Edited by motorsep
Link to comment
Share on other sites

The tool crashes on me :/ Windows 7 Pro 64-bit.

 

I run it like this:

 

BFGFontTool.exe create-bfg --bmfont=48.ftn --bfgfont=48.dat

 

and it crashes.

 

Problem signature:

Problem Event Name: CLR20r3

Problem Signature 01: bfgfonttool.exe

Problem Signature 02: 1.0.0.0

Problem Signature 03: 522f8c93

Problem Signature 04: mscorlib

Problem Signature 05: 4.0.0.0

Problem Signature 06: 517a19ee

Problem Signature 07: 3fdf

Problem Signature 08: 106

Problem Signature 09: System.IO.FileNotFoundException

OS Version: 6.1.7601.2.1.0.256.48

Locale ID: 1033

Additional Information 1: 5459

Additional Information 2: 545966238c284c903ff7bf1c4854787d

Additional Information 3: d0e7

Additional Information 4: d0e77fdc64f7c284b4b14bb145b02665

Edited by motorsep
Link to comment
Share on other sites

Well, I did some GIMP magic to get atlas to be 32bit with alpha, and I think you nailed it man!

 

http://www.steel-storm.com/files/d3bfg_ArialNarrow_font_comparison_B.zip

 

Seems identical :)

 

Now it would be nice for the tool not to crash ;)

 

P.S. All I have is VS2010 Express. I never worked with C# so I wouldn't know what dependencies it needs and so on..

Link to comment
Share on other sites

Not exact yet. Close enough though. (We should probably generate fonts from outline and turn off true type hinting.)

As for your error: FileNotFoundException. Maybe "48.ftn" should be "48.fnt"? Also you could try giving absolute paths to make sure.

 

I'm satisfied with the outcome so far. I'll try to do some TDM coding to try and make new fonts visually compatible with the old ones.

Link to comment
Share on other sites

Ok, you got me :) Everything works now that I typed file name correctly :) (with relative paths) Great job!

 

The only thing that doesn't match is one line in PDA (I haven't gotten deep into BFG to test every textual thing).

 

Instead of:

 

"assistance. I hope that you can find the time to

take advantage of some of our great staff"

 

it goes as:

"assistance. I hope that you can find the time

to take advantage of some of our great staff"

 

Any idea why is it happening?

Link to comment
Share on other sites

Such one-pixel-here-and-there inaccuracies are bound to happen. idFont and BMFont render the fonts slightly differently. id uses it's own font rendering and BMFont uses standard Windows rendering. Things like antialiasing type, hints, clear type etc. will produce slightly different results. There's no way to copy idFont's output with bit-to-bit precision. What we have is probably as close as we can get. And it's close enough IMHO.

 

Edit: "to" word in the next line is a result of such one-pixel inaccuracies.

Edited by Zbyl
Link to comment
Share on other sites

What I've done so far:

- ported BFG font rendering code to D3,

- ported "stone" font to D3 BFG format,

- implemented compatibility functions to adjust font scale,

- potrted BFG LangDict to D3 so all languages now support Unicode.

 

Here's a link to the picture (I don't have permission to insert an image):

https://docs.google....dit?usp=sharing

 

There a two problems that I can see:

- in main menu and on lists of missions some letters have descenders cut (problem with font scale?),

- in main menu the character "o with accent" is weirdly positioned.

I haven't yet compared it with the unmodified TDM.

Link to comment
Share on other sites

It's either:

- 3 old .dat files, 1 new .dat file and 1 new TGA atlas,

or:

- 1 new .dat file, 1 new TGA atlas and 1 new "legacy_sizes.dat" file.

Both work.

 

If compatibility was not a problem then I'd do a much cleaner solution without "legacy_sizes.dat" nor old .dat files. But it seems it's out of question. However - for any new fonts the compatibility layer will be bypassed. It'll be much easier for font makers and gui designers.

 

BTW.: Is it possible to get the stone font in TTF or OTF format?

Link to comment
Share on other sites

If compatibility was not a problem then I'd do a much cleaner solution without "legacy_sizes.dat" nor old .dat files. But it seems it's out of question. However - for any new fonts the compatibility layer will be bypassed. It'll be much easier for font makers and gui designers.

 

Hmm... Doesn't BFG's dat file miss some info? I wonder if I can use only BFG's .dat and atlas for new GUIs for BFG engine.

 

I guess the reason I am wondering is that GUI Editor work with old font system.

Link to comment
Share on other sites

BFG uses old .dat files for one thing only: taking the maxCharWidth and maxCharHeight from them. Nothing else. 100% certain.

BFG fonts are self contained.

Old maxCharWidth and maxCharHeight are used to figure out how to scale the new font to be the same size as the old font. Nothing else.

Rendering dosen't use old .dat files at all.

If GUI Editor uses old font system - then it's probably because it wasn't updated. After all Doom 3 BFG uses Flash for all new GUI, and the scaling-compatibility-layer ensures that even GUI made with old editor will display properly in game.

Link to comment
Share on other sites

No, BFG uses Flash only for full screen GUIs and I don't even think it uses .dat for Flash (probably embeds TTF/OTF into SWF). In-game surface GUIs are same as they used to be, just use new .dat and image for fonts.

 

Also BFG has no tools at all. So I would have to update idTech 4 with new fonts code for GUI Editor begin using it (which I have no idea how to do). Unless I can use same old Doom 3 to make GUI, but then use only new ,dat and TGA with that GUI in BFG.

 

So are you saying font size in .gui will make engine scale BFG's font to that size regardless of presence/absence of old .dat files?

Link to comment
Share on other sites

No, BFG uses Flash only for full screen GUIs and I don't even think it uses .dat for Flash (probably embeds TTF/OTF into SWF).

I know it uses Flash for menus, and old GUI for surfaces. But in both of them it uses .dat files exclusively. No TTFs, nor OTFs are used.

 

Unless I can use same old Doom 3 to make GUI, but then use only new ,dat and TGA with that GUI in BFG.

Old Doom GUI made with old tools will work with new fonts. Wheather they will work in Doom 3 BFG out of the box - probably. But that's another matter, which I'm not concerned with at the moment.

 

So are you saying font size in .gui will make engine scale BFG's font to that size regardless of presence/absence of old .dat files?

No. What I'm saying is this: either old .dat files, or new legacy_sizes.dat file is necessary for fonts to be scaled properly.

Link to comment
Share on other sites

For TDM it would not be necessary. Old fonts can be changed into BFG fonts with legacy_sizes.dat. And new fonts will have auto-generated legacy_sizes.dat files.

 

Moreover some font files, like stone font for example, do not adhere to the specification. They have a hack embedded to circumvent old .dat file limitations. It would be counter-productive for me to try and re-implement those hacks.

I could try to make a simple, no-hack, exporter - but I don't see a use for it.

 

Edit: What do you need old Doom 3 fonts for?

Edited by Zbyl
Link to comment
Share on other sites

Edit: What do you need old Doom 3 fonts for?

 

For BFG. Since GUIs are made in old Doom 3 engine using GUI Editor, new font needs to be scaled properly using those old .dat files. And since BFG doesn't support that one legacy_sized.dat and I still need to make more GUIs, I need old fonts.

 

I suppose there is no way around generating old fonts with that ExportFontsToDoom3 tool, since GUI Editor uses the old atlases too.

 

Note: I don't use TDM, I used Doom 3 BFG engine for my game.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 3 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...