Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


DirectX fonts


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 February 2000 - 04:54 AM

How can i retrieve the pixel length of drawn text in DirectX? I need it to determine the minimum length of a "menu".

Sponsor:

#2 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 13 February 2000 - 05:42 AM

could you clarify that? I don''t quite understand what you''re asking.

#3 PsYcHoPrOg   Members   -  Reputation: 115

Like
Likes
Like

Posted 13 February 2000 - 05:43 AM

just continuing my last post, sorry, I realized that the other post needed to bee added on to. My question is, do you want to retrieve the pixel leangth of one charecter, or the entire thing?

#4 trixter   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 February 2000 - 06:48 AM

how are you drawing this text? gdi, ddraw, d3d?

#5 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 February 2000 - 07:36 PM

I''m drawing in DirectDraw and want the length of entire string.

#6 Gromit   Members   -  Reputation: 144

Like
Likes
Like

Posted 13 February 2000 - 08:05 PM

Are you using the GDI to blit to a direct draw surface? or bliting a graphic of each letter?

#7 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 02:11 AM

I write text like this-
surfacename.Drawtext(xpos,ypos,"TEXT",False)
(the last false just makes the text stay in its x,y location and doesn''t go to upper left corner).

#8 trixter   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 05:42 AM

draw all the letters to the screen, take a screenshot, open it up in a paint app, and count the pixel widths and heights for whatever letters you want. this shoud work regardless oh how you are drawing this text




#9 Spellbound   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 10:42 AM

Just looked up the function and it looks like it updates the current position if you use TRUE for the last parameter.

Perhaps you can read the current position after printing the text and compare it to the position before.

#10 Tuan   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 02:17 PM

You can use the GetTextExtentPoint32 function to get the size of string with selected font.


#11 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 February 2000 - 02:27 AM

trixter-
I have to be more specific next time - of course I meant
runtime check.

#12 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 February 2000 - 03:05 AM

Tuan, what is the device context in DirectX? Example please...

#13 nes8bit   Members   -  Reputation: 275

Like
Likes
Like

Posted 16 February 2000 - 01:12 PM

I assume that you are using Visual Basic since DrawText is a VB only function. You must declare GetTextExtentPoint32 like this:

Private Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal cbString As Long, lpSize As SIZE) As Long

Then call it. Since I never used it, look it up somewhere.

#14 Tuan   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 01:31 PM

You can get the device context of DirectDrawSurface:

void GetTextSize(char* text, HFONT hFont, SIZE& size)
{
HDC hdc;
HFONT oldfont;
gDDSurface->GetDC(&hdc);
// Try with GDI functions
oldfont = (HFONT) SelectObject(hdc, hFont);
//SetBkMode(hdc, TRANSPARENT);
//SetTextAlign(hdc, TA_LEFT / TA_TOP / TA_NOUPDATECP);
GetTextExtentPoint32(hdc, text, strlen(text), &size);
SelectObject(hdc, oldfont);
gDDSurface->ReleaseDC(hdc);
}

Goodluck.


#15 Zombie   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 February 2000 - 10:10 PM

Yes, I''m using and don''t understand anything about that C code. I have the declaration too (api viewer is for that), but I have no idea how to get it working. To what i should use the SIZE?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS