SFML community forums
General => Feature requests => Topic started 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
FT_Glyph_To_Bitmap(&Glyph, FT_RENDER_MODE_NORMAL, 0, 1);
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
-
I'll look into that, but it's low priority so after SFML 2.0.
-
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
enum FontAntiAliasing {
AntiAliased, //default
NotAntiAliased
}
-
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 ;)
-
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
-
In MONO mode, a pixel is packed in a single bit instead of a byte.
The formula becomes:
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)