A free open source IT asset/license management system
add font getters and setters and hydration for 3490A 5267A 5520A
Godfrey Md2b64ca814da
diff --git a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.phpindex ceb2ab056e..220c12721b 100644--- a/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php+++ b/app/Models/Labels/CustomLabels/Concerns/RenderCustomLabelContent.php@@ -137,7 +137,7 @@ trait RenderCustomLabelContent$record->get('tag'),$layout['tag']['x'],$layout['tag']['y'],- 'freemono',+ $this->getTagFont(),'B',$layout['tag']['font_size'] ?? $this->getTagSize(),$this->getTagAlignment(),@@ -157,7 +157,7 @@ trait RenderCustomLabelContent$record->get('title'),$layout['title']['x'],$layout['title']['y'],- 'freesans',+ $this->getTitleFont(),'',$layout['title']['font_size'],'L',@@ -197,7 +197,7 @@ trait RenderCustomLabelContent$label,$layout['fields']['start_x'],$y,- 'freesans',+ $this->getFieldLabelFont(),'',$layout['fields']['label_size'],'L',@@ -214,7 +214,7 @@ trait RenderCustomLabelContent$value,$layout['fields']['value_x'],$y,- 'freemono',+ $this->getFieldValueFont(),'B',$layout['fields']['field_size'],'L',@@ -247,7 +247,7 @@ trait RenderCustomLabelContent$label,$layout['text']['x1'],$y,- 'freesans',+ $this->getFieldLabelFont(),'',$layout['fields']['label_size'],'L',@@ -265,7 +265,7 @@ trait RenderCustomLabelContent$value,$layout['text']['x1'],$y,- 'freemono',+ $this->getFieldValueFont(),'B',$layout['fields']['field_size'],'L',diff --git a/app/Models/Labels/CustomLabels/CustomSheetLabel.php b/app/Models/Labels/CustomLabels/CustomSheetLabel.phpindex df5ac21c6d..580f1f937b 100644--- a/app/Models/Labels/CustomLabels/CustomSheetLabel.php+++ b/app/Models/Labels/CustomLabels/CustomSheetLabel.php@@ -108,6 +108,10 @@ abstract class CustomSheetLabel extends RectangleSheetprotected float $tagOffsetX = 0.0;protected float $tagOffsetY = 0.0;+ protected string $tagFont = 'freemono';+ protected string $fieldLabelFont = 'freesans';+ protected string $fieldValueFont = 'freemono';+ protected string $titleFont = 'freesans';public function getTagOffsetX(): float{@@ -274,6 +278,26 @@ abstract class CustomSheetLabel extends RectangleSheetreturn $this->tagSize;}+ public function getTagFont(): string+ {+ return $this->tagFont;+ }++ public function getFieldLabelFont(): string+ {+ return $this->fieldLabelFont;+ }++ public function getFieldValueFont(): string+ {+ return $this->fieldValueFont;+ }++ public function getTitleFont(): string+ {+ return $this->titleFont;+ }+public function getTagAlignment(): string{return $this->tagAlignment;@@ -385,6 +409,10 @@ abstract class CustomSheetLabel extends RectangleSheet'field_value_margin' => $this->getFieldMargin(),'text_area_width' => $this->getTextAreaWidth(),'text_area_height' => $this->getTextAreaHeight(),+ 'tag_font' => $this->getTagFont(),+ 'title_font' => $this->getTitleFont(),+ 'field_label_font' => $this->getFieldLabelFont(),+ 'field_value_font' => $this->getFieldValueFont(),];}@@ -585,6 +613,10 @@ abstract class CustomSheetLabel extends RectangleSheet'logo_h_align' => 'logoHAlign','logo_v_align' => 'logoVAlign','tag_alignment' => 'tagAlignment',+ 'tag_font' => 'tagFont',+ 'title_font' => 'titleFont',+ 'field_label_font' => 'fieldLabelFont',+ 'field_value_font' => 'fieldValueFont',];foreach ($stringContentMap as $key => $property) {@@ -662,6 +694,10 @@ abstract class CustomSheetLabel extends RectangleSheet$this->titleOffsetX = isset($content['title_offset_x']) ? (float) $content['title_offset_x'] : $this->titleOffsetX;$this->labelMargin = isset($content['field_label_margin']) ? (float) $content['field_label_margin'] : $this->labelMargin;$this->fieldMargin = isset($content['field_value_margin']) ? (float) $content['field_value_margin'] : $this->fieldMargin;+ $this->tagFont = isset($content['tag_font']) ? (string)$content['tag_font'] : $this->tagFont;+ $this->titleFont = isset($content['title_font']) ? (string)$content['title_font'] : $this->titleFont;+ $this->fieldLabelFont = isset($content['field_label_font']) ? (string)$content['field_label_font'] : $this->fieldLabelFont;+ $this->fieldValueFont = isset($content['field_value_font']) ? (string)$content['field_value_font'] : $this->fieldValueFont;$this->barcode2DHAlign = isset($content['barcode2D_h_align'])? (string)$content['barcode2D_h_align']: $this->barcode2DHAlign;diff --git a/app/Models/Labels/CustomLabels/CustomTapeLabel.php b/app/Models/Labels/CustomLabels/CustomTapeLabel.phpindex ef9a74adb6..fab0049b26 100644--- a/app/Models/Labels/CustomLabels/CustomTapeLabel.php+++ b/app/Models/Labels/CustomLabels/CustomTapeLabel.php@@ -71,6 +71,10 @@ abstract class CustomTapeLabel extends Labelprotected int $rotation = 0;protected string $orientation = 'L';+ protected string $tagFont = 'freemono';+ protected string $fieldLabelFont = 'freesans';+ protected string $fieldValueFont = 'freemono';+ protected string $titleFont = 'freesans';public function getUnit(){return $this->unit;@@ -249,6 +253,25 @@ abstract class CustomTapeLabel extends Labelreturn $this->titleSize;}+ public function getTagFont(): string+ {+ return $this->tagFont;+ }++ public function getFieldLabelFont(): string+ {+ return $this->fieldLabelFont;+ }++ public function getFieldValueFont(): string+ {+ return $this->fieldValueFont;+ }++ public function getTitleFont(): string+ {+ return $this->titleFont;+ }public function getTitleMargin(): float{return $this->titleMargin;@@ -341,6 +364,10 @@ abstract class CustomTapeLabel extends Label'logo_h_align' => $this->getLogoHAlign(),'logo_v_align' => $this->getLogoVAlign(),'logo_placement' => $this->getLogoPlacement(),+ 'tag_font' => $this->getTagFont(),+ 'title_font' => $this->getTitleFont(),+ 'field_label_font' => $this->getFieldLabelFont(),+ 'field_value_font' => $this->getFieldValueFont(),];}@@ -452,6 +479,10 @@ abstract class CustomTapeLabel extends Label'logo_v_align' => 'logoVAlign','tag_alignment' => 'tagAlignment','logo_placement' => 'logoPlacement',+ 'tag_font' => 'tagFont',+ 'title_font' => 'titleFont',+ 'field_label_font' => 'fieldLabelFont',+ 'field_value_font' => 'fieldValueFont',];foreach ($stringContentMap as $key => $property) {@@ -522,6 +553,10 @@ abstract class CustomTapeLabel extends Label$this->logoHAlign = isset($content['logo_h_align']) ? (string)$content['logo_h_align'] : $this->logoHAlign;$this->logoVAlign = isset($content['logo_v_align']) ? (string)$content['logo_v_align'] : $this->logoVAlign;$this->logoPlacement = isset($content['logo_placement']) ? (string)$content['logo_placement'] : $this->logoPlacement;+ $this->tagFont = isset($content['tag_font']) ? (string)$content['tag_font'] : $this->tagFont;+ $this->titleFont = isset($content['title_font']) ? (string)$content['title_font'] : $this->titleFont;+ $this->fieldLabelFont = isset($content['field_label_font']) ? (string)$content['field_label_font'] : $this->fieldLabelFont;+ $this->fieldValueFont = isset($content['field_value_font']) ? (string)$content['field_value_font'] : $this->fieldValueFont;//If the logo and 2D barcode are both present, and one is moved to the other side, they will flip positions.if (array_key_exists('barcode2D_h_align', $content)) {@@ -810,7 +845,7 @@ abstract class CustomTapeLabel extends Label$record->get('tag'),$layout['tag']['x'],$layout['text']['y1'],- 'freemono',+ $this->getTagFont(),'B',$layout['text']['h'] + $this->getTextSizeMod(),$this->getTagAlignment(),@@ -864,7 +899,7 @@ abstract class CustomTapeLabel extends Label$field['value'] ?? '',$layout['text']['x1'],$layout['text']['y1'],- 'freemono',+ $this->getFieldValueFont(),'B',$layout['text']['h'] + $this->getTextSizeMod(),$this->getFieldAlignment(),diff --git a/app/Models/Labels/Sheets/Avery/_3490_A.php b/app/Models/Labels/Sheets/Avery/_3490_A.phpindex 13e0946536..cfbce085cb 100644--- a/app/Models/Labels/Sheets/Avery/_3490_A.php+++ b/app/Models/Labels/Sheets/Avery/_3490_A.php@@ -19,6 +19,9 @@ class _3490_A extends _3490private const FIELD_SIZE = 0.150;private const FIELD_MARGIN = 0.012;+ protected string $titleFont = 'freesans';+ protected string $fieldLabelFont = 'freesans';+ protected string $fieldValueFont = 'freemono';public function getBarcodeMargin(){@@ -115,6 +118,21 @@ class _3490_A extends _3490return true;}+ public function getTitleFont(): string+ {+ return $this->titleFont;+ }++ public function getFieldLabelFont(): string+ {+ return $this->fieldLabelFont;+ }++ public function getFieldValueFont(): string+ {+ return $this->fieldValueFont;+ }+protected function getContentEditorConfig(): array{return [@@ -126,6 +144,9 @@ class _3490_A extends _3490'field_label_margin' => $this->getLabelMargin(),'field_value_font_size' => $this->getFieldSize(),'field_value_margin' => $this->getFieldMargin(),+ 'title_font' => $this->getTitleFont(),+ 'field_label_font' => $this->getFieldLabelFont(),+ 'field_value_font' => $this->getFieldValueFont(),];}diff --git a/app/Models/Labels/Sheets/Avery/_5267_A.php b/app/Models/Labels/Sheets/Avery/_5267_A.phpindex 327f76eb92..0cb399d99b 100644--- a/app/Models/Labels/Sheets/Avery/_5267_A.php+++ b/app/Models/Labels/Sheets/Avery/_5267_A.php@@ -15,6 +15,9 @@ class _5267_A extends _5267private const FIELD_SIZE = 0.150;private const FIELD_MARGIN = 0.012;+ protected string $titleFont = 'freesans';+ protected string $fieldLabelFont = 'freesans';+ protected string $fieldValueFont = 'freemono';public function getBarcodeSize(){@@ -114,6 +117,21 @@ class _5267_A extends _5267return $barcode2dSize;}+ public function getTitleFont(): string+ {+ return $this->titleFont;+ }++ public function getFieldLabelFont(): string+ {+ return $this->fieldLabelFont;+ }++ public function getFieldValueFont(): string+ {+ return $this->fieldValueFont;+ }+protected function getContentEditorConfig(): array{return [@@ -136,6 +154,9 @@ class _5267_A extends _5267'fields' => $this->getSupportFields(),'logo' => $this->getSupportLogo(),'title' => $this->getSupportTitle(),+ 'title_font' => $this->getTitleFont(),+ 'field_label_font' => $this->getFieldLabelFont(),+ 'field_value_font' => $this->getFieldValueFont(),];}diff --git a/app/Models/Labels/Sheets/Avery/_5520_A.php b/app/Models/Labels/Sheets/Avery/_5520_A.phpindex 40f1c3f5a0..f77659ab27 100644--- a/app/Models/Labels/Sheets/Avery/_5520_A.php+++ b/app/Models/Labels/Sheets/Avery/_5520_A.php@@ -19,6 +19,9 @@ class _5520_A extends _5520private const FIELD_SIZE = 0.150;private const FIELD_MARGIN = 0.012;+ protected string $titleFont = 'freesans';+ protected string $fieldLabelFont = 'freesans';+ protected string $fieldValueFont = 'freemono';public function getBarcodeMargin(){@@ -115,6 +118,21 @@ class _5520_A extends _5520return true;}+ public function getTitleFont(): string+ {+ return $this->titleFont;+ }++ public function getFieldLabelFont(): string+ {+ return $this->fieldLabelFont;+ }++ public function getFieldValueFont(): string+ {+ return $this->fieldValueFont;+ }+protected function getSupportsEditorConfig(): array{return [@@ -138,6 +156,9 @@ class _5520_A extends _5520'field_label_margin' => $this->getLabelMargin(),'field_value_font_size' => $this->getFieldSize(),'field_value_margin' => $this->getFieldMargin(),+ 'title_font' => $this->getTitleFont(),+ 'field_label_font' => $this->getFieldLabelFont(),+ 'field_value_font' => $this->getFieldValueFont(),];}diff --git a/app/Services/CustomLabelImportValidator.php b/app/Services/CustomLabelImportValidator.phpindex bcb9498eb9..f44bea76ad 100644--- a/app/Services/CustomLabelImportValidator.php+++ b/app/Services/CustomLabelImportValidator.php@@ -99,6 +99,11 @@ class CustomLabelImportValidator'content.field_label_margin' => ['required', 'numeric'],'content.field_value_font_size' => ['required', 'numeric'],'content.field_value_margin' => ['required', 'numeric'],++ 'content.tag_font' => ['nullable', 'string'],+ 'content.title_font' => ['nullable', 'string'],+ 'content.field_label_font' => ['nullable', 'string'],+ 'content.field_value_font' => ['nullable', 'string'],];}@@ -281,6 +286,16 @@ class CustomLabelImportValidator'content.text_area_offset_y' => 'text area vertical offset','content.text_render_mode' => 'text render mode',+ /*+ |--------------------------------------------------------------------------+ | Fonts+ |--------------------------------------------------------------------------+ */+ 'content.tag_font' => 'tag font',+ 'content.title_font' => 'title font',+ 'content.field_label_font' => 'field label font',+ 'content.field_value_font' => 'field value font',+/*|--------------------------------------------------------------------------| Supports