September 29, 2023, 01:53:17 PM
Welcome,
Guest
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Latest WME version:
WME 1.9.1
(January 1st, 2010) -
download
Home
Help
Search
Calendar
Login
Register
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
String & Pixels
« previous
next »
Pages: [
1
]
Print
Author
Topic: String & Pixels (Read 4782 times)
0 Members and 1 Guest are viewing this topic.
MMR
Global Moderator
Frequent poster
Karma: 3
Offline
Gender:
Posts: 349
http://mmrdeveloper.wordpress.com/
String & Pixels
«
on:
July 03, 2005, 03:41:24 PM »
How can we know/calculate the size/length (in pixels) of a string using a determinate font?? e.g. to center a string (that changes it content) in the middle of the screen.
Logged
Nihil
Supporter
Addicted to WME forum
Karma: 0
Offline
Posts: 528
Fear me! I'm evil!
Re: String & Pixels
«
Reply #1 on:
July 03, 2005, 10:25:07 PM »
I guess you could use the Length-attribute of strings and multiply it with the width of the characters, but that would only work with bitmap-fonts, don't know how to get the size of TTFs.
Logged
H.P. Lovecraft's Dagon
Dagon on Facebook
Dagon on Twitter
McCoy
The cocido eater
Frequent poster
Karma: 0
Offline
Gender:
Posts: 365
Spurrrrrrring
Re: String & Pixels
«
Reply #2 on:
July 04, 2005, 12:10:54 AM »
Mhh... one thing that comes to my mind is to put the string inside a static control, then use the .SizeToFit() to automatically change its size to the string length. Then you just read the .width attribute of the static control, and voilá!
. And this way it will work with TTF and bitmap fonts.
Logged
Click
here
to sign my sig!
MMR
Global Moderator
Frequent poster
Karma: 3
Offline
Gender:
Posts: 349
http://mmrdeveloper.wordpress.com/
Re: String & Pixels
«
Reply #3 on:
July 04, 2005, 12:12:02 AM »
Good idea McCoy
thanks
I'm using TTF fonts
Logged
Mnemonic
WME developer
Administrator
Addicted to WME forum
Karma: 41
Offline
Gender:
Posts: 5683
Re: String & Pixels
«
Reply #4 on:
July 04, 2005, 09:16:29 AM »
Yes, SizeToFit() is the (only) way to go.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.
MMR
Global Moderator
Frequent poster
Karma: 3
Offline
Gender:
Posts: 349
http://mmrdeveloper.wordpress.com/
Re: String & Pixels
«
Reply #5 on:
July 04, 2005, 12:58:30 PM »
Yep, it works fine. Just what I needed
Logged
McCoy
The cocido eater
Frequent poster
Karma: 0
Offline
Gender:
Posts: 365
Spurrrrrrring
Re: String & Pixels
«
Reply #6 on:
July 04, 2005, 08:38:51 PM »
I'm not sure, but I think this method is used for the pointed object caption in the WME demo.
Logged
Click
here
to sign my sig!
Print
Pages: [
1
]
« previous
next »
Wintermute Engine Forum
>
Wintermute Engine
>
Technical forum
>
Topic:
String & Pixels