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

Author Topic: Using GetRect and GetWidth to find string pixel width  (Read 3296 times)

0 Members and 1 Guest are viewing this topic.

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
Using GetRect and GetWidth to find string pixel width
« on: May 24, 2008, 05:27:01 pm »
Hi,

Could somebody provide me with a simple example of how I can obtain the pixel width of a sf:string object please? I see that there is a string GetRect method which I'm guessing can be used (with the Rect GetWidth method) to achieve this.

I'd like to use these to centre some text and menus.

Many thanks.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Using GetRect and GetWidth to find string pixel width
« Reply #1 on: May 24, 2008, 05:48:14 pm »
You've found the solution, so... what's the purpose of this post ?
Laurent Gomila - SFML developer

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Re: Using GetRect and GetWidth to find string pixel width
« Reply #2 on: May 24, 2008, 06:46:39 pm »
Quote from: "acrin1"
Hi,

Could somebody provide me with a simple example of how I can obtain the pixel width of a sf:string object please? I see that there is a string GetRect method which I'm guessing can be used (with the Rect GetWidth method) to achieve this.

I'd like to use these to centre some text and menus.

Many thanks.


I was doing the exact same thing yesterday using the same method you described and it worked great I can tell you.

acrin1

  • Newbie
  • *
  • Posts: 45
    • View Profile
    • http://www.crpgdev.com
Using GetRect and GetWidth to find string pixel width
« Reply #3 on: May 24, 2008, 07:08:29 pm »
Quote from: "Laurent"
You've found the solution, so... what's the purpose of this post ?


I wasn't sure if that was the correct way to achieve it until you confirmed it. I'll try them out.

Thanks.

strongdrink

  • Newbie
  • *
  • Posts: 43
    • View Profile
    • Email
Using GetRect and GetWidth to find string pixel width
« Reply #4 on: March 10, 2011, 09:58:06 pm »
Sorry, got it :D