SFML community forums

General => Feature requests => Topic started by: nitram_cero on June 13, 2009, 11:50:23 am

Title: Ability to turn off font antialiasing when rendering glyphs
Post by: nitram_cero on June 13, 2009, 11:50:23 am
I'm requesting the ability to change the rendering mode when loading font glyphs to a texture.
For pixel-based games (i.e. pixellated, "vintage looking", etc.)
As antialiased fonts look bad where everything else is pixelated.

With this parameter, the font's image smoothness should also be disabled (SetSmooth(false))

(this will solve the issue for this other guy in the forum)

"Where to change it":
src\SFML\Graphics\FontLoader.cpp @ 213
Code: [Select]
FT_Glyph_To_Bitmap(&Glyph, FT_RENDER_MODE_NORMAL, 0, 1);

Quote
FT_RENDER_MODE_NORMAL   

This is the default render mode; it corresponds to 8-bit anti-aliased bitmaps.

FT_RENDER_MODE_MONO   

This mode corresponds to 1-bit bitmaps (with 2 levels of opacity).


Example!

(http://i44.tinypic.com/2qjk1p5.png)

Thanks
-Martín
Title: Ability to turn off font antialiasing when rendering glyphs
Post by: Laurent on June 13, 2009, 12:12:33 pm
I'll look into that, but it's low priority so after SFML 2.0.
Title: Ability to turn off font antialiasing when rendering glyphs
Post by: nitram_cero on June 13, 2009, 12:20:53 pm
But it's really really really reaaaaally easy to implement.

The only thing to "define" is the interface, as this should be passed to the loading functions (LoadFromFile, LoadFromMemory)

Define that and I can do it (respecting your coding notations)

maybe an extra optional parameter?

like
Code: [Select]
enum FontAntiAliasing {
    AntiAliased,                   //default
    NotAntiAliased
}
Title: Ability to turn off font antialiasing when rendering glyphs
Post by: Laurent on June 13, 2009, 12:34:55 pm
Quote
But it's really really really reaaaaally easy to implement.

So as many other features. Most of the features to implement in the roadmap would actually take only a few minutes / hours to be done.

I actually spend most of my time thinking about how to add them properly to the public API, rather than implementing them. I don't really like rushing to implement a new feature without making absolutely sure that it's consistent with the rest of the API. Sorry if it's frustrating (I can understand it), but that's how I work ;)
Title: Ability to turn off font antialiasing when rendering glyphs
Post by: SkyGriffin on December 31, 2009, 03:24:55 pm
I wanted to see how it looks without antialiasing so I tried changing:
      Error = FT_Load_Char(FontFace, Charset, FT_LOAD_TARGET_NORMAL);

with:
      Error = FT_Load_Char(FontFace, Charset, FT_LOAD_TARGET_MONO);

and:
      FT_Glyph_To_Bitmap(&Glyph,FT_RENDER_MODE_NORMAL, 0, 1);

with:
      FT_Glyph_To_Bitmap(&Glyph,FT_RENDER_MODE_MONO, 0, 1);

But it doesn't work. All I get is a pixel mess where the non-antialiased text should be. Any idea why? Thanks
Title: Ability to turn off font antialiasing when rendering glyphs
Post by: Laurent on December 31, 2009, 03:28:51 pm
In MONO mode, a pixel is packed in a single bit instead of a byte.

The formula becomes:
Code: [Select]
dest[index] = ((src[x / 8]) & (1 << (7 - (x % 8)))) ? 255 : 0;

(if you don't see where this line of code should go, tell me which version of SFML you use)