From 5f3523970516eb8d989809745b6383349b373578 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 8 Feb 2024 21:51:32 +0000 Subject: [PATCH 1/3] Fixed CJK characters not rendering in new Label Engine [sc-24364] --- app/Http/Controllers/SettingsController.php | 36 +++++++++++++++++++ app/Models/Labels/DefaultLabel.php | 12 +++---- app/Models/Labels/Label.php | 3 ++ app/Models/Labels/Sheets/Avery/L7162_A.php | 12 ++++--- app/Models/Labels/Sheets/Avery/L7162_B.php | 8 ++--- app/Models/Labels/Sheets/Avery/L7163_A.php | 10 +++--- app/Models/Labels/Sheets/Avery/_5267_A.php | 4 +-- app/Models/Labels/Sheets/Avery/_5520_A.php | 6 ++-- .../Labels/Tapes/Brother/TZe_12mm_A.php | 4 +-- .../Labels/Tapes/Brother/TZe_24mm_A.php | 10 +++--- .../Labels/Tapes/Dymo/LabelWriter_30252.php | 10 +++--- app/View/Label.php | 14 ++++++-- resources/views/settings/labels.blade.php | 25 ++++++++++++- 13 files changed, 114 insertions(+), 40 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 31ea724c0e94..f99374e871c7 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -29,6 +29,7 @@ use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Validator; use Carbon\Carbon; +use TCPDF_FONTS; /** * This controller handles all actions related to Settings for @@ -812,9 +813,42 @@ public function getPhpInfo() */ public function getLabels() { + $fontlist = []; + // this is lifted pretty directly from TCPDF itself; unfortunately + // this method is not exposed, so I had to just steal it :( + if (($fontsdir = opendir(TCPDF_FONTS::_getfontpath())) !== false) { + while (($fontfile = readdir($fontsdir)) !== false) { + if (substr($fontfile, -4) == '.php') { + // these are the variables that are going to get loaded up when we do require() + $name=''; + $type=''; + $up=0; + $ut=0; + $dw=0; + $diff=''; + $originalsize=0; + $enc=''; + $file=''; + $ctg=''; + $desc=[]; + $cbbox=''; + // end require() variables + require(TCPDF_FONTS::_getfontpath()."/".$fontfile); // YUCK!!! + \Log::debug("name is: ".@$name." and "); + if(!$name) { + continue; //these are utility files; not real fonts? + } + $fontlist[strtolower(basename($fontfile, '.php'))] = $name; + } + } + closedir($fontsdir); + } + asort($fontlist, SORT_FLAG_CASE|SORT_STRING); + return view('settings.labels', [ 'setting' => Setting::getSettings(), 'customFields' => CustomField::all(), + 'fonts' => $fontlist ]); } @@ -840,6 +874,8 @@ public function postLabels(Request $request) $setting->label2_2d_type = $request->input('label2_2d_type'); $setting->label2_2d_target = $request->input('label2_2d_target'); $setting->label2_fields = $request->input('label2_fields'); + $setting->label2_mono_font = $request->input('label2_mono_font'); + $setting->label2_variable_font = $request->input('label2_variable_font'); $setting->labels_per_page = $request->input('labels_per_page'); $setting->labels_width = $request->input('labels_width'); $setting->labels_height = $request->input('labels_height'); diff --git a/app/Models/Labels/DefaultLabel.php b/app/Models/Labels/DefaultLabel.php index f06c4582f926..0de8b5b24581 100644 --- a/app/Models/Labels/DefaultLabel.php +++ b/app/Models/Labels/DefaultLabel.php @@ -153,7 +153,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $textX1, 0, - 'freesans', 'b', $this->textSize, 'L', + $this->variable_font, 'b', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); @@ -167,7 +167,7 @@ public function write($pdf, $record) { static::writeText( $pdf, 'N: '.$asset->name, $textX1, $textY, - 'freesans', '', $this->textSize, 'L', + $this->variable_font, '', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); @@ -180,7 +180,7 @@ public function write($pdf, $record) { static::writeText( $pdf, 'C: '.$asset->company->name, $textX1, $textY, - 'freesans', '', $this->textSize, 'L', + $this->variable_font, '', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); @@ -193,7 +193,7 @@ public function write($pdf, $record) { static::writeText( $pdf, 'T: '.$asset->asset_tag, $textX1, $textY, - 'freesans', '', $this->textSize, 'L', + $this->variable_font, '', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); @@ -206,7 +206,7 @@ public function write($pdf, $record) { static::writeText( $pdf, 'S: '.$asset->serial, $textX1, $textY, - 'freesans', '', $this->textSize, 'L', + $this->variable_font, '', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); @@ -219,7 +219,7 @@ public function write($pdf, $record) { static::writeText( $pdf, 'M: '.$asset->model->name, $textX1, $textY, - 'freesans', '', $this->textSize, 'L', + $this->variable_font, '', $this->textSize, 'L', $textW, $this->textSize, true, 0 ); diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.php index b727c1cb1898..df2e475e3a27 100644 --- a/app/Models/Labels/Label.php +++ b/app/Models/Labels/Label.php @@ -16,6 +16,9 @@ */ abstract class Label { + public string $variable_font; + public string $mono_font; + /** * Returns the unit of measure used * 'pt', 'mm', 'cm', 'in' diff --git a/app/Models/Labels/Sheets/Avery/L7162_A.php b/app/Models/Labels/Sheets/Avery/L7162_A.php index 0b3312ba7ce4..6919b0f9e8d4 100644 --- a/app/Models/Labels/Sheets/Avery/L7162_A.php +++ b/app/Models/Labels/Sheets/Avery/L7162_A.php @@ -45,7 +45,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'C', + $this->mono_font, 'b', self::TAG_SIZE, 'C', //was 'freemono' $barcodeSize, self::TAG_SIZE, true, 0 ); static::write2DBarcode( @@ -59,7 +59,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y1, - 'freemono', 'b', self::TITLE_SIZE, 'L', + $this->mono_font, 'b', self::TITLE_SIZE, 'L', //was 'freemono' $barcodeSize, self::TITLE_SIZE, true, 0 ); $titleShiftX = $barcodeSize; @@ -69,17 +69,19 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $currentX + $titleShiftX, $currentY, - 'freesans', '', self::TITLE_SIZE, 'L', + $this->variable_font, '', self::TITLE_SIZE, 'L', //was 'freesans' $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; } + // FONT FAMILY WORK: + // >>>>> WORKED'cid0cs', // 'unifont15104' // TOTAL DISASTER, // 'cid0cs', /* ALL FOUR!*/ // 'cid0ct', (3/4) // 'cid0cs'/* ALL FOUR!!!!! */,//'cid0jp' (3/4!), // 'cid0jp' (3/4!), //'cid0kr' (almost!), //'droidsansfallback', // 'couriernew', //'notosansmonocjkscvf', //'notosansmono', //'msungstdlight', // 'freeserif', // 'unifont15104', // 'robotomono', // $fontFamily, foreach ($record->get('fields') as $field) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', // also was 'freesans' $usableWidth, self::LABEL_SIZE, true, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -87,7 +89,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', // also was freemono? $usableWidth, self::FIELD_SIZE, true, 0, 0.3 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; diff --git a/app/Models/Labels/Sheets/Avery/L7162_B.php b/app/Models/Labels/Sheets/Avery/L7162_B.php index 268754e04f45..952c3420a70e 100644 --- a/app/Models/Labels/Sheets/Avery/L7162_B.php +++ b/app/Models/Labels/Sheets/Avery/L7162_B.php @@ -65,7 +65,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $currentX, $currentY, - 'freesans', '', self::TITLE_SIZE, 'L', + $this->variable_font, '', self::TITLE_SIZE, 'L', $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; @@ -75,7 +75,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', $usableWidth, self::LABEL_SIZE, true, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -83,7 +83,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', $usableWidth, self::FIELD_SIZE, true, 0, 0.3 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; @@ -92,7 +92,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $currentX, $pa->y2 - self::BARCODE_SIZE - self::BARCODE_MARGIN - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'R', + $this->mono_font, 'b', self::TAG_SIZE, 'R', $usableWidth, self::TAG_SIZE, true, 0, 0.3 ); diff --git a/app/Models/Labels/Sheets/Avery/L7163_A.php b/app/Models/Labels/Sheets/Avery/L7163_A.php index 6dc33f64dd44..3d6d0e1d4d09 100644 --- a/app/Models/Labels/Sheets/Avery/L7163_A.php +++ b/app/Models/Labels/Sheets/Avery/L7163_A.php @@ -42,7 +42,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $currentX, $currentY, - 'freesans', '', self::TITLE_SIZE, 'C', + $this->variable_font, '', self::TITLE_SIZE, 'C', $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; @@ -54,7 +54,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'C', + $this->mono_font, 'b', self::TAG_SIZE, 'C', $barcodeSize, self::TAG_SIZE, true, 0 ); static::write2DBarcode( @@ -68,7 +68,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'R', + $this->mono_font, 'b', self::TAG_SIZE, 'R', $usableWidth, self::TAG_SIZE, true, 0 ); } @@ -77,7 +77,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', $usableWidth, self::LABEL_SIZE, true, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -85,7 +85,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', $usableWidth, self::FIELD_SIZE, true, 0, 0.5 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; diff --git a/app/Models/Labels/Sheets/Avery/_5267_A.php b/app/Models/Labels/Sheets/Avery/_5267_A.php index efe0855d5e9f..dcdb6c83d419 100644 --- a/app/Models/Labels/Sheets/Avery/_5267_A.php +++ b/app/Models/Labels/Sheets/Avery/_5267_A.php @@ -43,7 +43,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $pa->x1, $pa->y1, - 'freesans', '', self::TITLE_SIZE, 'L', + $this->variable_font, '', self::TITLE_SIZE, 'L', $pa->w, self::TITLE_SIZE, true, 0 ); } @@ -55,7 +55,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $pa->x1, $fieldY, - 'freemono', 'B', self::FIELD_SIZE, 'C', + $this->mono_font, 'B', self::FIELD_SIZE, 'C', $pa->w, self::FIELD_SIZE, true, 0, 0.01 ); } diff --git a/app/Models/Labels/Sheets/Avery/_5520_A.php b/app/Models/Labels/Sheets/Avery/_5520_A.php index 199566d2485b..b3b9bfd65d4e 100644 --- a/app/Models/Labels/Sheets/Avery/_5520_A.php +++ b/app/Models/Labels/Sheets/Avery/_5520_A.php @@ -42,7 +42,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $pa->x1, $pa->y1, - 'freesans', '', self::TITLE_SIZE, 'C', + $this->variable_font, '', self::TITLE_SIZE, 'C', $pa->w, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; @@ -64,7 +64,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', $usableWidth, self::LABEL_SIZE, true, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -72,7 +72,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', $usableWidth, self::FIELD_SIZE, true, 0, 0.01 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; diff --git a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php index f89cfc5d47ef..d5cecc9d131b 100644 --- a/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php +++ b/app/Models/Labels/Tapes/Brother/TZe_12mm_A.php @@ -39,7 +39,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $currentY, - 'freemono', 'b', $fontSize, 'L', + $this->mono_font, 'b', $fontSize, 'L', $tagWidth, $usableHeight, true, 0, 0 ); @@ -47,7 +47,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('fields')->values()->get(0)['value'], $pa->x1 + ($tagWidth), $currentY, - 'freemono', 'b', $fontSize, 'R', + $this->mono_font, 'b', $fontSize, 'R', $fieldWidth, $usableHeight, true, 0, 0 ); } diff --git a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php index ea4c6c9dfba2..d6b70e74d5c6 100644 --- a/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php +++ b/app/Models/Labels/Tapes/Brother/TZe_24mm_A.php @@ -37,7 +37,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'C', + $this->mono_font, 'b', self::TAG_SIZE, 'C', $barcodeSize, self::TAG_SIZE, true, 0 ); static::write2DBarcode( @@ -51,7 +51,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'R', + $this->mono_font, 'b', self::TAG_SIZE, 'R', $usableWidth, self::TAG_SIZE, true, 0 ); } @@ -60,7 +60,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $currentX, $currentY, - 'freesans', '', self::TITLE_SIZE, 'L', + $this->variable_font, '', self::TITLE_SIZE, 'L', $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; @@ -70,7 +70,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', $usableWidth, self::LABEL_SIZE, true, 0, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -78,7 +78,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', $usableWidth, self::FIELD_SIZE, true, 0, 0.3 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; diff --git a/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php b/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php index d5f0e8d12229..0b03ae1e1fa8 100644 --- a/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php +++ b/app/Models/Labels/Tapes/Dymo/LabelWriter_30252.php @@ -40,7 +40,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'C', + $this->mono_font, 'b', self::TAG_SIZE, 'C', $barcodeSize, self::TAG_SIZE, true, 0 ); static::write2DBarcode( @@ -54,7 +54,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('tag'), $pa->x1, $pa->y2 - self::TAG_SIZE, - 'freemono', 'b', self::TAG_SIZE, 'R', + $this->mono_font, 'b', self::TAG_SIZE, 'R', $usableWidth, self::TAG_SIZE, true, 0 ); } @@ -63,7 +63,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $record->get('title'), $currentX, $currentY, - 'freesans', '', self::TITLE_SIZE, 'L', + $this->variable_font, '', self::TITLE_SIZE, 'L', $usableWidth, self::TITLE_SIZE, true, 0 ); $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; @@ -73,7 +73,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['label'], $currentX, $currentY, - 'freesans', '', self::LABEL_SIZE, 'L', + $this->variable_font, '', self::LABEL_SIZE, 'L', $usableWidth, self::LABEL_SIZE, true, 0, 0 ); $currentY += self::LABEL_SIZE + self::LABEL_MARGIN; @@ -81,7 +81,7 @@ public function write($pdf, $record) { static::writeText( $pdf, $field['value'], $currentX, $currentY, - 'freemono', 'B', self::FIELD_SIZE, 'L', + $this->mono_font, 'B', self::FIELD_SIZE, 'L', $usableWidth, self::FIELD_SIZE, true, 0, 0.3 ); $currentY += self::FIELD_SIZE + self::FIELD_MARGIN; diff --git a/app/View/Label.php b/app/View/Label.php index 83184e4b0491..4de59365cf42 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -35,7 +35,7 @@ public function __construct() { */ public function render(callable $callback = null) { - $settings = $this->data->get('settings'); + $settings = $this->data->get('settings'); //this has *ALL* settings!!! $assets = $this->data->get('assets'); $offset = $this->data->get('offset'); $template = $this->data->get('template'); @@ -64,6 +64,9 @@ public function render(callable $callback = null) [ $template->getWidth(), $template->getHeight() ] ); + // Required for CJK languages; otherwise the embedded font can get too massive + $pdf->SetFontSubsetting(true); + // Reset parameters $pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false); @@ -75,6 +78,9 @@ public function render(callable $callback = null) $pdf->SetSubject('Asset Labels'); $template->preparePDF($pdf); + $template->variable_font = $settings->label2_variable_font; + $template->mono_font = $settings->label2_mono_font; + // Get fields from settings $fieldDefinitions = collect(explode(';', $settings->label2_fields)) ->filter(fn($fieldString) => !empty($fieldString)) @@ -96,6 +102,7 @@ public function render(callable $callback = null) $title = str_replace('{COMPANY}', $asset->company->name, $settings->label2_title); $settings->qr_text; $assetData->put('title', $title); + \Log::error("THE TITLE YOU ARE TRYING TO PUT IS: $title"); } } @@ -167,10 +174,13 @@ public function render(callable $callback = null) if ($template instanceof Sheet) { $template->setLabelIndexOffset($offset ?? 0); } + //\Log::error("DUMPING all of the 'data' - ".print_r($data,true)); $template->writeAll($pdf, $data); $filename = $assets->count() > 1 ? 'assets.pdf' : $assets->first()->asset_tag.'.pdf'; - $pdf->Output($filename, 'I'); + set_time_limit(0); // ignore php timeout + + $pdf->Output($filename, 'I'); // KERPLOW - splodey splode. } /** diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index a6edd29154be..0f17f71ba2ec 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -122,7 +122,30 @@ class="table table-striped snipe-table" - + +
+
+ {{ Form::label('label2_variable_font','Variable-width font', ['class' => 'control-label']) }} +
+
+ {{ Form::select('label2_variable_font', $fonts, old('label2_variable_font', $setting->label2_variable_font), [ 'class'=>'select2 col-md-3', 'aria-label'=>'label2_variable_font' ]) }} + "FreeSans" is the default +
+
+ + +
+
+ {{ Form::label('label2_mono_font','Fixed-width font', ['class' => 'control-label']) }} +
+
+ {{ Form::select('label2_mono_font', $fonts, old('label2_mono_font', $setting->label2_mono_font), [ 'class'=>'select2 col-md-3', 'aria-label'=>'label2_mono_font' ]) }} + "FreeMono" is the default +
+
+ + +
has('label2_asset_logo') ? 'error' : '' }}">
From 76ebab465f7843e772fbdc3a9dff5d82b8fe73d6 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 8 Feb 2024 21:55:31 +0000 Subject: [PATCH 2/3] Whoops! Forgot the migration --- ...024_02_08_165209_add_fonts_to_settings.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 database/migrations/2024_02_08_165209_add_fonts_to_settings.php diff --git a/database/migrations/2024_02_08_165209_add_fonts_to_settings.php b/database/migrations/2024_02_08_165209_add_fonts_to_settings.php new file mode 100644 index 000000000000..07056cd4da03 --- /dev/null +++ b/database/migrations/2024_02_08_165209_add_fonts_to_settings.php @@ -0,0 +1,35 @@ +string('label2_variable_font')->default('freesans'); + $table->string('label2_mono_font')->default('freemono'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + // + $table->dropColumn(['label2_variable_font','label2_fixed_font']); + }); + } +} From dafbabf2cd1722a9b29e32d48bdac6288dbc904c Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Mon, 19 Feb 2024 13:55:52 +0000 Subject: [PATCH 3/3] Final fixups to make this fix Production-ready for [sc-24364] --- app/Models/Labels/Sheets/Avery/L7162_A.php | 2 -- app/View/Label.php | 5 +---- .../2024_02_08_165209_add_fonts_to_settings.php | 2 +- resources/lang/en-US/admin/settings/general.php | 4 ++++ resources/views/settings/labels.blade.php | 10 +++++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Models/Labels/Sheets/Avery/L7162_A.php b/app/Models/Labels/Sheets/Avery/L7162_A.php index 6919b0f9e8d4..9faf8f8a352a 100644 --- a/app/Models/Labels/Sheets/Avery/L7162_A.php +++ b/app/Models/Labels/Sheets/Avery/L7162_A.php @@ -75,8 +75,6 @@ public function write($pdf, $record) { $currentY += self::TITLE_SIZE + self::TITLE_MARGIN; } - // FONT FAMILY WORK: - // >>>>> WORKED'cid0cs', // 'unifont15104' // TOTAL DISASTER, // 'cid0cs', /* ALL FOUR!*/ // 'cid0ct', (3/4) // 'cid0cs'/* ALL FOUR!!!!! */,//'cid0jp' (3/4!), // 'cid0jp' (3/4!), //'cid0kr' (almost!), //'droidsansfallback', // 'couriernew', //'notosansmonocjkscvf', //'notosansmono', //'msungstdlight', // 'freeserif', // 'unifont15104', // 'robotomono', // $fontFamily, foreach ($record->get('fields') as $field) { static::writeText( $pdf, $field['label'], diff --git a/app/View/Label.php b/app/View/Label.php index 4de59365cf42..e8ae22fd933c 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -102,7 +102,6 @@ public function render(callable $callback = null) $title = str_replace('{COMPANY}', $asset->company->name, $settings->label2_title); $settings->qr_text; $assetData->put('title', $title); - \Log::error("THE TITLE YOU ARE TRYING TO PUT IS: $title"); } } @@ -174,13 +173,11 @@ public function render(callable $callback = null) if ($template instanceof Sheet) { $template->setLabelIndexOffset($offset ?? 0); } - //\Log::error("DUMPING all of the 'data' - ".print_r($data,true)); $template->writeAll($pdf, $data); $filename = $assets->count() > 1 ? 'assets.pdf' : $assets->first()->asset_tag.'.pdf'; - set_time_limit(0); // ignore php timeout - $pdf->Output($filename, 'I'); // KERPLOW - splodey splode. + $pdf->Output($filename, 'I'); } /** diff --git a/database/migrations/2024_02_08_165209_add_fonts_to_settings.php b/database/migrations/2024_02_08_165209_add_fonts_to_settings.php index 07056cd4da03..92f4eb93d6b4 100644 --- a/database/migrations/2024_02_08_165209_add_fonts_to_settings.php +++ b/database/migrations/2024_02_08_165209_add_fonts_to_settings.php @@ -29,7 +29,7 @@ public function down() { Schema::table('settings', function (Blueprint $table) { // - $table->dropColumn(['label2_variable_font','label2_fixed_font']); + $table->dropColumn(['label2_variable_font','label2_mono_font']); }); } } diff --git a/resources/lang/en-US/admin/settings/general.php b/resources/lang/en-US/admin/settings/general.php index 33cfd7b416fb..ba2ca8c87a0f 100644 --- a/resources/lang/en-US/admin/settings/general.php +++ b/resources/lang/en-US/admin/settings/general.php @@ -349,6 +349,10 @@ 'label2_2d_target_help' => 'The URL the 2D barcode points to when scanned', 'label2_fields' => 'Field Definitions', 'label2_fields_help' => 'Fields can be added, removed, and reordered in the left column. For each field, multiple options for Label and DataSource can be added, removed, and reordered in the right column.', + 'label2_variable_width_font' => 'Variable-width font', + 'label2_variable_width_font_hint' => '"FreeSans" is the default', + 'label2_fixed_width_font' => 'Fixed-width font', + 'label2_fixed_width_font_hint' => '"FreeMono" is the default', 'help_asterisk_bold' => 'Text entered as **text** will be displayed as bold', 'help_blank_to_use' => 'Leave blank to use the value from :setting_name', 'help_default_will_use' => ':default will use the value from :setting_name.
Note that the value of the barcodes must comply with the respective barcode spec in order to be successfully generated. Please see the documentation for more details. ', diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.php index 0f17f71ba2ec..9e34c761cd89 100644 --- a/resources/views/settings/labels.blade.php +++ b/resources/views/settings/labels.blade.php @@ -125,27 +125,27 @@ class="table table-striped snipe-table"
- {{ Form::label('label2_variable_font','Variable-width font', ['class' => 'control-label']) }} + {{ Form::label('label2_variable_font',trans('admin/settings/general.label2_variable_width_font'), ['class' => 'control-label']) }}
{{ Form::select('label2_variable_font', $fonts, old('label2_variable_font', $setting->label2_variable_font), [ 'class'=>'select2 col-md-3', 'aria-label'=>'label2_variable_font' ]) }} - "FreeSans" is the default + {{ trans('admin/settings/general.label2_variable_width_font_hint') }}
- {{ Form::label('label2_mono_font','Fixed-width font', ['class' => 'control-label']) }} + {{ Form::label('label2_mono_font',trans('admin/settings/general.label2_fixed_width_font'), ['class' => 'control-label']) }}
{{ Form::select('label2_mono_font', $fonts, old('label2_mono_font', $setting->label2_mono_font), [ 'class'=>'select2 col-md-3', 'aria-label'=>'label2_mono_font' ]) }} - "FreeMono" is the default + {{ trans('admin/settings/general.label2_fixed_width_font_hint') }}
- +
has('label2_asset_logo') ? 'error' : '' }}">