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

Author Topic: Problems with sf::Text  (Read 2914 times)

0 Members and 1 Guest are viewing this topic.

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
Problems with sf::Text
« on: July 16, 2010, 03:37:28 pm »
Hy,

I'm building some kind of GUI Framework using SFML 2.0 (quite a new revision, less than a week old) and had several Problems with drawing sf::Texts:

These Pictures show the Bug:
Pict1 (Starting Situation)
and Pict2 (After some Text Input)

Problem (as you can probably see) is that the fontsize isn't updated correctly. I haven't been able to Isolate some kind of minimal code reproducing this, I can Upload my code on request.

Has anyone ever have a similar Problem, is it a Bug in SFML 2.0 or what can I do about it?

Thanks ;)

bye, CBenni::O
42!
Metal will never die!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problems with sf::Text
« Reply #1 on: July 16, 2010, 04:00:03 pm »
I don't know if it's a bug, but it is not a known issue.

If you can't extract a minimal code that reproduces this problem, I won't be able to see what's wrong :?
Laurent Gomila - SFML developer

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
Problems with sf::Text
« Reply #2 on: July 16, 2010, 04:37:43 pm »
Yes, I know... I'll try to extract something smaller...

bye, CBenni::O
42!
Metal will never die!

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
Problems with sf::Text
« Reply #3 on: July 17, 2010, 07:45:26 pm »
Got it!

This may not be minimal, but it may be short enough: (Compile with SFML 2.0)
Code: [Select]
#include <Windows.h>
#include <SFML/Graphics.hpp>

class style
{
public:
sf::Font Font;
int fs;
sf::Vector2f pos;
style()
: Font(sf::Font::GetDefaultFont()),fs(30),pos(sf::Vector2f(0.f,0.f))
{
}
};

class btn
{
public:
btn(std::string txt)
{
MyValue = sf::Text(txt,st.Font,st.fs);
}
void up()
{
MyValue.SetFont(st.Font);
MyValue.SetCharacterSize(st.fs);
MyValue.SetPosition(st.pos);
}
void add(std::string txt,int at)
{
std::string t=MyValue.GetString();
t.insert(at,txt);
MyValue.SetString(t);
}
void render(sf::RenderTarget* rt)
{
rt->Draw(MyValue);
}
style st;
private:
sf::Text MyValue;
};

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nShowCommand)
{
sf::RenderWindow App(sf::VideoMode(800,600),"Text Bug");
btn b1("Btn1");
b1.st.fs = 35;
b1.st.pos.x = 100;
b1.up();
btn b2("Btn2");
b2.st.fs = 25;
b2.st.pos.x = 400;
b2.up();
btn b3("Btn3");
b3.st.fs = 20;
b3.st.pos.x = 700;
b3.up();
while(App.IsOpened())
{
sf::Event e;
while (App.GetEvent(e))
{
std::string txt = " ";
switch(e.Type)
{
case sf::Event::Closed:
App.Close();
break;
case sf::Event::TextEntered:
txt[0] = (char)e.Text.Unicode;
b2.add(txt,2);
}
}
App.Clear();
b1.render(&App);b2.render(&App);b3.render(&App);
App.Display();
}
return 0;
}


bye,
CBenni::O
42!
Metal will never die!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problems with sf::Text
« Reply #4 on: July 18, 2010, 04:42:11 pm »
Great, thanks :)

I'll test it as soon as possible.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problems with sf::Text
« Reply #5 on: July 18, 2010, 06:03:48 pm »
Fixed.
Laurent Gomila - SFML developer

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
Problems with sf::Text
« Reply #6 on: July 19, 2010, 11:07:26 am »
Great! Thank you  :wink:

bye,
CBenni::O
42!
Metal will never die!

 

anything