Hi all,
I need to know the exact font size needed to print a certain number o chars.
I made the following function with these parameters:
- cFontName, that is the font name
- n_ColRequired that is the number of chars that I want to print in a single printer row
- nMaxSize, the size of the paper
It seem to runs, however I receive a font number value different that the same I use in Word to print the same number of chars.
I need to know the font in a Microsoft Word-like format
Any ideas ?
Thanks in advance
------------
? GetFontSize("Arial",136,"210")
Function GetFontSize(cFontName,n_ColRequired,nMaxSize)
oPrn:=PrintBegin("")
aPoints:=oPrn:Cmtr2Pix(0,nMaxSize/10)
for nFontWidth:=90 to 1 step -1
oFont:=Tfont():New(cFontName,-nFontWidth)
oPrn:SetFont(oFont)
llv:=oPrn:GetTextWidth(replicate("B",n_ColRequired),oFont)
llv2:=oPrn:Pix2mmtr(0,llv)
if llv2[2]<nMaxSize &&
exit
endif
oFont:End()
sysrefresh()
next
oPrn:End()
return(nFontWidth)