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.


Topics - Cleroth

Pages: [1]
1
Graphics / Glitch on font rendering (subpixel) and workaround
« on: June 13, 2013, 02:37:21 pm »
I've been trying to render text on SFML with fractional positions, and it all worked fine except for some white pixels appearing at the top left of each glyph:


I thought it was the texture bleeding from another part of the font texture, but I increased the padding and it didn't help.

I found a workaround which offsets the top boundary of the glyph by +1, at Text::updateGeometry:
int left   = glyph.bounds.left;
int top    = glyph.bounds.top+1;
int right  = glyph.bounds.left + glyph.bounds.width;
int bottom = glyph.bounds.top+1  + glyph.bounds.height;

float u1 = static_cast<float>(glyph.textureRect.left);
float v1 = static_cast<float>(glyph.textureRect.top+1);
float u2 = static_cast<float>(glyph.textureRect.left + glyph.textureRect.width);
float v2 = static_cast<float>(glyph.textureRect.top+1  + glyph.textureRect.height);

I'm not entirely sure if this code is correct, it probably cuts off a part of the glyph or something, but so far I haven't seen anything noticeable in my fonts. It's certainly better than having a conspicuous pixel at the top left of nearly every glyph.

After spending three hours for a fix to this problem I'm content with this solution, but I believe the real problem probably lies within Font::loadGlyph. It would be nice to see it properly fixed.
Other than that... I'm having a great time using SFML. I moved from a different engine to this and I don't regret it.

Also, it would be nice having text alignment in hand.

Thank you!

Pages: [1]