Hello Guest

Author Topic: Getting fonts to look perfect  (Read 8905 times)

fkassad

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Getting fonts to look perfect
« on: May 10, 2013, 11:33:57 pm »
I've followed the tutorial for preparing fonts. I'm using BMFont to take a .ttf font I've downloaded to create the bitmap font used by 2d toolkit.  I can't get it to look exactly as it is advertised on the site I downloaded it from.  This seems to be a problem with any font I try.   Here is an example and I attached an image to show you what I'm seeing in game.

http://www.theleagueofmoveabletype.com/fanwood

I have a feeling it has to do with how BMFont is outputting the font.  I've tried various different settings including font smoothing, super sampling, render from truetype outline, but can't seem to get it just right.

Some of the basics that I made sure of in Unity:
1. TextMesh (x,y) positions fall on whole numbers.
2. Using Point filtering in the sprite collection for my fonts.  (Should the source texture for the separate bitmap fonts also be set to Point?)  I actually think bilinear filter made it look better, but enabling this resulted in characters tops/bottoms getting cut off by a couple pixels.
3. I'm using tk2d Camera and I ticked the checkbox for "use tk2d camera".
4. Mip maps are not getting generated

I'm not building to a device by the way.  I'm seeing these results in the Game window in Unity.  Also, when I view the font .ttf in a different font program designed for testing out fonts, they do look perfect.  Could the tk2d shader I've selected on the atlas material also be affecting it?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Getting fonts to look perfect
« Reply #1 on: May 10, 2013, 11:44:10 pm »
Shader can't be affecting it. The shader doesn't do anything really apart from output the texture.
Try this with the old way of importing fonts (without importing into a sprite collection), just to confirm that that what you're seeing is in the texture.

Also drag the texture onto a quad in Unity. I suspect you'll see exactly what you see there.

It looks like bmfont is softening up the font somewhat. Not sure what to do about that - if you have a Mac you could try importing with glyph designer to see what you get there?

fkassad

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Getting fonts to look perfect
« Reply #2 on: May 11, 2013, 04:42:34 am »
I'm not sure if it's possible to get the characters to look exactly the way I want at lower font sizes.  At larger fonts they do look correct.  Which makes sense since each glyph contains more pixels to get all the detail out of it.  I probably will just have to tinker around and find the optimal settings in BMFont Generator by super sampling at smaller font sizes.

(Extra reading for anyone interested: http://blog.felixbreuer.net/2011/07/27/fonts.html )

unikron are you familiar with the issue I was referring to before about bilinear filtering causing glyphs to get cut off at the top and bottom?  Probably nothing you can do with 2dtoolkit regarding this.  BMFont gives the coordinates of the glyph, and enabling bilinear filtering in unity will alter the texture given by bmfont without reconfiguring the xml coordinates in the bmfont, thereby making some of the characters look cut off.
« Last Edit: May 11, 2013, 05:00:49 am by fkassad »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Getting fonts to look perfect
« Reply #3 on: May 11, 2013, 02:43:59 pm »
Unsure about the bilinear issue - It shouldn't clip under normal circumstances. I've seen it happen occasionally when inadvertently downsampling without mipmaps, eg. when the game window is smaller than the needed pixel size in Unity.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Getting fonts to look perfect
« Reply #4 on: May 11, 2013, 02:45:49 pm »
Also, font rendering on Windows uses ClearType, which uses subpixel rendering which is display dependent (as the doc points out). Its not possible to use bitmap fonts in this manner.