PDA

View Full Version : lenght of fonts and ortho mode



happy
04-01-2003, 03:52 PM
i use ortho mode, so i use bitmap fonts (NeHe tutorial) to write texts

the only pb whith those fonts is that we cannot pick the exact lenght (in pixels) of the string ; we could then center them in the screen for example

using the outline fonts enable us to pick this lenght but i think the don't work in ortho mode

so what can i do!!!

thanks in advance http://www.opengl.org/discussion_boards/ubb/smile.gif

shinpaughp
04-01-2003, 06:12 PM
See http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/012330.html

happy
04-02-2003, 07:05 AM
well i've found in MSDN a fonction called : GetCharABCWidthsFloat ; it seems to be better than GetCharWidth32 or GetCharWidthFloat, and here is its description:

BOOL GetCharABCWidthsFloat(
HDC hdc, // handle to DC
UINT iFirstChar, // first character in range
UINT iLastChar, // last character in range
LPABCFLOAT lpABCF // array of character widths
);

///////////////////////////////////////////
Parameters
hdc
[in] Handle to the device context.
iFirstChar
[in] Specifies the code point of the first character in the group of consecutive characters where the ABC widths are sought.
iLastChar
[in] Specifies the code point of the last character in the group of consecutive characters where the ABC widths are sought. This range is inclusive. An error is returned if the specified last character precedes the specified first character.
lpABCF
[out] Pointer to an array of ABCFLOAT structures that receives the character widths, in logical units.

Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
///////////////////////////////////////////

i call it like that :
int isOK=GetCharABCWidthsFloat(hDC,'a','z',lpABCF);

of course after having declared :
HDC hDC;
LPABCFLOAT lpABCF;

but the pb is that the value of isOK is always 0, ie the function fails, and i don't know why!!!

using GetLastError() i got error 87, ie according to MSDN System Error Codes : The parameter is incorrect (ERROR_INVALID_PARAMETER) !!!

please help i can't see where the error is

thanks

PS : if someone wants the MSDN page it's : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_3ook.asp

shinpaughp
04-02-2003, 11:43 AM
of course after having declared :
LPABCFLOAT lpABCF;


The problem is that you have to declare either ABCFLOAT theABCF (or as an array) and pass it as &theABCF (array does not need the address of) or initialize your lpABCF variable since it is a pointer pointing to some arbitrary and unknown address in memory using malloc or new.

[This message has been edited by shinpaughp (edited 04-02-2003).]