In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Function for text size in pixels?

Xailer professional forum in English
Responder
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9469
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Function for text size in pixels?

Mensaje 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
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
NoName
Mensajes: 531
Registrado: Vie Feb 03, 2006 7:27 pm

Function for text size in pixels?

Mensaje 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
>
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Function for text size in pixels?

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5718
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Function for text size in pixels?

Mensaje 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
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Mahanimann
Mensajes: 216
Registrado: Dom Sep 23, 2007 11:08 pm

Function for text size in pixels?

Mensaje 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
Responder