Jump to content


Photo

Ported font code from Doom3 BFG Edition

fonts localization bfg charsets translations

  • Please log in to reply
59 replies to this topic

#26 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 09 September 2013 - 01:50 PM

Thanks for sharing! Have you checked the stuff I sent you to see what needs to be adjusted to make sure font will be the same in BFG as original font?

#27 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 10 September 2013 - 12:09 AM

Yes. My font has different ascender, descender and scale. But how to compute those values exactly as idFont does - I'll have to dig some more.

#28 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 12:14 AM

Understood. I wish they supplied debug version of idFont.exe. Then I would be much easier to figure it out :P

#29 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 01:06 PM

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, 10 September 2013 - 01:41 PM.


#30 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 10 September 2013 - 04:35 PM

I've uploaded your font's .dat file here:
https://drive.google...SVU&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...Z00&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.

#31 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 04:42 PM

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-sto...omparison_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, 10 September 2013 - 04:57 PM.


#32 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 05:02 PM

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, 10 September 2013 - 05:07 PM.


#33 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 05:18 PM

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, 10 September 2013 - 05:20 PM.


#34 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 05:35 PM

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

http://www.steel-sto...omparison_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..

#35 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 10 September 2013 - 05:58 PM

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.

#36 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 06:24 PM

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?

#37 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 10 September 2013 - 06:36 PM

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, 10 September 2013 - 06:38 PM.


#38 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 10 September 2013 - 06:40 PM

Yeah, I am not complaining :)

What would be cool is if you could also generate Doom 3 .dat files in one run. Does it make any difference how Doom 3 .dat files were made as long as it's from the same TTF/OTF file?

#39 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 12 September 2013 - 06:42 PM

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.

#40 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 12 September 2013 - 06:47 PM

Do you still use old .dat files ?

#41 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 12 September 2013 - 06:49 PM

I use old .dat files to read information about their size. Then I save it on the side in a helper file, and don't use old .dat files ever again, for anything.

#42 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 12 September 2013 - 06:54 PM

So it isn't like in BFG, 3 old .dat files, 1 new .dat file and 1 new TGA atlas ?

#43 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 12 September 2013 - 07:24 PM

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?

#44 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 12 September 2013 - 07:45 PM

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.

#45 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 12 September 2013 - 07:55 PM

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.

#46 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 12 September 2013 - 08:00 PM

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?

#47 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 13 September 2013 - 12:39 PM

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.

#48 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 13 September 2013 - 12:42 PM

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.


Gotcha. Can you add an option to your tool to generated old Doom 3 .dat files? This way there is no need to run yet another tool to get vanilla Doom 3 fonts.

#49 Zbyl

Zbyl

    Member

  • Member
  • PipPip
  • 37 posts

Posted 13 September 2013 - 01:06 PM

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, 13 September 2013 - 01:07 PM.


#50 motorsep

motorsep

    Advanced Member

  • Member
  • PipPipPip
  • 884 posts

Posted 13 September 2013 - 01:37 PM

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.





Also tagged with one or more of these keywords: fonts, localization, bfg, charsets, translations

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users