This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Wrapping with DrawText


Wrapping with DrawText

Postby Sparkie » Jul 4, 2003 @ 8:17am

Sparkie
pm Member
 
Posts: 35
Joined: May 7, 2003 @ 2:05pm
Location: Budapest/Hungary


Postby Johan » Jul 4, 2003 @ 9:55am

Hi! Please feel email me any suggestions you might have regarding function names and data return types at gapidraw@viktoria.se
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby ppcStudios » Jul 4, 2003 @ 11:55am

I was just thinking about creating a wrapper for simple text processing that would parse the input string for \n and simply 'chop' it up and draw the text on separate lines. Warlords does a TON of text rendering from a file-based string table and this feature would be wonderful to have in GapiDraw 2.02

Another nice text feature (I'm just dreaming here) would be to pass DrawText a string with basic format commands (such as %d) along with an argument list and have the method insert the embedded text. Many of our text strings are currently broken up into multiple segments that have to be read in separately and have a value inserted in them, then drawn out. For example :

read in : You have
embed : (some number)
read in : cities
merge them together and DrawText

It would be nice if I could :

read in : You have %d cities
pass DrawText the string and some number in an arglist.

Just a thought =)
G.R. Moore
President/CEO
Pocket PC Studios
www.ppcstudios.com

Image
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Postby Sparkie » Jul 5, 2003 @ 8:55am

Sparkie
pm Member
 
Posts: 35
Joined: May 7, 2003 @ 2:05pm
Location: Budapest/Hungary


Postby ppcStudios » Jul 7, 2003 @ 12:11pm

G.R. Moore
President/CEO
Pocket PC Studios
www.ppcstudios.com

Image
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Postby Sparkie » Jul 7, 2003 @ 4:39pm

Sparkie
pm Member
 
Posts: 35
Joined: May 7, 2003 @ 2:05pm
Location: Budapest/Hungary


Agreed

Postby cottrelld » Jul 8, 2003 @ 5:16am

cottrelld
pm Member
 
Posts: 12
Joined: Jun 10, 2003 @ 5:03am


Postby Sparkie » Jul 8, 2003 @ 9:30am

Sparkie
pm Member
 
Posts: 35
Joined: May 7, 2003 @ 2:05pm
Location: Budapest/Hungary


Postby 8bit » Jul 8, 2003 @ 11:08am

I'm new to GD but can I make a suggestion? Create a function that takes a whole string of characters and then returns the dimensions used up by the string - Width & Height in pixels.

For a fixedsize 8x8 font:
"ace" will give us a dimension of Width = 24 and Height = 6 (lowercase).
"ACE" will give us a dimension of Width = 24 and Height = 8 (uppercase).

GD will then do the calculation natively which will be a big performance boost, rather than making multiple function calls for every character in the a string which will take longer.

Uses for this function for example will allow one to create a destination surface according to the dimensions, blit the string to that surface, then do all sorts of extra effects like scaling and rotation...

Like I said, just a suggestion - use it don't use it. :)

[EDIT - a few minute later]

I see that CGapiSurface::DrawText has support for GDDRAWTEXT_CALCWIDTH, but doesn't have a GDDRAWTEXT_CALCHEIGHT, which would be a nice to have. But CGapiSurface::RenderSystemFont does not have the same ability.
8bit
pm Member
 
Posts: 8
Joined: Jul 6, 2003 @ 10:09am
Location: South Africa


Postby Sparkie » Jul 8, 2003 @ 1:57pm

Sparkie
pm Member
 
Posts: 35
Joined: May 7, 2003 @ 2:05pm
Location: Budapest/Hungary


Postby Sm!rk » Jul 8, 2003 @ 10:08pm

User avatar
Sm!rk
pm Member
 
Posts: 172
Joined: Dec 16, 2002 @ 4:40pm


Postby Pejo Software - Per » Jul 9, 2003 @ 8:54am

User avatar
Pejo Software - Per
pm Insider
 
Posts: 343
Joined: Apr 25, 2002 @ 1:00pm
Location: Mölndal, Sweden


Postby maurice » Jul 9, 2003 @ 10:30am

maurice
pm Member
 
Posts: 37
Joined: Feb 26, 2003 @ 9:08pm
Location: Rotterdam


Postby Johan » Jul 10, 2003 @ 10:01am

Hi,

Unfortunately I don't have the time to revamp the DrawText function.. But I will add the following functions in 2.02:

// Returns the width in pixels needed to draw the string pString
HRESULT GetStringWidth(const TCHAR* pString, DWORD* pWidth);

// Returns the width in pixels for the specified character
HRESULT GetCharWidth(TCHAR tcChar, DWORD* pWidth);

// Returns the white space in pixels between the two characters
HRESULT GetSpacing(TCHAR tcChar1, TCHAR tcChar2, DWORD* pSpacing);

Hope it's enough for most uses. It would involve too much work to add the individual height of each character so unfortunately this will not be added.

I will however probably change the DrawText function to support features such as drawing text in columns etc in the future, hope it's not too much pain to change all the DrawText calls (The last parameter DWORD* pWidth would be changed to GDDRAWTEXTFX* pFX)...
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby Johan » Jul 10, 2003 @ 10:09am

Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Next

Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum