Page 2 of 2

Re: PrintLen on Test

Posted: Sat Aug 23, 2014 6:21 am
by hmgchang
Dear Sirs,

After applying your new PrintLen....

Re: PrintLen on Test

Posted: Fri Jun 05, 2015 9:15 pm
by hmgchang
Dear Masters,

Till now I am still struggling with the correct string width printed by the PRINT DATA command, Anyone pls help !

TIA....

best rgds,
Chang

Re: PrintLen on Test

Posted: Fri Jun 05, 2015 10:42 pm
by dragancesu
Each font is defined by the need to know the size, height and width character

example
PRIVATE cFontName: = "Courier", nFontSize: = 10, nFontHeight: = 5, nCharWidth = 2.5

and then it is easy

Re: PrintLen on Test

Posted: Sat Jun 06, 2015 3:26 am
by hmgchang
Thanks Mr. Dragancesu,

According to the syntax, i provide fontname, fontsize, fontattribute( B, I or U).
I dont understand how to define the nFontHeight and nCharWidth that related to
fontname and fontsize. Can you pls give me some advise or sample ?

TIA

best rgds,
Chang

Re: PrintLen on Test

Posted: Sat Jun 06, 2015 4:59 am
by dragancesu
No table for it, print out and measure it
(might have but not looking)

when look:

Java have font functions https://docs.oracle.com/javase/tutorial ... gtext.html
but for display (pixel) and you need for print (mm)

Re: PrintLen on Test

Posted: Tue Jun 16, 2015 10:56 pm
by hmgchang
Dear Masters and Mr. Rathinagiri,

Thanks for the your printlen function.
I experimented and modified your printlen function,

Code: Select all

function printLen( cString, nFontsize, cFontname)
  cCreateFont := _HMG_CREATEFONT( OpenPrinterGetDC(), cFontname, nFontSize )
  nGetTextWidth := gettextwidth( OpenPrinterGetDC(), cString, cCreateFont )
	nWidth := nGetTextWidth * 25.4 / 600
	RETURN( ROUND( nWidth, 2))
	*- return round( nGetTextWidth * 0.0254 * nFontsize, 2 ) 
and the result,
printlen.JPG
printlen.JPG (76.3 KiB) Viewed 4088 times
it works but not perfectly, esp with the fontsize 8, any suggestions ?
_FontSizeWidth.zip
(3.41 KiB) Downloaded 250 times

Re: PrintLen on Test

Posted: Wed Jun 17, 2015 5:15 am
by hmgchang
But on Epson L210 Color Printer, the formula should be :
nWidth := nGetTextWidth * 25.4 / 360

Now, my question is :
1. How to get the printer name selected ?
2. How the number 600 ( for HP LaserJet) or 360 ( Epson Color Printer) related to printer resolution ?

TIA