Font sizing for printout.

Font sizing for printout.

Postby TimStone » Wed May 27, 2020 4:42 pm

For years, when working with FONTS on printouts I have had no problems. Suddenly just 1 client is having an issue which I could solve with a better understanding of how FONT sizing works in FiveWin. Here is the line:

DEFINE FONT oFnorp NAME "Courier New" SIZE 0, -10 OF oPrn

Specifically, withy this setting, how many characters should I be able to place in an inch on a printout ?

In the past, I've always adjusted the second size component ( which I now see is height ). Normally I use -11, but if I want condensed, I go to a smaller number, like -7. Expanded might be -18. This has always worked, but now I see I don't fully realize why.

Most important, with the selected font and size, I do need to know how many characters I should be able to fit on a line with 8.5 inches width.

Thanks for your input.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Font sizing for printout.

Postby James Bott » Tue Jun 23, 2020 12:21 am

Hi Tim,

Tim,

I haven't done anything like this in a long time, but below (after my signature) is a note from my FW printing notes file. Keep in mind that everything from the colon on is a remark. I don't know why I did it that way now.

I am not sure exactly what you are trying to accomplish, but here are some options:

To find out how many characters of a specific font will fit in a specific width you will have to create a function that calculates it in pixels. Generally, one uses the widest character (usually a W or M). Just create a DO WHILE loop that keeps adding a new "W" until it exceeds the printable width of the printer page. Then subtract 1. Now any combination of characters will fit. Alternatively, you could do a similar thing with the real characters. You would keep adding the real text, character by character until is exceeds the printable width, then subtract everything up to the last space and print. Tedious.

I assume there is some reason you can't just let the printer object handle all this for you? If you are doing some kind of a special report where you need to fit a string of characters on one line without word wrapping, then maybe you need to process the entire report looking for the longest line, then find the font width that will be required to print that line.

Complicated stuff.

Regards,
James

--------------------------------------------
12/8/2006 7:58 PM - JBott

Here are two sets of data from different devices (both for 8.5x11 inch paper). Previously, I assumed that nHorzRes() was the dimension of the paper but it is the printable area of the page. All the vars refer to the printable area except for GetPhySize().


oPrn:cModel: HP DeskJet 420,winspool,LPT1:
oPrn:nHorzRes(): 2400 [2400/300 dpi = 8 inches]
oPrn:nVertRes(): 3025 [3025/300 dpi = 10.1 inches]
oPrn:nLogPixelx(): 300
oPrn:nLogPixely(): 300
oPrn:nXOffset: 75
oPrn:nYOffset: 75
oPrn:nHorzSize() : 203 mm = 8.0 in
oPrn:nVertSize() : 256 mm = 10.1 in
oPrn:GetPhySize()[1]: 215.900 [ 215.9 mm / 25.4 = 8.5 in ]
oPrn:GetPhySize()[2]: 279.400 [ 279.4 mm / 25.4 = 11 in ]

8.5 in * 300 dpi = 2550 pixels - (2 * nXOffset ) = 2400
===========================
oPrn:cModel: hp officejet 5500 series,winspool,USB001
oPrn:nHorzRes(): 4800
oPrn:nVertRes(): 6258
oPrn:nLogPixelx(): 600
oPrn:nLogPixely(): 600
oPrn:nXOffset: 150
oPrn:nYOffset: 42
oPrn:nHorzSize() : 203 mm = 8 in
oPrn:nVertSize() : 264 mm = 10.4 in
oPrn:GetPhySize()[1]: 215.900
oPrn:GetPhySize()[2]: 279.400
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Font sizing for printout.

Postby nageswaragunupudi » Thu Jun 25, 2020 3:36 pm

As long as you use only fixed width fonts like Courier New, Lucida Console, Consolas, etc., you can use this function to calculate the number of characters that fit in given length in inches.

Code: Select all  Expand view  RUN
function CharsPerInches( oPrn, nWidthInInches, oFont ) // --> Number of chars

   local nPixPerChar := GetTextWidth( oPrn:hDCOut, Replicate( "B", 100 ), oFont:hFont ) / 100.0
   local nWidthPix   := oPrn:Units2Pix( nil, nil, nWidthInInches, nil, "INCHES" )[ 3 ]

return Int( nWidthPix / nPixPerChar )
 


This does not work (rather meaningless) for proportional fonts like Arial, Tahoma, Verdana, etc
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Font sizing for printout.

Postby nageswaragunupudi » Thu Jun 25, 2020 3:37 pm

As long as you use only fixed width fonts like Courier New, Lucida Console, Consolas, etc., you can use this function to calculate the number of characters that fit in given length in inches.

Code: Select all  Expand view  RUN
function CharsPerInches( oPrn, nWidthInInches, oFont ) // --> Number of chars

   local nPixPerChar := GetTextWidth( oPrn:hDCOut, Replicate( "B", 100 ), oFont:hFont ) / 100.0
   local nWidthPix   := oPrn:Units2Pix( nil, nil, nWidthInInches, nil, "INCHES" )[ 3 ]

return Int( nWidthPix / nPixPerChar )
 


This does not work (rather meaningless) for proportional fonts like Arial, Tahoma, Verdana, etc
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 53 guests