add ruler mode to pagetest.sh for exact chars-per-line calibration
Repeating-digit and prefixed-number test lines make it hard to read off exactly where a printer truncates a line. `./pagetest.sh ruler` prints a single line marking every 10th column with its tens digit and every 5th with '+', so the real cutoff column can be read directly off the page instead of estimated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>master
parent
a7d5b9d1bc
commit
063626d150
50
pagetest.sh
50
pagetest.sh
|
|
@ -1,23 +1,46 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Generates a page-break diagnostic file: numbered lines padded with '#' to
|
# Generates printer diagnostic files, so you can read a printer's real page
|
||||||
# a fixed width, so you can see exactly where a printer's real page length
|
# capacity straight off the paper instead of guessing from paper geometry.
|
||||||
# and line width limits are instead of guessing from paper geometry.
|
|
||||||
#
|
#
|
||||||
# Usage: ./pagetest.sh [width] [lines]
|
# Usage:
|
||||||
# width - characters per line, including the "NNN " prefix (default 64)
|
# ./pagetest.sh [width] [lines] - numbered lines padded with '#', to find
|
||||||
# lines - number of lines to generate (default 100)
|
# a printer's real lines-per-page (the
|
||||||
|
# last line number printed on page 1)
|
||||||
|
# (default width=64, lines=100)
|
||||||
|
# ./pagetest.sh ruler [width] - a single long ruler line marking every
|
||||||
|
# 10th column with its tens digit and
|
||||||
|
# every 5th with '+', to find a
|
||||||
|
# printer's real chars-per-line exactly
|
||||||
|
# (default width=200)
|
||||||
#
|
#
|
||||||
# Print the result with PRINTER_A4=false in printer.conf (no rotation), so
|
# Print the result with PRINTER_A4=false in printer.conf (no rotation):
|
||||||
# the line numbers read straight off the page:
|
|
||||||
# ./txt2printr.sh pagetest.txt
|
# ./txt2printr.sh pagetest.txt
|
||||||
|
|
||||||
dir="$(dirname "$0")"
|
dir="$(dirname "$0")"
|
||||||
width="${1:-64}"
|
|
||||||
lines="${2:-100}"
|
|
||||||
outfile="$dir/pagetest.txt"
|
outfile="$dir/pagetest.txt"
|
||||||
|
|
||||||
awk -v width="$width" -v lines="$lines" '
|
if [ "$1" = "ruler" ]; then
|
||||||
|
width="${2:-200}"
|
||||||
|
awk -v width="$width" '
|
||||||
|
BEGIN {
|
||||||
|
line = ""
|
||||||
|
for (i = 1; i <= width; i++) {
|
||||||
|
if (i % 10 == 0) line = line (int(i / 10) % 10)
|
||||||
|
else if (i % 5 == 0) line = line "+"
|
||||||
|
else line = line "-"
|
||||||
|
}
|
||||||
|
print line
|
||||||
|
}
|
||||||
|
' > "$outfile"
|
||||||
|
echo "Wrote a $width-char ruler line to $outfile"
|
||||||
|
echo "Every 10th column is marked with its tens digit (column 40 -> '4',"
|
||||||
|
echo "column 100 -> '0'), every 5th with '+'. Read off the last marker"
|
||||||
|
echo "that fully prints to get your printer's exact chars-per-line."
|
||||||
|
else
|
||||||
|
width="${1:-64}"
|
||||||
|
lines="${2:-100}"
|
||||||
|
awk -v width="$width" -v lines="$lines" '
|
||||||
BEGIN {
|
BEGIN {
|
||||||
for (i = 1; i <= lines; i++) {
|
for (i = 1; i <= lines; i++) {
|
||||||
prefix = sprintf("%03d ", i)
|
prefix = sprintf("%03d ", i)
|
||||||
|
|
@ -28,7 +51,8 @@ awk -v width="$width" -v lines="$lines" '
|
||||||
print line
|
print line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' > "$outfile"
|
' > "$outfile"
|
||||||
|
echo "Wrote $lines lines x $width chars to $outfile"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Wrote $lines lines x $width chars to $outfile"
|
|
||||||
echo "Print it with: PRINTER_DEV=/dev/lp0 \"$dir/txt2printr.sh\" \"$outfile\""
|
echo "Print it with: PRINTER_DEV=/dev/lp0 \"$dir/txt2printr.sh\" \"$outfile\""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue