diff --git a/photobooth.py b/photobooth.py index 6f70db2..723ad0c 100755 --- a/photobooth.py +++ b/photobooth.py @@ -180,11 +180,26 @@ _PRINT_MARGIN_IN = 0.5 def a4_landscape_chars(cpi, lpi): - """(cols, rows) of an A4 sheet printed sideways, at the given pitch.""" + """(cols, rows) to capture/preview for an A4 landscape printout. + + txt2printr.sh prints on a normally-fed (portrait) page and rotates the + ascii art 90 degrees in software; the reader turns the finished sheet + 90 degrees to view it. That second turn cancels the software rotation, + so this buffer's own dimensions equal the final visual result - but its + width becomes the printed *line count* after rotation, which must fit + within one page's line capacity along the long (feed) edge. Height is + then derived from the target landscape aspect ratio, corrected for + non-square character cells (cells are cpi/lpi times taller than wide), + so the final printout keeps true A4 proportions instead of just filling + however many character cells happen to fit. + """ long_in = _A4_LONG_MM / _MM_PER_IN short_in = _A4_SHORT_MM / _MM_PER_IN - cols = max(1, round((long_in - 2 * _PRINT_MARGIN_IN) * cpi)) - rows = max(1, round((short_in - 2 * _PRINT_MARGIN_IN) * lpi)) + max_lines = max(1, round((long_in - 2 * _PRINT_MARGIN_IN) * lpi)) + max_chars = max(1, round((short_in - 2 * _PRINT_MARGIN_IN) * cpi)) + aspect = (long_in / short_in) * (cpi / lpi) + cols = max_lines + rows = max(1, min(max_chars, round(cols / aspect))) return cols, rows