Hello,
is there a clean Solution, to calculate Pixeldimension in Relation to Font - Pt ?
There was a lot of testing, to find the values / adjustment for SAY's from Source
in Relation to the Font-Style / Size.
( you can Download the Fonttool again ( Rel. 1.4b ), with some more fixes pointing out to this Problem )
I tested some Solutions from the Internet, but it was not 100 %
My calculation for Font : Bold, Italic, Underline
A Solution from Internet :
*is the font-size given in pt, you can calculate the font-size in px by:
*fspx = 1.3333*fspt;
*e.g.
*a font-size specified with: font-size:10pt;
*will lead to a font-size of 13.3333px.
*A font-size, specified with: font-size:2.5em;
*is leading to a font-size, which is 2.5 times that of the bodies font-size.
*e.g.
*you specified the font-size of a div to 1.5 em, you can calculate its
*pixel-value by:
*fsdivpx = 1.3333*fsbodypt*fsdivem
*or
*fsdivpx = fsbodypx*fsdivem
*in both cases is the result 20px
Best Regards
Uwe
Calculation from Font-Size (pt) to Pixel ?
Calculation from Font-Size (pt) to Pixel ?
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: Calculation from Font-Size (pt) to Pixel ?
It's more complicated.
You need to know DPI (x or y) of the device (screen in this case) for convert the two values.
Example
FontSize px = ?
FontSize pt = 14
DPI = 96 (standard screen dpi resolution)
Point in a inch = 72
FontSize (in px) = FontSize(in pt) * DpiX / 72 = 14 * 96 / 72 = 18.667 px
You need to know DPI (x or y) of the device (screen in this case) for convert the two values.
Example
FontSize px = ?
FontSize pt = 14
DPI = 96 (standard screen dpi resolution)
Point in a inch = 72
FontSize (in px) = FontSize(in pt) * DpiX / 72 = 14 * 96 / 72 = 18.667 px
Re: Calculation from Font-Size (pt) to Pixel ?
Patrizio,
Thank You very much.
Is it possible for You, to test it with the Tools
and tell me Your results on Your Computer ?
My working Solution ( maybe some changes needed )
Best Regards
Uwe
Thank You very much.
Is it possible for You, to test it with the Tools
and tell me Your results on Your Computer ?
My working Solution ( maybe some changes needed )
Code: Select all
// cTEXTFONT2 = Prompt
//--------------- TEXT-Width ------------------//
FUNCTION TEXT_W( oSay, oTFont )
hDC1 := oSay:GetDC()
IF aFTYPE[6] = .F. // Italic
nTXTWIDTH := 2 + INT( GettextWidth( hDC1, ALLTRIM(cTEXTFONT2), oTFont:hFont, ) / 2 )
ELSE
nTXTWIDTH := 5 + INT( GettextWidth( hDC1, ALLTRIM(cTEXTFONT2), oTFont:hFont, ) / 2 )
ENDIF
oSay:ReleaseDC()
SAYTEXT := '@ 10,10 Say oSay Prompt "' + ALLTRIM(cTEXTFONT2) + '" OF oDlg SIZE ' ;
+ ALLTRIM(STR(nTXTHEIGHT)) + "," + ALLTRIM(STR(nTXTWIDTH)) + " Pixel Font oFont"
RETURN ( NIL )
//--------------- TEXT-Height ------------------//
FUNCTION TEXT_H( oTFont )
IF aFTYPE[7] = .F. // Underline
nTXTHEIGHT := 2 + INT( Abs( oTFont:nHeight ) / 2 )
ELSE
nTXTHEIGHT := 10 + INT( Abs( oTFont:nHeight ) / 2 )
ENDIF
SAYTEXT := '@ 10,10 Say oSay Prompt "' + ALLTRIM(cTEXTFONT2) + '" OF oDlg SIZE ' ;
+ ALLTRIM(STR(nTXTHEIGHT)) + "," + ALLTRIM(STR(nTXTWIDTH)) + " Pixel Font oFont"
RETURN ( NIL )
Uwe
Last edited by ukoenig on Wed Feb 17, 2010 11:48 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: Calculation from Font-Size (pt) to Pixel ?
With
The preview say Size: 33 x 92
Code: Select all
oFont := TFont():New( "Arial",21,-47,.F.,.T.,0,0,0,.T..T.)
oSay:SetColor( 16777215, 128 )
Re: Calculation from Font-Size (pt) to Pixel ?
The Result of Your settings on my Computer
I hope, it looks the same :
Best regards
Uwe
I hope, it looks the same :
Best regards
Uwe
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.