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

Author Topic: Blurry text  (Read 2856 times)

0 Members and 1 Guest are viewing this topic.

chris67

  • Newbie
  • *
  • Posts: 12
    • View Profile
Blurry text
« on: December 30, 2009, 12:33:49 am »
I am using 640 x 480 x 32 bit mode and so I use small .ttf fonts, but when I blit them to the screen there is some kind of automatic AA done to them which makes them blurry and ruins the readability.

For example, at 12 pt it looks like this ( enlarged 3x ):



I tried to use this command to turn off blending:

SetBlendMode( sf::Blend::None );

But when I do that I get this ( enlarged 3x ):



Any help would be appreciated.

Here is my code

Code: [Select]


FontClass::FontClass( char *filename, int s )
{
    size = s;

    if( !( font.LoadFromFile( filename, size ) ) )
    {
        char errormsg[200];
        sprintf( errormsg, "Failed to load - %s", filename );
        DisplayError( errormsg );
    }
}

FontClass::~FontClass()
{
}

// function to draw the font
void FontClass::DrawFont( char *text, int x, int y, int cx, int cy )
{
    sf::String Txt( text, font, size );

    Txt.SetPosition( float ( x ), float( y ) );

    App.Draw( Txt );
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurry text
« Reply #1 on: December 30, 2009, 01:09:10 am »
Without blurring it's even worse. What does 12 pt corresponds to, in pixels?
Laurent Gomila - SFML developer

chris67

  • Newbie
  • *
  • Posts: 12
    • View Profile
Blurry text
« Reply #2 on: December 30, 2009, 02:04:14 am »
Quote from: "Laurent"
Without blurring it's even worse. What does 12 pt corresponds to, in pixels?


Ya why is it just blocks of white with sf::Blend::None?

I think 12 pt means 12 pixels, or close anyway.

I turned it down to 7 pt and here is the result ( not enlarged ):



Much clearer, but there is still some blending. The font is about 5 x 5 pixels in most spots.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Blurry text
« Reply #3 on: December 30, 2009, 02:09:10 am »
Quote from: "chris67"
Quote from: "Laurent"
Without blurring it's even worse. What does 12 pt corresponds to, in pixels?


Ya why is it just blocks of white with sf::Blend::None?

I think 12 pt means 12 pixels, or close anyway.

I turned it down to 7 pt and here is the result ( not enlarged ):



Much clearer, but there is still some blending. The font is about 5 x 5 pixels in most spots.
I don't know about anyone else, but I don't see any blurring.
I use the latest build of SFML2

chris67

  • Newbie
  • *
  • Posts: 12
    • View Profile
Blurry text
« Reply #4 on: December 30, 2009, 02:11:57 am »
Quote from: "OniLink10"
I don't know about anyone else, but I don't see any blurring.


Look again. It's better when it's at 7pt, but it still blurs. Here's an enlarged version so you can see it better.



Nevermind I fixed it. I just had the pt size too large.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Blurry text
« Reply #5 on: December 30, 2009, 10:52:22 am »
It has nothing to do with blending, the blend mode controls how the pixels are blended according to their alpha or color channels. What produces this antialiasing is a combination of a flag used to generate the glyphs, and Image::SetSmooth (which is not accessible for the font's image).

Can you show your original 12 pt text at scale 1:1?
Laurent Gomila - SFML developer

 

anything