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

Author Topic: SFML2: font specific problem  (Read 7736 times)

0 Members and 1 Guest are viewing this topic.

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« on: March 26, 2010, 01:52:29 am »
As the title says it might not be SFML's fault but the behavior seems weird.
When I use msgothic.ttc or extract a ttf out of it (=it's not a ttc problem) as font, the text is not being rendered/drawn properly when the text size is below 23.
Like this white shade "effect": it should be \u3082
 >=23 shows them correctly.
It applies to both Japanese characters and ASCII.

Since Arial works with smaller sizes (but doesn't support Japanese) it looks like the problem is within msgothic even though other software including the default windows font-viewer are displaying smaller sizes of it without problem.

Will this be "fixed" or should I try to find other fonts supporting smaller sizes?
Or is it working for other people and I am just doing something wrong?

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
SFML2: font specific problem
« Reply #1 on: March 26, 2010, 01:57:06 am »
Do you get this problem with the tutorials as well?

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #2 on: March 26, 2010, 02:16:36 am »
I think the tutorial is only for SFML1.5 at the moment, isn't it?
I did change to SFML2 because SFML1.5 is limited to a certain charset and thus Japanese text didn't work per default at all I think. SFML1.5 wasn't capable to load ttc files either, for me at least.

Well but I'm not doing much, it's something like


Code: [Select]

sf::Font MyFont;
sf::String _name;
sf::Text _namelabel;
...
MyFont.LoadFromFile("msgothic-02.ttf");
_namelabel = sf::Text(_name, MyFont, 10);
App.Draw(_namelabel);

while _name is set by an argument with the type sf::String as well.
I'm also moving the _namelabel around with SetPosition but that shouldn't really matter here.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
SFML2: font specific problem
« Reply #3 on: March 26, 2010, 02:25:33 am »
Can you try that again out of a class in a single main() and post the full source?

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #4 on: March 26, 2010, 02:51:17 am »
sure, here


Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>

int main(int argc, char* argv[])
{
sf::Font       MyFont;
sf::Text      _namelabel;

sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Sample");

MyFont.LoadFromFile("msgothic.ttc");
_namelabel = sf::Text(L"\u3082", MyFont, 22);

while (App.IsOpened())
{
sf::Event Event;


while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();

if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();

}
App.Clear(sf::Color(0, 0, 0));
_namelabel.SetPosition(10,10);
App.Draw(_namelabel);
App.Display();
}

return EXIT_SUCCESS;
}

Same result for me.
Maybe I should add that I use code::blocks (mingw), windows7 and use a dll version (not static).
Changed the font to the ttc version here since the ttfs might not be available for everyone.

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
SFML2: font specific problem
« Reply #5 on: March 26, 2010, 06:43:46 am »
Hi,

Can you try with this ?
Code: [Select]
MyFont.LoadFromFile("msgothic.ttc",10);
Mindiell
----

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #6 on: March 26, 2010, 07:05:19 am »
Hi,

when I try to compile this I get an "no matching function for call to" error message.
As "note" it's telling me only this candiate "bool sf::Font::LoadFromFile(const std::string&)".
I was also wondering at first but it looks like due to the change of how Text is rendered you only set the size at sf::Text now (in SFML2).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: font specific problem
« Reply #7 on: March 26, 2010, 07:36:31 am »
Hi

Can you upload the font, or provide a link to get it? I don't have it with my Win XP, and it doesn't seem to be free.
Laurent Gomila - SFML developer

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #8 on: March 26, 2010, 08:00:36 am »
Yeah it's a windows font but part of the "Asian (at least Japanese) Language Package" or something, you can probably install it if you have a windows CD.
Anyway I'll upload it but guess I'll give you the link via PM since as you noticed it's not free.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: font specific problem
« Reply #9 on: March 26, 2010, 08:32:11 am »
I did some tests, and I think that the combination FreeType/msgothic might produce a bug (so it's not related to SFML). I tried to change the render mode from "antialiased" (FT_RENDER_MODE_NORMAL) to "mono" (FT_RENDER_MODE_MONO), and it works fine for all characters and all sizes.

Maybe you should report it to the FreeType team? Or maybe it's just that the font doesn't support antialiased rendering at small sizes, I'll see if there's a function or a flag to test it.
Laurent Gomila - SFML developer

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #10 on: March 26, 2010, 09:15:17 am »
Thanks for looking into it.
At least it's reproducible :lol:

I'm puzzled now I did some test with two other fonts, one for Korean and one for Chinese characters, and they both can also display the \u3082 Japanese character even at lower size than 23.
Another font (all of the MS packages btw) for Japanese called msmincho however has the same problem as the msgothic.

If you can't find such flag or function maybe I'll consider reporting it. I think I'll also just ask google to see if other people had such a problem with FreeType already since those fonts are quite common on windows for displaying Japanese text.

EDIT: After some research I found someone who had the exact same problem only some week ago with FreeType and those fonts.
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=218421#218665
So if I understand it right those two font files only have a monochrome version of the font and while loading them it fails.
Is that a FreeType bug or something you can also handle inside the SFML2 code?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: font specific problem
« Reply #11 on: March 26, 2010, 11:58:39 am »
I think I can handle that in SFML 2. I'll do some more tests this week-end.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML2: font specific problem
« Reply #12 on: March 26, 2010, 08:45:46 pm »
It's fixed ;)

Thanks for your feedback.
Laurent Gomila - SFML developer

nachy

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML2: font specific problem
« Reply #13 on: March 27, 2010, 09:28:16 am »
Nice, thanks for working on it so quickly.
I compiled the new version and it's indeed working fine now.
Good job  :)

 

anything