Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - war_man333

Pages: [1]
1
Feature requests / Pixelated text
« on: January 04, 2015, 09:19:45 pm »
I'd like an option for text/fonts to be pixelated.
Currently, SFML will always anti-aliase text.
This is how it should be:

This is how it is:

In order to fix this, the source code must be altered, as explained on page two of this thread:
http://en.sfml-dev.org/forums/index.php?topic=17166.0

2
Graphics / Re: Font Aliasing
« on: January 04, 2015, 07:47:53 pm »
I pulled myself together and did it, text looks great now :D
Hopefully it'll be added as an option at some point, otherwise people can look at this thread! :)

3
Graphics / Re: Font Aliasing
« on: January 04, 2015, 05:51:28 pm »
https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L485
FT_LOAD_TARGET_NORMAL -> FT_LOAD_TARGET_MONO

https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L503
FT_RENDER_MODE_NORMAL -> FT_RENDER_MODE_MONO

https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L716
setSmooth(true) -> setSmooth(false)

http://www.sfml-dev.org/tutorials/2.2/compile-with-cmake.php

The compile part looks a bit complicated :(
I'll save it for when I get too tired of the current font-rendering.
Thanks :)

4
Graphics / Re: Font Aliasing
« on: January 04, 2015, 04:24:07 pm »
Quote
So you had to recompile the source?
Yes. Using the mono mode for glyphs cannot be done externally, even with an ugly hack.

Quote
if you mean that it will be added to SFML in the near future.
Don't wait for it. It's not validated, and even if it is, nobody knows when it's going to be implemented.

Alright.. by any chance can you tell me what you changed specifically, and maybe drop a link to where to a recompile guide...?

5
Graphics / Re: Font Aliasing
« on: January 04, 2015, 01:04:11 pm »
Thanks.

To get the pixelated look, I had to disable texture smoothing and render glyphs in mono mode (2-color bitmaps). So this is indeed a case not covered by the latest modifications in sf::Font.

This brings back the idea of providing a "mode" when loading a font: antialiased or pixelated. This could also apply to fonts that are not natively pixelated.

So you had to recompile the source? I guess I'll just work on some other things in my game than text, if you mean that it will be added to SFML in the near future.  :)

6
Graphics / Re: Font Aliasing
« on: January 04, 2015, 12:20:59 am »
Can you provide a complete and minimal example that reproduces the problem?

Try this.
Includes a main and a font.
It's close but it's still blurry.

7
Graphics / Re: Font Aliasing
« on: January 04, 2015, 12:05:43 am »
Is the final position of the text rounded, or decimal?

It's decimal. I see where you're going at, I'll try rounding it. Makes sense.

No effect.

8
Graphics / Re: Font Aliasing
« on: January 03, 2015, 11:57:06 pm »
Quote
My game is enlarged 3 times, so one pixel becomes 9.
That's what causes the problem. Font rendering is exact, and thus not blurry, as long as nothing is stretched. But if one texel = several pixels, texture filtering applies and you get the antialiased result.

The const_cast is an ugly hack, but you can use it to check if disabling texture smoothing would indeed give you the expected result. This would allow us to progress on this issue: if the result is ok then we can discuss the addition of this feature to the public API, and if it's not then it means there's a problem somewhere else that may be fixed / improved.

I tried this, no luck though. It looks exactly the same, blurry.

ScreenText::ScreenText(double posx, double posy, std::string font, sf::Color color, int size, std::string text) : Entity(posx,posy)
{
        x = posx;
        y = posy;
        font_.loadFromFile(font+".ttf"); //LCD_Solid.ttf
        const_cast<sf::Texture&>(font_.getTexture(size)).setSmooth(false);
        text_.setFont(font_);
        text_.setStyle(sf::Text::Regular);
        color_ = color;
        text_.setColor(color_);
        text_.setCharacterSize(size);
        text_.setString(text);
        textAlpha = 255;
        removed = false;
}


9
Graphics / Re: Font Aliasing
« on: January 03, 2015, 09:21:33 pm »
Well, const_casting like that is probably undefined behavior so no surprises.  Even if it did work that'd just be a hack around SFML not providing proper access to that option.

https://github.com/SFML/SFML/issues/254 appears to have a lot of relevant discussion about the actual issue here.

I took at look at this, and if you see the last post, it says 'Since this seems resolved with the latest revision, I'll close the issue.' - but I'm not sure what he means by this. In general, the fix seems to be a hackaround as far as I can see.

10
Graphics / Re: Font Aliasing
« on: January 03, 2015, 09:04:20 pm »
A bit of a blind guess, but since I was browsing the sf::Text code recently and it might save someone some time: Could this be because sf::Font calls setSmooth(true) on the texture it uses to render glyphs? (https://github.com/SFML/SFML/blob/master/src/SFML/Graphics/Font.cpp#L716)  I assume that's correct in most cases but maybe it should be configurable?

How would you access this?

I think they talked about it here, but it didn't seem to work(?)

http://en.sfml-dev.org/forums/index.php?topic=5586.0

11
Graphics / Re: Font Aliasing
« on: January 03, 2015, 08:55:35 pm »
Sorry, it's a small 0 to the top left of the blue guy.
That's exactly the problem, the text is hard to see.

My game is enlarged 3 times, so one pixel becomes 9.
Sadly, so does the antialiased text's pixels, and so it is blurry.

12
Graphics / Font Aliasing
« on: January 03, 2015, 07:48:01 pm »
I'm aware of the fact that there are several threads on this, but all of them seem to end up with either changing source code or someone saying 'this has been fixed in the current revision (2.2)'

So, my problem is that I'm trying to use a bitmap (pixelated) font, but SFML insists on trying to anti-aliase it.

Here's an example:



How do you fix this? I just want oldshool pixelated text without having to create my own bitmap class.

 Thanks in advance.

Pages: [1]