I have been years away from my math class. Now I would like to figure out the following.
I am writing a simple javascript program where some tabular data is output to PDF file. The program will automatically decide if to output the data in portrait or landscape layout.
User will have the ability to choose size of the font. Based on the size of the font and the number of characters in the widest tabular data row, the program will calculate whether portrait of landscape layout to apply.
I checked how many characters can be output per line under a specific font. Here is the result:
| Font size | Characters | Ratio | Ratio calc | Notes |
|---|---|---|---|---|
| 4 | 200 | 50.0 | (200 / 4) | |
| 6 | 130 | 21.7 | (130 / 6) | |
| 8 | 100 | 12.5 | (100 / 8) | |
| 10 | 80 | 8.0 | (80 / 10) | |
| 12 | 65 | 5.4 | (65 / 12) | |
| 14 | 56 | 4.0 | (56 / 14) | |
| 16 | 50 | 3.1 | (50 / 16) | |
| 18 | 43 | 2.4 | (43 / 18) | |
| 20 | 38 | 1.9 | (38 / 20) | |
| 22 | 35 | 1.6 | (35 / 22) | |
| 24 | 32 | 1.3 | (32 / 24) | |
| 26 | 30 | 1.2 | (30 / 26) | |
| 28 | 28 | 1.0 | (28 / 28) | |
| etc | etc | etc |
We can see the quantity of characters is lower with increased size of the font. But the ratio is not symmetrical. I can simply create a table for this where the program would lookup the result,but it would be more efficient to have a simple formula that would calculate the result.
For example, if user supplies font size 10, the formula calculates the answer of close to: 80. If the user chooses font size 26, the formula calculates the answer of around: 30.
What would be a mathematical approach to the calculation / formula / coefficients for this? (If possible, please try to present the answer in terms of JavaScript Math() functions or similar - but not necessary).
Thanks to @Raymond Chen here is the logic for his answer in which he turned my thinking 180 degrees around.
The product of the multiplications shows as the target size of a line - around 800. Now we can simply apply coefficient 800 and divide it by the font size and get the approximate number of characters. Good thinking @Raymond Chen.