| Mirage Source http://miragesource.net/forums/ |
|
| Centering Blted Text http://miragesource.net/forums/viewtopic.php?f=201&t=3553 |
Page 1 of 1 |
| Author: | seraphelic [ Sat Apr 05, 2008 4:25 am ] |
| Post subject: | Centering Blted Text |
In my journey to center text, I ran across a gdi32 api call dubbed GetTextExtentPoint which measures dimensions of specified text in hdc. The only problem is, I get a "User-Defined Type Not Defined" when adding the function: Code: Public Declare Function GetTextExtentPoint Lib "gdi32" Alias "GetTextExtentPointA" (ByVal hDC As Integer, ByVal lpszString As String, ByVal cbString As Integer, ByRef lpSize As Size) As Integer Can't figure out why it won't recognise it. Help!! Even better, if you have a operable center solution, pm me Thanks in advance! |
|
| Author: | Lea [ Sat Apr 05, 2008 1:44 pm ] |
| Post subject: | Re: Centering Blted Text |
Public Type Size cx As Long cy As Long End Type |
|
| Author: | seraphelic [ Sat Apr 05, 2008 4:38 pm ] |
| Post subject: | Re: Centering Blted Text |
Thanks, I got it working. Only problem is, the size is way off!! :[ What's going on? Took a screenie of mirage. a 31px name was reported as 43px. a 30px name was reported as 37px. Any help? |
|
| Author: | Lea [ Sat Apr 05, 2008 9:34 pm ] |
| Post subject: | Re: Centering Blted Text |
Each letter probably has some buffer space before and after it, including the first letter and last letter. If you measure from the start of the first letter to the end of the last letter, you won't be including that buffer space. |
|
| Author: | seraphelic [ Sun Apr 06, 2008 4:56 am ] |
| Post subject: | Re: Centering Blted Text |
Good point, but both words described had 6 letters. In paint, the difference in the words' pixel width was 1; the buffer should be constant im guessing, or else there would be no way to measure width with this method. So making these assumptions, I cannot fathom why the names "Jables" and "tester" would come out with a 6 pixel difference using this function >.> If anyone has a working system, please help. If there's another method give me a hint, I like figuring things out on my own (if theyre in my capacity). |
|
| Author: | Lea [ Sun Apr 06, 2008 12:40 pm ] |
| Post subject: | Re: Centering Blted Text |
Because J and S have different intra-letter spaces than T and R. If you want it to be right on, I bet a monospaced font like courier would do the trick. |
|
| Author: | seraphelic [ Sun Apr 06, 2008 1:19 pm ] |
| Post subject: | Re: Centering Blted Text |
But I heart verdana :[. There has to be another way.. Guess Im back to google. |
|
| Author: | Robin [ Sun Apr 06, 2008 1:39 pm ] |
| Post subject: | Re: Centering Blted Text |
Just create a .bmp file with the verdana font in it using monospacing. |
|
| Author: | seraphelic [ Wed Apr 09, 2008 12:48 am ] |
| Post subject: | Re: Centering Blted Text |
So I actually got GetTextExtentPoint32 to work in a seperate project, and I think I figured out the problem. For some reason the GAME_SIZE has to be an extra 5 to display the correct size. If someone doesn't already have a fix for this, I'm going to redo the dx text system because it SUCKS. |
|
| Author: | Robin [ Wed Apr 09, 2008 2:10 pm ] |
| Post subject: | Re: Centering Blted Text |
Hey, blame DX7 not us ;DD Drawing text directly sucks on all version of DX I've used. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|