diff --git a/www/go/core/install/install.sql b/www/go/core/install/install.sql index 611e4f28d..c82c48054 100644 --- a/www/go/core/install/install.sql +++ b/www/go/core/install/install.sql @@ -1098,6 +1098,8 @@ create table core_pdf_template footer text null, footerX decimal(19, 4) default 0.0000 null, footerY decimal(19, 4) default -20.0000 null, + fontFamily varchar(100) default 'dejavusans' not null, + fontSize tinyint default 10 null, constraint core_pdf_template_core_blob_id_fk foreign key (logoBlobId) references core_blob (id), constraint core_pdf_template_ibfk_1 diff --git a/www/go/core/install/updates.php b/www/go/core/install/updates.php index e8e517407..d3ac7bd99 100644 --- a/www/go/core/install/updates.php +++ b/www/go/core/install/updates.php @@ -1654,3 +1654,12 @@ $updates['202412090921'][] = "drop index accessToken on core_auth_token;"; + + +$updates['202501141553'][] = "alter table core_pdf_template + add fontFamily varchar(100) default 'dejavusans' not null;"; + +$updates['202501141553'][] = "alter table core_pdf_template + add fontSize tinyint default 10 null;"; + + diff --git a/www/go/core/model/PdfTemplate.php b/www/go/core/model/PdfTemplate.php index 59e45ac97..7df92c616 100644 --- a/www/go/core/model/PdfTemplate.php +++ b/www/go/core/model/PdfTemplate.php @@ -112,6 +112,10 @@ class PdfTemplate extends Entity { */ public $measureUnit = 'mm'; + public string $fontFamily = "dejavusans"; + + public int $fontSize = 10; + /** * @var PdfBlock[] */ diff --git a/www/go/core/util/PdfTemplateRenderer.php b/www/go/core/util/PdfTemplateRenderer.php index adb1be639..18521110d 100644 --- a/www/go/core/util/PdfTemplateRenderer.php +++ b/www/go/core/util/PdfTemplateRenderer.php @@ -65,6 +65,9 @@ public function __construct(PdfTemplate $template, $templateModels = []) { $this->parser->addModel($name, $model); } + $this->defaultFont = $this->template->fontFamily; + $this->defaultFontSize = $this->template->fontSize; + parent::__construct($orientation, $this->template->measureUnit, $this->template->pageSize); $this->SetTopMargin($this->template->marginTop); diff --git a/www/go/core/views/extjs3/pdftemplate/TemplateDialog.js b/www/go/core/views/extjs3/pdftemplate/TemplateDialog.js index d858c605f..2c6f21bb7 100644 --- a/www/go/core/views/extjs3/pdftemplate/TemplateDialog.js +++ b/www/go/core/views/extjs3/pdftemplate/TemplateDialog.js @@ -96,6 +96,30 @@ go.pdftemplate.TemplateDialog = Ext.extend(go.form.Dialog, { }), valueField: 'value', displayField: 'display' + },{ + xtype: 'combo', + name: 'fontFamily', + fieldLabel: t('Font'), + mode: 'local', + editable: false, + triggerAction: 'all', + value: "dejavusans", + store: new Ext.data.ArrayStore({ + fields: [ + 'value', + 'display' + ], + data: [['dejavusans', 'DejaVu Sans'], ['freesans', 'Freesans'],['freemono', 'Free mono'],['freeserif', 'Free serif'], ['helvetica', 'Helvetica'], ['times', 'Times New Roman', 'aefurat', "Arabic Furat"]] + }), + valueField: 'value', + displayField: 'display' + }, + + { + xtype: 'gonumberfield', + fieldLabel: t('Font size'), + name: 'fontSize', + value: 10 }, new go.form.FileButtonField({