| @@ -147,8 +147,41 @@ | ||
| 147 | 147 | */ |
| 148 | 148 | public const COL_WIDTH_MAX = self::PAPER_WIDTH_MAX; |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | + * Printable dots across 80 mm paper at 203 dpi. | |
| 152 | + */ | |
| 153 | + public const DOTS_80MM = 576; | |
| 154 | + | |
| 155 | + /** | |
| 156 | + * Printable dots across 58 mm paper at 203 dpi. | |
| 157 | + */ | |
| 158 | + public const DOTS_58MM = 384; | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Column count at or above which paper is treated as 80 mm. | |
| 162 | + * | |
| 163 | + * 58 mm rolls carry 32 columns; 80 mm rolls carry 42 or 48. | |
| 164 | + */ | |
| 165 | + public const WIDE_PAPER_COLUMNS = 40; | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * The printable width of the roll, in dots. | |
| 169 | + * | |
| 170 | + * Templates size images in dots, but declare paper in character columns, so | |
| 171 | + * every lane that puts an image on paper has to bridge the two. Shared here | |
| 172 | + * because an image scaled against 576 dots on one lane and 384 on another is | |
| 173 | + * the same divergence this whole table exists to prevent. | |
| 174 | + * | |
| 175 | + * @param int $columns The paper width in character columns. | |
| 176 | + * | |
| 177 | + * @return int The printable width in dots. | |
| 178 | + */ | |
| 179 | + public static function paper_dots( int $columns ): int { | |
| 180 | + return $columns >= self::WIDE_PAPER_COLUMNS ? self::DOTS_80MM : self::DOTS_58MM; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 151 | 184 | * Clamp a value into one of the ranges above. |
| 152 | 185 | * |
| 153 | 186 | * Thermal_Markup_Parser already clamps every attribute on its way into the |
| 154 | 187 | * AST, so for parsed templates this is a no-op. It is here for ASTs built by |