SFML community forums

Help => Graphics => Topic started by: xumepoc on March 14, 2014, 02:03:57 pm

Title: [SOLVED]Help with mono spaced font
Post by: xumepoc on March 14, 2014, 02:03:57 pm
Hi everyone, I have some issues and questions on the text rendering with SFML

This is the situation using a custom defined font for a project.

(http://xumepoc.com/vatsim/sfml_direct2d_text_problem.jpg)


As you can see there is a significant difference with the way the font is displayed with SFML and Direct2D/GDI/PhotoShop/everything else. In both samples the font is size 13. There are two problems:

1. The font is not displayed correctly, you can see that some of the letters are not even drawn with their full length, like the S. Also I know that Direct2D is using ClearType, but is simply looks better with it, then in SFML

2. You can see that there is some spacing in SFML with is not present in Direct2D or GDI or anywhere else.

So my question is, how can I overcome these problems. Because with Direct2D I get 10 FPS and with SFML 45 drawing the same elements (which are something like 50000 lines).

I am using v2.1
Title: Re: Help with mono spaced font
Post by: Stauricus on March 14, 2014, 03:52:09 pm
have you resized your sf::Text object?
can you show us a piece of code and your font? i'd like to test it.
Title: Re: Help with mono spaced font
Post by: Laurent on March 14, 2014, 04:33:27 pm
Text rendering has been improved in the current development version.

https://github.com/SFML/SFML/issues/228
Title: Re: Help with mono spaced font
Post by: xumepoc on March 14, 2014, 10:10:28 pm
have you resized your sf::Text object?
can you show us a piece of code and your font? i'd like to test it.
The font is based on this font ,http://avsim-bg.org/others/Karben%20205%20Mono%20Medium.otf (http://avsim-bg.org/others/Karben%20205%20Mono%20Medium.otf) but I can't give you actual code do to copyright.

Here is the code snippet
sf::Font font;
font.loadFromFile("res/font.ttf");

sf::Text text("TEST 1234000 WERTY",font);
text.setFont(font);
text.setCharacterSize(13) ;
text.setColor(sf::Color::White);
text.setPosition(20,20);

ttl2D->draw(text);
 

BTW using this
int give_letter_size(char &letter, sf::Font &font, int font_size)
{
        return font.getGlyph(int(letter), font_size, false).advance;
}

for the same text I get 26. Is this pixels or some value I need to convert to pixels?
Title: Re: Help with mono spaced font
Post by: xumepoc on March 14, 2014, 10:11:31 pm
Text rendering has been improved in the current development version.

https://github.com/SFML/SFML/issues/228
I know that topic, I did make a search before posting, but I though that was for v2 and it was implemented already in 2.1.
Any news for the next public release?
Title: Re: Help with mono spaced font
Post by: zsbzsb on March 14, 2014, 11:03:55 pm
Any news for the next public release?

Soon™



But seriously compile the latest sources yourself. It really isn't that difficult and you will be up and running in no time.  ;)
Title: Re: Help with mono spaced font
Post by: xumepoc on March 14, 2014, 11:11:45 pm
Well I have never done it before, so will have to do some reading first, but maybe I will do it and not wait for the next release and run with it until then.  ;) ;D ;D
Title: Re: Help with mono spaced font
Post by: xumepoc on March 16, 2014, 11:25:09 am
I am looking in the SFML source code and the changes are there. Does this means that the release 2.1 is compiled with that code or no?
Title: Re: Help with mono spaced font
Post by: Laurent on March 16, 2014, 11:36:12 am
No. It means that it will be in the next one.
Title: Re: Help with mono spaced font
Post by: Nexus on March 16, 2014, 11:37:02 am
SFML 2.1 is older. If you want the newest revision, you should take the most recent Git revision. You could also checkout the blendmodes instead of master branch, to help with testing the new blend modes ;)
Title: Re: Help with mono spaced font
Post by: xumepoc on March 16, 2014, 03:34:15 pm
Thanks for the info guys  ;D ;D ;D
Title: Re: Help with mono spaced font
Post by: xumepoc on March 22, 2014, 03:45:01 pm
Guys I have a little problem, when I compile the source I get a linker error for sf::Window::setSize()
Title: Re: Help with mono spaced font
Post by: Jesper Juhl on March 22, 2014, 04:02:34 pm
Guys I have a little problem, when I compile the source I get a linker error for sf::Window::setSize()

And the error is???
Title: Re: Help with mono spaced font
Post by: xumepoc on March 22, 2014, 07:05:32 pm
Sorry
Error   1       error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::setSize(class sf::Vector2<unsigned int>)" (__imp_?setSize@Window@sf@@QAEXV?$Vector2@I@2@@Z) referenced in function "public: void __thiscall HMI_SFML::Resize(float,float)" (?Resize@HMI_SFML@@QAEXMM@Z)    HMI_SFML.obj
 
Title: Re: Help with mono spaced font
Post by: Jesper Juhl on March 23, 2014, 02:03:57 pm
Are you linking sfml-window?
Title: Re: Help with mono spaced font
Post by: xumepoc on March 23, 2014, 03:17:37 pm
Yes, and with the old original 2.1 build everything was OK.
I guess I just can't build it right. I guess will wait for the official next release.
Title: Re: Help with mono spaced font
Post by: xumepoc on March 24, 2014, 08:28:08 pm
The font issue is fixed. It turns out that if I use .oft variant of the font, everything is OK, with .ttf I get the result in the first post.

Now I have small problem with resizing, but will post in the corresponding section ;D ;D