Skip to content

Commit 79d97a8

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 85bd47c + 939a0c4 commit 79d97a8

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

app/Models/Labels/Tapes/Brother/TZe_24mm_D.php

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,38 @@ public function write($pdf, $record) {
7070
}
7171

7272
foreach ($record->get('fields') as $field) {
73-
// Write label and value on the same line
74-
// Calculate label width with proportional character spacing
75-
$labelWidth = $pdf->GetStringWidth($field['label'], 'freemono', '', self::LABEL_SIZE);
76-
$charCount = strlen($field['label']);
77-
$spacingPerChar = 0.5;
78-
$totalSpacing = $charCount * $spacingPerChar;
79-
$adjustedWidth = $labelWidth + $totalSpacing;
73+
if (!empty($field['label']) && $field['label'] !== "\u{200B}") {
74+
// Write label and value on the same line
75+
// Calculate label width with proportional character spacing
76+
$labelWidth = $pdf->GetStringWidth($field['label'], 'freemono', '', self::LABEL_SIZE);
77+
$charCount = strlen($field['label']);
78+
$spacingPerChar = 0.5;
79+
$totalSpacing = $charCount * $spacingPerChar;
80+
$adjustedWidth = $labelWidth + $totalSpacing;
8081

81-
static::writeText(
82-
$pdf, $field['label'],
83-
$currentX, $currentY,
84-
'freemono', 'B', self::LABEL_SIZE, 'L',
85-
$adjustedWidth, self::LABEL_SIZE, true, 0, $spacingPerChar
86-
);
82+
static::writeText(
83+
$pdf, $field['label'],
84+
$currentX, $currentY,
85+
'freemono', 'B', self::LABEL_SIZE, 'L',
86+
$adjustedWidth, self::LABEL_SIZE, true, 0, $spacingPerChar
87+
);
8788

88-
static::writeText(
89-
$pdf, $field['value'],
90-
$currentX + $adjustedWidth + 2, $currentY,
91-
'freemono', 'B', self::FIELD_SIZE, 'L',
92-
$usableWidth - $adjustedWidth - 2, self::FIELD_SIZE, true, 0, 0.3
93-
);
89+
static::writeText(
90+
$pdf, $field['value'],
91+
$currentX + $adjustedWidth + 2, $currentY,
92+
'freemono', 'B', self::FIELD_SIZE, 'L',
93+
$usableWidth - $adjustedWidth - 2, self::FIELD_SIZE, true, 0, 0.3
94+
);
95+
} else {
96+
97+
// Label is empty, so write value only.
98+
static::writeText(
99+
$pdf, $field['value'],
100+
$currentX, $currentY, // No offset
101+
'freemono', 'B', self::FIELD_SIZE, 'L',
102+
$usableWidth, self::FIELD_SIZE, true, 0, 0.3
103+
);
104+
}
94105

95106
$currentY += max(self::LABEL_SIZE, self::FIELD_SIZE) + self::FIELD_MARGIN;
96107
}

app/View/Label.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,13 @@ public function render(callable $callback = null)
177177
// The end result of this will be in this format:
178178
// {labelOne} {valueOne} | {labelTwo} {valueTwo} | {labelThree} {valueThree}
179179
$previous['value'] = trim(implode(' | ', [
180-
implode(' ', [null, $previous['value']]),
180+
implode(' ', [$previous['label'], $previous['value']]),
181181
implode(' ', [$current['label'], $current['value']]),
182182
]));
183183

184+
// We'll set the label to an empty string since we
185+
// injected the label into the value field above.
186+
$previous['label'] = '';
184187
return $previous;
185188
});
186189

0 commit comments

Comments
 (0)