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

Author Topic: [SOLVED]Help with mono spaced font  (Read 5465 times)

0 Members and 1 Guest are viewing this topic.

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
[SOLVED]Help with mono spaced font
« 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.




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
« Last Edit: March 24, 2014, 08:28:26 pm by xumepoc »

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Help with mono spaced font
« Reply #1 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.
« Last Edit: March 14, 2014, 03:53:48 pm by Stauricus »
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Help with mono spaced font
« Reply #2 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
Laurent Gomila - SFML developer

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #3 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 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?

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #4 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?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Help with mono spaced font
« Reply #5 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.  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #6 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

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #7 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Help with mono spaced font
« Reply #8 on: March 16, 2014, 11:36:12 am »
No. It means that it will be in the next one.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Help with mono spaced font
« Reply #9 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 ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #10 on: March 16, 2014, 03:34:15 pm »
Thanks for the info guys  ;D ;D ;D

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #11 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()

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Help with mono spaced font
« Reply #12 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???

xumepoc

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Help with mono spaced font
« Reply #13 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
 

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Help with mono spaced font
« Reply #14 on: March 23, 2014, 02:03:57 pm »
Are you linking sfml-window?