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

Author Topic: sf::String and size errors  (Read 4515 times)

0 Members and 1 Guest are viewing this topic.

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« on: October 03, 2010, 11:45:36 am »
Hi everyone, I've recently decided to do a kind of textbox, and I'm encoutering a few problems :
-First of all, if a Set the cusor position at the same place as the sf::String, the cursor seems to high. Where should I place it ?
-Secondly, when typping a 'É' with a 'j' just above it for example they "hit" each other.

I am using the default font and SFML 1.6. I've tried with "block note" and I get the same Result. However, with Word, the characters don't overlap. Is there the same problem with SFML 2.0 ? Can this problem be corected ?

Thanks.

[EDIT] Since it's still about strings and unicode characters, i'll add it here :
Is the default font not able to display € ? because I receive the event TextEntered with 8364 which is right but I can't display it. If so, how can I know what characters a font can draw ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #1 on: October 03, 2010, 01:42:51 pm »
If you can, you should try SFML 2. The problem may have been corrected.
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #2 on: October 03, 2010, 01:53:59 pm »
Do you mean the overlapping has been corrected ? If so, i'm quite pleased even though i'm not passing yet to 2.0. I'll just wait...
However, would somebody mind answering my question :
-How should I set the cursor Y coordinate compared to the sf::String ? I used to put it at the same place with a size equal to GetSize() but it seems to high. I moved it down a bit and it seems ok, but it doesn't adapt to the font. Is there a perfect position ?

-I edited at the same time you answered so if somebody could answer me at the same time...

Thank you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #3 on: October 03, 2010, 03:30:10 pm »
Quote
-How should I set the cursor Y coordinate compared to the sf::String ? I used to put it at the same place with a size equal to GetSize() but it seems to high. I moved it down a bit and it seems ok, but it doesn't adapt to the font. Is there a perfect position ?

What kind of cursor are you talking about? The | one for editing? If so, what you do should be ok. Can you show us a screenshot of what you get?
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #4 on: October 03, 2010, 03:47:15 pm »
If you look at the following Image, you will notice that the | seems to high compared to the j.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #5 on: October 03, 2010, 04:24:19 pm »
It's not too high, it's just too small. The character size of the text represents the distance between the top and the base line, so it doesn't include what's below. But I think that's what all text editor do, the cursor never go below the base line.
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #6 on: October 03, 2010, 04:27:46 pm »
I can assure you (for I've just tried with Block note) that the cursor goes under the base line. The question is, by how much ?
Does somebody know why I can't display a € symbol with the default font ?
Thank you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #7 on: October 03, 2010, 04:38:37 pm »
Quote
I can assure you (for I've just tried with Block note) that the cursor goes under the base line. The question is, by how much ?

That's right, it goes below, but it doesn't seem to go completely.
This information depends on the font's metrics, and I don't think that you can retrieve the relevant values in SFML 1.
By the way, which GetSize() do you use for the size of your cursor?

Quote
Does somebody know why I can't display a € symbol with the default font ?

You need to check its Unicode code, and if it's not in range [0, 255] then you won't be able to display it with the default font.
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #8 on: October 03, 2010, 04:43:30 pm »
Quote
This information depends on the font's metrics, and I don't think that you can retrieve the relevant values in SFML 1.


Will there be a solution in 2.0 (it would be nice)?

I don't really understand the idea of font metric's. Could you give me a clue of how to calculate the cursor's position ?

Quote
You need to check its Unicode code, and if it's not in range [0, 255] then you won't be able to display it with the default font.


Thanks, i'm dealing with Unicode strings, however i was using default font...
How can I know which font supports which characters ?



I'm using sf::String::GetSize() (i'm in 1.6 so no sf::Text::GetSize()).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #9 on: October 03, 2010, 04:52:36 pm »
Quote
Will there be a solution in 2.0 (it would be nice)?

Yes :)

Quote
I don't really understand the idea of font metric's. Could you give me a clue of how to calculate the cursor's position ?

In fact it should be ok with GetSize(), I'll do some tests to see what's wrong.

Quote
Thanks, i'm dealing with Unicode strings, however i was using default font...
How can I know which font supports which characters ?

There are two levels:
- the characters that are included in the font file
- the characters set that you use when you load a sf::Font

By default, the characters set in SFML is the range [0, 255]. You can change it with the third argument of the sf::Font::LoadFromFile function.
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #10 on: October 03, 2010, 04:59:17 pm »
How can I get the characters included in the Font file ?
Is there an option for charset=AllAvailableCharacters ?

Quote
Will there be a solution in 2.0 (it would be nice)?

Yes Smile


I'm very glad to here that. Nice (futur ?) job !
Quote

In fact it should be ok with GetSize(), I'll do some tests to see what's wrong.


Ok. Perfect.

I must say, you are doing a great job answering all those questions. Wouldn't think you would answer so much with CAMP and SFML as projects...

[EDIT] Does it take more memory to Load the whole charset (I guess the answer is yes). More time printing (accessing to the Sprties is longer) ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #11 on: October 03, 2010, 06:28:20 pm »
Quote
How can I get the characters included in the Font file ?

I don't know, there are probably tools that show you this kind of information.

Quote
Is there an option for charset=AllAvailableCharacters ?

There are approximately 245000 characters in the Unicode standard, so... no ;)
But SFML 2.0 doesn't have this limitation, characters are generated on the fly when necessary.

Quote
I must say, you are doing a great job answering all those questions. Wouldn't think you would answer so much with CAMP and SFML as projects...

Actually, I'm not working much on CAMP. My focus is almost entirely on SFML.

Quote
Does it take more memory to Load the whole charset (I guess the answer is yes)

Yes, indeed.

Quote
More time printing (accessing to the Sprties is longer) ?

Nop.
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #12 on: October 15, 2010, 07:47:12 pm »
Quote
Quote
I don't really understand the idea of font metric's. Could you give me a clue of how to calculate the cursor's position ?


In fact it should be ok with GetSize(), I'll do some tests to see what's wrong.


Hi, I wanted to know if you had found what was wrong with GetSize().

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::String and size errors
« Reply #13 on: October 15, 2010, 09:09:44 pm »
Quote
Hi, I wanted to know if you had found what was wrong with GetSize().

Not yet, sorry. I move it up in my todo list ;)
Laurent Gomila - SFML developer

NoIdea

  • Full Member
  • ***
  • Posts: 149
    • View Profile
sf::String and size errors
« Reply #14 on: October 15, 2010, 09:34:21 pm »
Quote
Not yet, sorry. I move it up in my todo list


thanks...