#!/usr/bin/env bash # # papersize.bash - Single source of truth for GNU troff papersizes # # Generates a list of paper formats which can then be transformed # into generated code for gropdf, papersize.tmac, and libgroff. # See accompanying gropdf.pl.awk, papersize.tmac.awk, paper.cpp.awk. # # Generate paper format for given series and start dimensions # Returns lines that specify the paper format name and dimensions (width x height) # and dimension unit indicator metric implying millimeters, e.g.: # a4 210 297 metric function iso() { series=$1 # The name of the series width=$2 # The starting width height=$3 # The starting height count=$4 # The number of formats to generate, e.g. 10 = A0-A10 for format in $(seq 0 $count); do metric $series$format $width $height tmp=$height height=$width width=$(( tmp / 2 )) done } # Prints the given first 3 arguments and # appends the metric dimension unit indicator implying millimeters, e.g.: # $1 $2 $3 metric function metric() { echo ${1:-unknown} ${2:-0} ${3:-0} metric } # Prints the given first 3 arguments and # appends the imperial dimension unit indicator implying inches, e.g.: # $1 $2 $3 imperial function imperial() { echo ${1:-unknown} ${2:-0} ${3:-0} imperial } # # Single source of truth for papersizes # # ISO Papersizes specified in millimeters iso a 841 1189 10 iso b 1000 1414 10 iso c 917 1297 10 iso d 771 1090 8 # ISO Envelopes metric dl 220 110 # US Papersizes specified in inches imperial letter 8.5 11 imperial legal 8.5 14 imperial jrlegal 5 8 imperial tabloid 11 17 imperial ledger 17 11 imperial statement 5.5 8.5 # These dimensions for executive paper format are what all printer manufacturers use. imperial executive 7.25 10.5 # US Envelopes imperial monarch 7.5 3.875 imperial com10 9.5 4.125