![]() |
Get the REAL width of text - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Get the REAL width of text (/showthread.php?tid=806) |
Get the REAL width of text - Robin - 08-03-2007 Perfect for those who can't seem to centralise names [cleared] I also found it useful when I made Nr completely in DX. Code: Public Function getSize(ByVal DC As Long, ByVal Text As String) As textSize Code: Public Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As textSize) As Long Code: Public Type textSize Re: Get the REAL width of text - GIAKEN - 22-07-2008 How do we use this? :? It doesn't make sense...I'm wanting a function that returns the width of the text in pixels? Why do we need the array there? Re: Get the REAL width of text - GIAKEN - 22-07-2008 Nevermind I figured it out ![]() ![]() Code: TextX = ((GetPlayerX(Index) * PIC_X + Player(Index).XOffset) + 16) - (getSize(frmMirage.hdc, GetPlayerName(Index)).width / 2) Re: Get the REAL width of text - GIAKEN - 22-07-2008 Alright I just did some tests. The actual width of the text (checked with Photoshop) is 48 pixels. getSize returns 43. Len(Text) * 8 returns 48, which is what was the system that was in place. Re: Get the REAL width of text - Robin - 22-07-2008 This is over a year old xD And I'm aware it doesn't centralise it perfectly, but it does it a lot better than len*x on different sized fonts. Re: Get the REAL width of text - GIAKEN - 22-07-2008 I'm aware of the date ![]() This would only be useful on font that varies in size between letters. Also I noticed: When using frmMirage.hDC it was 43 and when I used frmMirage.picScreen.hDC it returned 32 (or some 30 number). Re: Get the REAL width of text - seraphelic - 22-07-2008 I made a center text tutorial a while back using this method. http://web.miragesource.com/forums/viewtopic.php?f=75&t=3562&start=0&st=0&sk=t&sd=a Re: Get the REAL width of text - Robin - 22-07-2008 I made mine in 2007, you made yours in 2008. |