0

I have a requirement where I need to print something on a custom media , say 3x5 inches in Ubuntu. I am using the "enscript" tool to print the information.

The number of lines that need to be print in the 3 inches would vary and so would the font size.

Is there any algorithm that I can use to calculate the font size needed to print a given number of lines per page in say 3 inches.

Lets say my font type would always be fixed to "Courier".

I have tried to calculate the font size, based on assuming that 1 inch is 72 points. So 3 inches is 216 points. If I need to print 20 lines in 3 inch space, my font size would be (216/20) which would be 10.8 points.

But this algorithm does not work and does not work for any given number of lines.

Any pointers in solving this would be greatly appreciated.

1 Answer 1

0

Ok so I was able to work around the problem. Here's what I did:

72 points per inch is not really a standard, but depends on the type of font, the spacing between lines and many other factors.So I fixed a font like "Courier" and then found what was the maximum font size I could print without any truncation/word wrap. Based on this font, I worked my way back to the points/per inch value.

I found that the "points/per inch" was different for both the font width and font height.

I found that this value was something like "64" not "72" for the font height. Based on "64" I was able to calculate, the font size height based on the formula:

64 * height of paper / number of lines on page

And it worked for all paper sizes and number of lines per page. .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .