PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
← All changes | includes/Templates/Thermal/Thermal_Text_Layout.php +14 -5 1.10.3 → 1.10.17 View file →
@@ -258,24 +258,33 @@
258 258
259 259 /**
260 260 * Compute the leading-space padding that aligns a line of the given width.
261 261 *
262 + * The padding is emitted as literal spaces INSIDE the run it indents, so under a `<size>`
263 + * multiplier each one is $scale cells wide -- as is each character of the text. Callers that
264 + * emit bytes to a printer must pass the multiplier in force; a count taken at scale 1 lays
265 + * down $scale times the margin asked for and wraps the line. Callers that place glyphs at
266 + * computed cell positions (the raster emitter) already fold the multiplier into $text_width
267 + * and leave $scale at 1.
268 + *
262 269 * @param string $align The alignment mode (left|center|right).
263 - * @param int $text_width The display width of the line's plain text.
270 + * @param int $text_width The display width of the line's plain text, in unscaled cells.
264 271 * @param int $columns The paper width in character cells.
272 + * @param int $scale The text width multiplier in force. Default 1.
265 273 *
266 274 * @return int The number of leading spaces (clamped at 0).
267 275 */
268 - public static function alignment_padding( string $align, int $text_width, int $columns ): int {
269 - $remaining = $columns - $text_width;
276 + public static function alignment_padding( string $align, int $text_width, int $columns, int $scale = 1 ): int {
277 + $scale = max( 1, $scale );
278 + $remaining = $columns - ( $text_width * $scale );
270 279 if ( $remaining <= 0 ) {
271 280 return 0;
272 281 }
273 282 if ( 'center' === $align ) {
274 - return (int) floor( $remaining / 2 );
283 + return (int) floor( (int) floor( $remaining / 2 ) / $scale );
275 284 }
276 285 if ( 'right' === $align ) {
277 - return $remaining;
286 + return (int) floor( $remaining / $scale );
278 287 }
279 288
280 289 return 0;
281 290 }