Página 1 de 1
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 3:39 pm
por Mahanimann
What function do I use to measure the length in pixels of a string in a
particular font and fontsize? I have looked "everywhere" in different help
files, but can't find it.
Thanks,
Paal
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 3:51 pm
por Mahanimann
Typically, 2 minutes after posting the question I found at least on solution
in TFont:GetTextSize. But are there any *function* to call also (something
like GetTextSizeFromFont( cFontName, cTextToMeasure )?
Thanks,
Paal
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 3:51 pm
por Mahanimann
Typically, 2 minutes after posting the question I found at least on solution
in TFont:GetTextSize. But are there any *function* to call also (something
like GetTextSizeFromFont( cFontName, cTextToMeasure )?
Thanks,
Paal
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 5:32 pm
por ignacio
Paal,
Is the correct function. Your function prototype is not valid since it does
not take care of font size or bold state.
BTW, you can also use TCanvas:TextExtent()
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Mahanimann" <
paaldalen@gmail.com> escribió en el mensaje
news:[email=
47176503@ozsrv2.ozlan.local...]
47176503@ozsrv2.ozlan.local...[/email]
> Typically, 2 minutes after posting the question I found at least on
> solution in TFont:GetTextSize. But are there any *function* to call also
> (something like GetTextSizeFromFont( cFontName, cTextToMeasure )?
>
> Thanks,
> Paal
>
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 5:32 pm
por NoName
Paal,
Is the correct function. Your function prototype is not valid since it does
not take care of font size or bold state.
BTW, you can also use TCanvas:TextExtent()
Regards,
--
Ignacio Ortiz de Zúñiga
http://www.xailer.com
"Mahanimann" <
paaldalen@gmail.com> escribió en el mensaje
news:[email=
47176503@ozsrv2.ozlan.local...]
47176503@ozsrv2.ozlan.local...[/email]
> Typically, 2 minutes after posting the question I found at least on
> solution in TFont:GetTextSize. But are there any *function* to call also
> (something like GetTextSizeFromFont( cFontName, cTextToMeasure )?
>
> Thanks,
> Paal
>
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 9:29 pm
por Mahanimann
>> (something like GetTextSizeFromFont( cFontName, cTextToMeasure )?
> Is the correct function. Your function prototype is not valid since it
> does
> not take care of font size or bold state.
Yes I forgot this wasn't Xbase++, there it would be: cFontName := "10.Arial
Bold"

> BTW, you can also use TCanvas:TextExtent()
Ok.
I have experimented and it's not enough to know the text width with a
certain font. I also need to know the system font DPI size set in the
Display properties -> Settings -> the General tab -> Display DPI Setting.
Please se the attached picture.
From Xbase++ I know that there is a function in USER32.DLL,
"GetSystemMetrics", parameter no. 30, which returns a value indicating the
DPI size. But I'm in the beginning of a learning process and for now I
would be very happy to avoid learning using DLL's and that kind of stuff.
Are there any ready made function available in (ok, or through) Xailer?
Regards,
Paal
Attached files
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 9:29 pm
por Mahanimann
>> (something like GetTextSizeFromFont( cFontName, cTextToMeasure )?
> Is the correct function. Your function prototype is not valid since it
> does
> not take care of font size or bold state.
Yes I forgot this wasn't Xbase++, there it would be: cFontName := "10.Arial
Bold"

> BTW, you can also use TCanvas:TextExtent()
Ok.
I have experimented and it's not enough to know the text width with a
certain font. I also need to know the system font DPI size set in the
Display properties -> Settings -> the General tab -> Display DPI Setting.
Please se the attached picture.
From Xbase++ I know that there is a function in USER32.DLL,
"GetSystemMetrics", parameter no. 30, which returns a value indicating the
DPI size. But I'm in the beginning of a learning process and for now I
would be very happy to avoid learning using DLL's and that kind of stuff.
Are there any ready made function available in (ok, or through) Xailer?
Regards,
Paal
Attached files
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 9:39 pm
por jfgimenez
Paal,
> I have experimented and it's not enough to know the text width with a
> certain font. I also need to know the system font DPI size set in the
> Display properties -> Settings -> the General tab -> Display DPI Setting.
> Please se the attached picture.
>
> From Xbase++ I know that there is a function in USER32.DLL,
> "GetSystemMetrics", parameter no. 30, which returns a value indicating the
> DPI size. But I'm in the beginning of a learning process and for now I
> would be very happy to avoid learning using DLL's and that kind of stuff.
> Are there any ready made function available in (ok, or through) Xailer?
Screen:nPixelsPerInch
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 9:39 pm
por jfgimenez
Paal,
> I have experimented and it's not enough to know the text width with a
> certain font. I also need to know the system font DPI size set in the
> Display properties -> Settings -> the General tab -> Display DPI Setting.
> Please se the attached picture.
>
> From Xbase++ I know that there is a function in USER32.DLL,
> "GetSystemMetrics", parameter no. 30, which returns a value indicating the
> DPI size. But I'm in the beginning of a learning process and for now I
> would be very happy to avoid learning using DLL's and that kind of stuff.
> Are there any ready made function available in (ok, or through) Xailer?
Screen:nPixelsPerInch
--
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 10:14 pm
por Mahanimann
> Screen:nPixelsPerInch
Thank you very much, that was it! I tried it earlier today and don't
understand why I didn't get it! Arghh...
Thanks,
Paal
Function for text size in pixels?
Publicado: Jue Oct 18, 2007 10:14 pm
por Mahanimann
> Screen:nPixelsPerInch
Thank you very much, that was it! I tried it earlier today and don't
understand why I didn't get it! Arghh...
Thanks,
Paal