I have some doubts about accuracy of GetTextWidth() function
Code: Select all
/*
Test for accuracy of GetTextWidth() function.
2014-08-18
*/
#include <hmg.ch>
PROCEDURE Main()
DEFINE WINDOW frmGTWTest ;
AT 0,0 ;
WIDTH 250 ;
HEIGHT 200 ;
MAIN ;
TITLE "GTW Accuracy" ;
ON INIT { || MsgDebug( GetTextWidth( , "size10" ), GetTextWidth( , "size20" ) ) }
ON KEY ESCAPE ACTION ThisWindow.Release
@ 50, 50 LABEL lblSize10 HEIGHT 20 VALUE "Size10" FONT "Verdana" SIZE 10
@ 100, 50 LABEL lblSize20 HEIGHT 30 VALUE "Size20" FONT "Verdana" SIZE 20
END WINDOW // frmGTWTest
frmGTWTest.Center()
frmGTWTest.Activate()
RETU // Main()
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.
Anyway I need know exact length in pixel of any string.
And IMHO for this info requires font size in addition to font name and not requires window / control name specified.
We have same samples for interesting usages by experts :
Code: Select all
gettextwidth(Nil,cString,fontname)*0.072/72*25.4*fontsize
Any opinion ?