Font with outline not rendered correctly

Started by
7 comments, last by WitchLord 9 years, 10 months ago

Hello,

I use a .fnt font created with 1.13 and 1.14 beta versions of BMFont and rendered in jMonkeyEngine.

With both versions I get a visual error when I use outlines and I don't know if this problem is on the Font side or on the jEngine side.

Here you can see the erroneous spacings (see yellow subtitle text and also the h=105.0 text in the upper white text):

https://docs.google.com/file/d/0ByWKJMpxOBKFMkl4blNVcVgtZlk/edit?pli=1

The font that I used is the one you can find here:

https://docs.google.com/file/d/0ByWKJMpxOBKFLWc2RWxsOG5iSTg/edit?pli=1

So I tried using the old "bitmapfonts.exe" from this site: http://www.angelcode.com/dev/bmfonts/

I ran the programm on my old Direct-X-9-Machine and it crashed even before starting. The log.txt holds this information:


acgfx_graphics.|  273|Adapter description: ATI Radeon HD 4800 Series           
acgfx_graphics.|  274|Driver: ati2dvag.dll
acgfx_graphics.|  275|Version: 6.14.10.7200
acgfx_graphics.|  287|Checking graphics capabilities...
acgfx_graphics.|  290|Blending with source alpha              : Yes
acgfx_graphics.|  291|Blending with inverse source alpha      : Yes
acgfx_graphics.|  292|Textures with alpha channel             : Yes
acgfx_graphics.|  295|Max texture width                       : 8192
acgfx_graphics.|  296|Max texture height                      : 8192
acgfx_graphics.|  303|Dynamic textures                        : Yes
acgfx_graphics.|  306|Vertex shader version                   : 300
acgfx_graphics.|  307|Pixel shader version                    : 300
acgfx_graphics.|  310|Number of simultaneous RTs              : 4
acgfx_graphics.|  341|Available render target format: A16B16G16R16
acgfx_graphics.|  341|Available render target format: A2R10G10B10
acgfx_graphics.|  341|Available render target format: A2B10G10R10
acgfx_graphics.|  341|Available render target format: A8R8G8B8
acgfx_graphics.|  341|Available render target format: X8R8G8B8
acgfx_graphics.|  341|Available render target format: X8B8G8R8
acgfx_graphics.|  341|Available render target format: G16R16
acgfx_graphics.|  341|Available render target format: R32F
acgfx_graphics.|  341|Available render target format: G32R32F
acgfx_graphics.|  341|Available render target format: A32B32G32R32F
acgfx_graphics.|  341|Available render target format: R16F
acgfx_graphics.|  341|Available render target format: G16R16F
acgfx_graphics.|  341|Available render target format: A16B16G16R16F
acgfx_graphics.|  341|Available render target format: L16
acgfx_font.cpp |  933|Unrecognized format for 'data/comic24.fnt'
application.cpp|   42|Failed to initialize font 'data/comic24.fnt' (-1)
acframe_applica|  160|Application specific init failed (-1)

So I removed the comic24.fnt font that comes with the test-programm and then it crashed every time after the line with "format: L16".

Can anyone please help?

My next try would be to edit the .fnt text file and add a +6 to each glyph's width (3 pixels of outline) in the hope that this will fix the problem.

If anyone could confirm that the problem is not on my game engine's side but in the created .fnt files, this would help alot - maybe even other users of the angelcode bitmap font generator.

Advertisement

Hi Ogli,

The spacing between characters shouldn't change when adding outline to the characters. Though if your engine is not prepared to render text with outline you'll get the overlap of characters that you're having. To properly render text with outline the engine has to use 2 passes. In the first pass the engine should render just the outline, and in the second pass the engine should render only the glyph. This will make sure the outline stays behind the characters and don't overlap them.

If you can't change the engine to render the font in two passes, then you can manipulate the .fnt file to add a little to the xadvance for each glyph to separate the characters a bit more. (do not change the width).

It's difficult to say from this image only but it does indeed look like the jMonkeyEngine rendering the characters with more overlap that it should. I suspect it is updating the cursor position for each character drawn incorrectly. Most likely it is adding the xoffset to the cursor position but it shouldn't. Only the xadvance variable should be used to update the cursor position (+ possible extra spacing due to kerning pairs).

Thanks for letting me know about the problem with 'bitmapfonts.exe'. It's been ages since I updated that sample. I'll need to revisit it to update it to support the current file format. Perhaps I'll even find the time to implement a proper 2 pass rendering of fonts with outline.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Understood what you wrote and made a workaround for my game:

I created two .fnt fonts - one with outline (font1) and one without outline (font2).

Then, I created two text objects, first text with font1 and second text with font2.

The color of the first text set to black, attach it to the gui graphics of the game.

The color of the second text set to yellow, attach it to the gui graphics of the game.

So, I simulated the "two passes" with overwrites of two different fonts.

Here is an image (see the yellow subtitles):

https://drive.google.com/file/d/0ByWKJMpxOBKFS2lEeDdOYndDWXM/edit?pli=1

It looks good :)

It also proves that there is no error in the logic for the updating the cursor position in the jMonkeyEngine (since both with and without the outline the characters are aligned the same way).

Perhaps you could let the author of jMonkeyEngine know about the need for the 2 pass rendering of text with outline, so you can avoid the need for the work around. :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Okay, I will write a forum post there tomorrow, which will link to this forum post here.

Honestly, I don't know if the original author for .fnt integration is still active in the community. I would fix this myself, if I had the time to work my way through his code.

There are still some visual artifacts when resizing the font, because for whitespace characters his renderer creates a zero-sized quad which then has an outline. Looks very odd when I scale the font up and down, but looks okay for 100% scaling. It might even be, that this particular error is on the .fnt side this time.

I have, however, created my own AngelCodeBMFont class which represents a copy of a .fnt file and can be (de)serialized. This class will be able to merge a current font with another font. For example, my current font doesn't support Arabic, but Chinese+Japanese - so I must mix it with another font. You may remember, that I suggested this once. :)

Yes, I do remember this suggestion, and it is on my to-do list so it won't be forgotten. Unfortunately I do not spend a lot of time with BMFont at the moment, as most of the time goes to AngelScript instead. It is unlikely I'll spend time to implement any complex new feature for BMFont soon.

However, BMFont is now open source (since April, this year), so you could implement this support in the tool yourself if you wish. If you, I'd very much like to see how you do it and perhaps merge the changes into the official version. :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Well, first: This is great news! Basic technologies should be open and I do also write open source software. My current game will be open for example.

I'm now almost done with my Java implementation of the .fnt merge tool, but I don't know if this can be ported to C++ quickly and easily.

I don't know anything about AngelScript. I know Lua and a little bit of Groovy and Python. Is there a Java-port of AngelScript?

FYI: I made a Font-Merge-Thing for jMonkeyEngine. It works, I tested this idea. :)

I don't know of any ports of AngelScript to Java. I'm targetting especifically C++ developers who wish to embed a scripting engine in their application.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement