mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added GNU unifont as fallback font for labels with CJK characters
This commit is contained in:
parent
6505af2a8b
commit
956ed9e8ae
10 changed files with 154 additions and 16 deletions
|
@ -181,7 +181,8 @@ Editor.defaultConfig = {
|
||||||
'DejaVu Serif, serif',
|
'DejaVu Serif, serif',
|
||||||
'Helvetica, Arial, sans-serif',
|
'Helvetica, Arial, sans-serif',
|
||||||
'Times New Roman, Times, serif',
|
'Times New Roman, Times, serif',
|
||||||
'Courier New, Courier, monospace'
|
'Courier New, Courier, monospace',
|
||||||
|
'Unifont, monospace',
|
||||||
],
|
],
|
||||||
supportAllValues: true
|
supportAllValues: true
|
||||||
},
|
},
|
||||||
|
|
3
assets/fonts/dompdf/.gitignore
vendored
Normal file
3
assets/fonts/dompdf/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Ignore font files
|
||||||
|
*.otf
|
||||||
|
*.ttf
|
1
assets/fonts/dompdf/README.md
Normal file
1
assets/fonts/dompdf/README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Put your font ttf files in this folder to make them available to the label generator.
|
|
@ -25,6 +25,7 @@
|
||||||
"florianv/swap-bundle": "dev-master",
|
"florianv/swap-bundle": "dev-master",
|
||||||
"gregwar/captcha-bundle": "^2.1.0",
|
"gregwar/captcha-bundle": "^2.1.0",
|
||||||
"jbtronics/2fa-webauthn": "^v2.0.0",
|
"jbtronics/2fa-webauthn": "^v2.0.0",
|
||||||
|
"jbtronics/dompdf-font-loader-bundle": "^1.0.0",
|
||||||
"jfcherng/php-diff": "^6.14",
|
"jfcherng/php-diff": "^6.14",
|
||||||
"league/csv": "^9.8.0",
|
"league/csv": "^9.8.0",
|
||||||
"league/html-to-markdown": "^5.0.1",
|
"league/html-to-markdown": "^5.0.1",
|
||||||
|
@ -35,6 +36,7 @@
|
||||||
"nyholm/psr7": "^1.1",
|
"nyholm/psr7": "^1.1",
|
||||||
"ocramius/proxy-manager": "2.2.*",
|
"ocramius/proxy-manager": "2.2.*",
|
||||||
"omines/datatables-bundle": "^0.7.2",
|
"omines/datatables-bundle": "^0.7.2",
|
||||||
|
"part-db/label-fonts": "^1.0",
|
||||||
"php-translation/symfony-bundle": "^0.13.0",
|
"php-translation/symfony-bundle": "^0.13.0",
|
||||||
"phpdocumentor/reflection-docblock": "^5.2",
|
"phpdocumentor/reflection-docblock": "^5.2",
|
||||||
"s9e/text-formatter": "^2.1",
|
"s9e/text-formatter": "^2.1",
|
||||||
|
|
119
composer.lock
generated
119
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "28e49fed0a1eb5f33d7ca39a19ba2fff",
|
"content-hash": "ac083d3e7e6f9bfde54fb37e99edf662",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "beberlei/assert",
|
"name": "beberlei/assert",
|
||||||
|
@ -2511,6 +2511,61 @@
|
||||||
},
|
},
|
||||||
"time": "2023-06-11T11:09:45+00:00"
|
"time": "2023-06-11T11:09:45+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "jbtronics/dompdf-font-loader-bundle",
|
||||||
|
"version": "v1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/jbtronics/dompdf-font-loader-bundle.git",
|
||||||
|
"reference": "8323aa3d4c3e70536b958a44f159208a6a0f7fa2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/jbtronics/dompdf-font-loader-bundle/zipball/8323aa3d4c3e70536b958a44f159208a6a0f7fa2",
|
||||||
|
"reference": "8323aa3d4c3e70536b958a44f159208a6a0f7fa2",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"dompdf/dompdf": "v1.0.0|v2.0.3",
|
||||||
|
"ext-json": "*",
|
||||||
|
"php": "^8.1",
|
||||||
|
"symfony/finder": "^6.0",
|
||||||
|
"symfony/framework-bundle": "^6.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.5",
|
||||||
|
"roave/security-advisories": "dev-latest",
|
||||||
|
"symfony/phpunit-bridge": "^6.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Jbtronics\\DompdfFontLoaderBundle\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jan Böhmer",
|
||||||
|
"email": "mail@jan-boehmer.de"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A symfony bundle to easily load custom fonts for dompdf (on cache warming)",
|
||||||
|
"keywords": [
|
||||||
|
"dompdf",
|
||||||
|
"fonts",
|
||||||
|
"symfony",
|
||||||
|
"symfony-bundle"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/jbtronics/dompdf-font-loader-bundle/issues",
|
||||||
|
"source": "https://github.com/jbtronics/dompdf-font-loader-bundle/tree/v1.0.0"
|
||||||
|
},
|
||||||
|
"time": "2023-07-02T00:21:14+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "jfcherng/php-color-output",
|
"name": "jfcherng/php-color-output",
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
|
@ -4139,6 +4194,44 @@
|
||||||
},
|
},
|
||||||
"time": "2022-06-14T06:56:20+00:00"
|
"time": "2022-06-14T06:56:20+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "part-db/label-fonts",
|
||||||
|
"version": "v1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/Part-DB/label-fonts.git",
|
||||||
|
"reference": "65f4a47d877f45e39804cd86a4fc65789b49ee2f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/Part-DB/label-fonts/zipball/65f4a47d877f45e39804cd86a4fc65789b49ee2f",
|
||||||
|
"reference": "65f4a47d877f45e39804cd86a4fc65789b49ee2f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"proprietary"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "The Part-DB Team",
|
||||||
|
"homepage": "https://github.com/Part-DB/Part-DB-server"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "This library bundles the fonts used in Part-DB for label generators. Fonts are work of others.",
|
||||||
|
"homepage": "https://github.com/Part-DB/Part-DB-server",
|
||||||
|
"keywords": [
|
||||||
|
"font",
|
||||||
|
"fonts",
|
||||||
|
"part-db"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/Part-DB/label-fonts/issues",
|
||||||
|
"source": "https://github.com/Part-DB/label-fonts/tree/v1.0.0"
|
||||||
|
},
|
||||||
|
"time": "2023-07-02T01:01:20+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phenx/php-font-lib",
|
"name": "phenx/php-font-lib",
|
||||||
"version": "0.5.4",
|
"version": "0.5.4",
|
||||||
|
@ -14370,16 +14463,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
"version": "1.10.21",
|
"version": "1.10.22",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
"reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5"
|
"reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5",
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/97d694dfd4ceb57bcce4e3b38548f13ea62e4287",
|
||||||
"reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5",
|
"reference": "97d694dfd4ceb57bcce4e3b38548f13ea62e4287",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -14428,7 +14521,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-06-21T20:07:58+00:00"
|
"time": "2023-06-30T20:04:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan-doctrine",
|
"name": "phpstan/phpstan-doctrine",
|
||||||
|
@ -14752,12 +14845,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Roave/SecurityAdvisories.git",
|
"url": "https://github.com/Roave/SecurityAdvisories.git",
|
||||||
"reference": "9920192eab87b9ae105696b0b86326c8fac91677"
|
"reference": "885786b30f50e83a88941df2062d68de623599fd"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/9920192eab87b9ae105696b0b86326c8fac91677",
|
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/885786b30f50e83a88941df2062d68de623599fd",
|
||||||
"reference": "9920192eab87b9ae105696b0b86326c8fac91677",
|
"reference": "885786b30f50e83a88941df2062d68de623599fd",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
|
@ -15011,7 +15104,7 @@
|
||||||
"marcwillmann/turn": "<0.3.3",
|
"marcwillmann/turn": "<0.3.3",
|
||||||
"matyhtf/framework": "<3.0.6",
|
"matyhtf/framework": "<3.0.6",
|
||||||
"mautic/core": "<4.3|= 2.13.1",
|
"mautic/core": "<4.3|= 2.13.1",
|
||||||
"mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35",
|
"mediawiki/core": "<=1.39.3",
|
||||||
"mediawiki/matomo": "<2.4.3",
|
"mediawiki/matomo": "<2.4.3",
|
||||||
"melisplatform/melis-asset-manager": "<5.0.1",
|
"melisplatform/melis-asset-manager": "<5.0.1",
|
||||||
"melisplatform/melis-cms": "<5.0.1",
|
"melisplatform/melis-cms": "<5.0.1",
|
||||||
|
@ -15229,7 +15322,7 @@
|
||||||
"thelia/thelia": ">=2.1-beta.1,<2.1.3",
|
"thelia/thelia": ">=2.1-beta.1,<2.1.3",
|
||||||
"theonedemon/phpwhois": "<=4.2.5",
|
"theonedemon/phpwhois": "<=4.2.5",
|
||||||
"thinkcmf/thinkcmf": "<=5.1.7",
|
"thinkcmf/thinkcmf": "<=5.1.7",
|
||||||
"thorsten/phpmyfaq": "<3.2-beta",
|
"thorsten/phpmyfaq": "<3.2-beta.2",
|
||||||
"tinymce/tinymce": "<5.10.7|>=6,<6.3.1",
|
"tinymce/tinymce": "<5.10.7|>=6,<6.3.1",
|
||||||
"tinymighty/wiki-seo": "<1.2.2",
|
"tinymighty/wiki-seo": "<1.2.2",
|
||||||
"titon/framework": ">=0,<9.9.99",
|
"titon/framework": ">=0,<9.9.99",
|
||||||
|
@ -15275,7 +15368,7 @@
|
||||||
"wintercms/winter": "<1.0.475|>=1.1,<1.1.10|>=1.2,<1.2.1",
|
"wintercms/winter": "<1.0.475|>=1.1,<1.1.10|>=1.2,<1.2.1",
|
||||||
"woocommerce/woocommerce": "<6.6",
|
"woocommerce/woocommerce": "<6.6",
|
||||||
"wp-cli/wp-cli": "<2.5",
|
"wp-cli/wp-cli": "<2.5",
|
||||||
"wp-graphql/wp-graphql": "<0.3.5",
|
"wp-graphql/wp-graphql": "<=1.14.5",
|
||||||
"wpanel/wpanel4-cms": "<=4.3.1",
|
"wpanel/wpanel4-cms": "<=4.3.1",
|
||||||
"wpcloud/wp-stateless": "<3.2",
|
"wpcloud/wp-stateless": "<3.2",
|
||||||
"wwbn/avideo": "<=12.4",
|
"wwbn/avideo": "<=12.4",
|
||||||
|
@ -15360,7 +15453,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-06-28T23:04:41+00:00"
|
"time": "2023-06-30T21:04:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/diff",
|
"name": "sebastian/diff",
|
||||||
|
|
|
@ -29,4 +29,5 @@ return [
|
||||||
Nbgrp\OneloginSamlBundle\NbgrpOneloginSamlBundle::class => ['all' => true],
|
Nbgrp\OneloginSamlBundle\NbgrpOneloginSamlBundle::class => ['all' => true],
|
||||||
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
|
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
|
||||||
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
|
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
|
||||||
|
Jbtronics\DompdfFontLoaderBundle\DompdfFontLoaderBundle::class => ['all' => true],
|
||||||
];
|
];
|
||||||
|
|
11
config/packages/dompdf_font_loader.yaml
Normal file
11
config/packages/dompdf_font_loader.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
dompdf_font_loader:
|
||||||
|
auto_install: true
|
||||||
|
|
||||||
|
fonts:
|
||||||
|
unifont:
|
||||||
|
normal: "%kernel.project_dir%/vendor/part-db/label-fonts/fonts/unifont.ttf"
|
||||||
|
|
||||||
|
# Enable autodiscovery of fonts, so that font installation is much easier
|
||||||
|
autodiscovery:
|
||||||
|
paths:
|
||||||
|
- "%kernel.project_dir%/assets/fonts/dompdf"
|
|
@ -92,4 +92,27 @@ The following variables are in injected into Twig and can be accessed using `{%
|
||||||
| `{% raw %}{{ element }}{% endraw %}` | The target element, selected in label dialog |
|
| `{% raw %}{{ element }}{% endraw %}` | The target element, selected in label dialog |
|
||||||
| `{% raw %}{{ user }}{% endraw %}` | The current logged in user. Null if you are not logged in |
|
| `{% raw %}{{ user }}{% endraw %}` | The current logged in user. Null if you are not logged in |
|
||||||
| `{% raw %}{{ install_title }}{% endraw %}` | The name of the current Part-DB instance (similar to [[INSTALL_NAME]] placeholder). |
|
| `{% raw %}{{ install_title }}{% endraw %}` | The name of the current Part-DB instance (similar to [[INSTALL_NAME]] placeholder). |
|
||||||
| `{% raw %}{{ page }}{% endraw %}` | The page number (the nth-element for which the label is generated |
|
| `{% raw %}{{ page }}{% endraw %}` | The page number (the nth-element for which the label is generated |
|
||||||
|
|
||||||
|
|
||||||
|
## Use custom fonts for PDF labels
|
||||||
|
You can use your own fonts for label generation. To do this, put the TTF files of the fonts you want to use into the `assets/fonts/dompdf` folder.
|
||||||
|
The filename will be used as name for the font family and you can use a `_bold` (or `_b`), `_italic` (or `_i`) or `_bold_italic` (or `_bi`) suffix to define
|
||||||
|
different styles of the font. So for example, if you copy the file `myfont.ttf` and `myfont_bold.ttf` into the `assets/fonts/dompdf` folder, you can use the font family `myfont` with regular and bold style.
|
||||||
|
Afterwards regenerate cache with `php bin/console cache:clear`, so the new fonts will be available for label generation.
|
||||||
|
|
||||||
|
The fonts will not be availble from the UI directly, you have to use it in the HTML directly either by defining a `style="font-family: 'myfont';"` attribute on the HTML element or by using a CSS class.
|
||||||
|
You can define the font globally for the label, by adding following statement to the "Additional styles (CSS)" option in the label generator settings:
|
||||||
|
```css
|
||||||
|
* {
|
||||||
|
font-family: 'myfont';
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Non-latin characters in PDF labels
|
||||||
|
The default used font (DejaVu) does not support all characters. Especially characters from non-latin languages like Chinese, Japanese, Korean, Arabic, Hebrew, Cyrillic, etc. are not supported.
|
||||||
|
For this we use [Unifont](http://unifoundry.com/unifont.html) as fallback font. This font supports all (or most) unicode characters, but is not as beautiful as DejaVu.
|
||||||
|
|
||||||
|
If you want to use a different (more beautiful) font, you can use the [custom fonts](#use-custom-fonts-for-pdf-labels) feature.
|
||||||
|
There is the [Noto](https://www.google.com/get/noto/) font family from Google, which supports a lot of languages and is available in different styles (regular, bold, italic, bold-italic).
|
||||||
|
For example you can use [Noto CJK](https://github.com/notofonts/noto-cjk) for more beautful Chinese, Japanese and Korean characters.
|
|
@ -177,6 +177,9 @@
|
||||||
"jbtronics/2fa-webauthn": {
|
"jbtronics/2fa-webauthn": {
|
||||||
"version": "dev-master"
|
"version": "dev-master"
|
||||||
},
|
},
|
||||||
|
"jbtronics/dompdf-font-loader-bundle": {
|
||||||
|
"version": "dev-main"
|
||||||
|
},
|
||||||
"laminas/laminas-code": {
|
"laminas/laminas-code": {
|
||||||
"version": "3.4.1"
|
"version": "3.4.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: "DejaVu Sans Mono";
|
font-family: "DejaVu Sans Mono", "unifont", monospace;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 1.0;
|
line-height: 1.0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue