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

Author Topic: how to disable font smoothing  (Read 5988 times)

0 Members and 1 Guest are viewing this topic.

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
how to disable font smoothing
« on: August 15, 2011, 05:33:39 pm »
Can somebody tell me how can I set smoothing of font to false please?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
how to disable font smoothing
« Reply #1 on: August 15, 2011, 05:41:29 pm »
search > instantaneous answer > http://www.sfml-dev.org/forum/viewtopic.php?p=35073&highlight=font+smooth#35073 for sfml 2.0

Please refer to the rules
SFML / OS X developer

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
how to disable font smoothing
« Reply #2 on: August 15, 2011, 07:01:36 pm »
Sorry, I tried mentioned solution, but it doesnt work, please can you check my code?

Code: [Select]

sf::Font myfont;
myfont.LoadFromFile("courier.ttf");
((sf::Texture&)myfont.GetTexture(12)).SetSmooth(false);
sf::Text Text(str,myfont,12);
Text.SetColor(sf::Color(0,0,0));
Text.SetPosition(150,3);
App.Draw(Text);

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
how to disable font smoothing
« Reply #3 on: August 18, 2011, 08:21:26 am »
Please try it someone  :cry:

Aremion

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • http://mr--x.bplaced.de
how to disable font smoothing
« Reply #4 on: August 22, 2011, 07:24:48 pm »
I've done it this way:

const_cast<sf::Texture&>(myfont.GetTexture(12)).SetSmooth(false);

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
how to disable font smoothing
« Reply #5 on: September 11, 2011, 06:54:43 pm »
it doesnt work, but thanks for effort  :(

maybe I have mistake in my other code
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <ctime>
#include <cstdlib>

char str[5] = "HIJK";

void Generate()
{
    str[0] = ' ';
    srand(time(0));
    while(!((int(str[0]) > 47 && int(str[0]) < 55) ||
            (int(str[0]) > 64 && int(str[0]) < 88) ||
            (int(str[0]) > 96 && int(str[0]) < 120)))
    str[0] = char(rand() % 124);
    str[1] = char(int(str[0])+1);
    str[2] = char(int(str[1])+1);
    str[3] = char(int(str[2])+1);
    str[4] = '\0';
}

void Write(sf::RenderWindow & App)
{
    sf::Font myfont;
    myfont.LoadFromFile("courier.ttf");
    const_cast<sf::Texture&>(myfont.GetTexture(12)).SetSmooth(false);
    sf::Text Text(str,myfont,12);
    Text.SetColor(sf::Color(0,0,0));
    Text.SetPosition(150,3);
    App.Draw(Text);
}

int main()
{
    sf::RenderWindow App(sf::VideoMode(341,45),"Keygen",sf::Style::Titlebar);

    sf::Texture images[3];
    images[0].LoadFromFile("base.png");
    images[1].LoadFromFile("Generate.png");
    images[2].LoadFromFile("Exit.png");
    sf::Sprite sprites[3];
    for(int i=0;i<3;i++)
    {
        sprites[i].SetTexture(images[i]);
    }
    sprites[1].SetPosition(2,23);
    sprites[2].SetPosition(74,23);

    while(App.IsOpened())
    {
        sf::Event Event;
        App.PollEvent(Event);
        int mx = sf::Mouse::GetPosition(App).x;
        int my = sf::Mouse::GetPosition(App).y;

        App.Clear();
        App.Draw(sprites[0]);
        Write(App);
        if(mx >= 5 && mx <= 74 && my >= 24 && my <= 44)
        {
            if((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left))
            {
                App.Draw(sprites[1]);
                Generate();
            }
        }

        else if(mx >= 78 && mx <= 119 && my >= 24 && my <= 44)
        {
            if((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left))
            {
                App.Draw(sprites[2]);
                App.Close();
            }
        }
        App.Display();
        sf::Sleep(0.001);
    }

    return 0;
}

 

anything