Repository navigation
Closed
Labels
dependencyRelates to a project dependencydockerDocker / docker-composequestionThis is a questionsetupRelates to the InvenTree setup / installation processtranslation
Description
Please verify that this bug has NOT been raised before.
- I checked and didn't find a similar issue
Describe the bug*
When printing custom labels, Chinese cannot be output, you must manually add Chinese font support to successfully print Chinese labels.
Please see Bug Solution Record.
Steps to Reproduce
- Creat a Chinese headline part;
- Printer part label to pdf with Simple part label template;
- You can see no zh_cn text will be printed.
Expected behaviour
Possible problem to be solved: add Chinese font support in the officially given Docker container image.
Reason for needing to add font support to official mirrors: The update process given in the official help documentation requires the mirrors to be pulled and downloaded from the server again, and I'm not sure if this overrides the operation of adding font support manually, which would result in the user needing to once again re-add Chinese font support manually.
Deployment Method
- Docker
- Package
- Bare metal
- Other - added info in Steps to Reproduce
Version Information
# Version Information:
InvenTree-Version: 0.15.6
Django Version: 4.2.14
Commit Hash: 23a9485
Commit Date: 2024-07-23
Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-5.4.0-189-generic-x86_64-with
Installer: DOC
Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.0.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.0.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'IPNGenerator', 'slug': 'ipngen', 'version': '0.1'}]
Please verify if you can reproduce this bug on the demo site.
- I can reproduce this bug on the demo site.
Relevant log output
See [Bug Demo](https://github.com/inventree/InvenTree/issues/7735)Metadata
Metadata
Assignees
Labels
dependencyRelates to a project dependencydockerDocker / docker-composequestionThis is a questionsetupRelates to the InvenTree setup / installation processtranslation
Activity
SchrodingersGat commentedon Jul 26, 2024
@zly20129 can you please explain your process of "adding Chinese font support" - what additional packages are required, etc
zly20129 commentedon Jul 26, 2024
Oh, I apologize, I forgot to put the link to the detailed instructions here.
Please see here
SchrodingersGat commentedon Jul 27, 2024
There are a few ways we can tackle this:
Add Font Package
For Chinese font support, likely the package we need to add is font-isas-misc - this package adds around ~700KB to the base alpine image, so it not very heavy.
Extend Docker Image
Users can inherit from our base docker image to install whatever extra packages they need. No work required on our end but is on the user end.
Allow Custom Package Installation
There is already a feature request to this end - #5718
zly20129 commentedon Jul 27, 2024
Okay, I'm very much looking forward to the project team's improvements. Because as a user, having to manually reinstall the fonts all over again with every update and every restart of the server after changing environment variables is really too easy to forget.
SchrodingersGat commentedon Jul 27, 2024
@zly20129 do you have a setup running using our official docker image where you can run a test?
zly20129 commentedon Jul 27, 2024
Using the official docker mirror.
I ran it the first time after the download and used the command to query the Chinese fonts support list, but the terminal did not output any valid results, which means that there are no Chinese fonts in the official mirrors either.
I tried to test the Chinese label output on your demo site too, and the result is the same, it can't output double-width characters like Chinese, it's replaced with double-width blanks.
zly20129 commentedon Jul 27, 2024
If you happen to have the official image, then I would recommend using docker exec inventree-server fc-list :lang=zh to see if there is any output, if nothing else it is not outputting anything.
4 remaining items
zly20129 commentedon Jul 29, 2024
Incidentally, those two fonts were used as examples only because they came up most frequently when I was looking for solutions on Baidu, so I installed them.
matmair commentedon Jul 29, 2024
If we address this in core I would like to tackle at least most non-latin character sets. Google Fonts Noto might solve this problem. Having one font for all glyphs would also ensure consistency.
zly20129 commentedon Jul 30, 2024
Good idea!
SchrodingersGat commentedon Jul 30, 2024
@zly20129 can you please try the following:
docker compose exec inventree-server sudo apk add font-terminus font-inconsolata font-dejavu font-noto font-noto-cjk font-noto-extraDoes this setup provide font support as requested?
zly20129 commentedon Jul 30, 2024
All I can say is that they will appear in the Chinese language support list.
I downloaded and installed them using the proxy, then used docker exec inventree-server fc-list :lang=zh to see that Chinese supported fonts did appear in the output.
I then cleared my proxy settings for inventree-server and saved the config file.
However, after I executed docker compose up -d and docker compose restart, the docker image was restored and these installed fonts disappeared, and I wasn't able to test them to see if they could output labels with Chinese characters properly.
From a few hours ago, until now, I've been trying to install these fonts again, but unfortunately, whether using a proxy or not, they download extraordinarily slowly and then get stuck, and I've never been able to successfully download and install them again.
SchrodingersGat commentedon Aug 4, 2024
@zly20129 can you supply a report template / label template / etc where I can test character support locally? A simple
.htmltemplate file with some representative chinese characters / text would be sufficient I thinkzly20129 commentedon Aug 4, 2024
Okay! I will provide all my current custom templates, all temp~ use font is wqy-zenhei.
zly20129 commentedon Aug 4, 2024
@SchrodingersGat Stockitem_Label and Part_Label It's almost the same, so I won't write about it separately here.
棕色F6可组装抽屉式收纳盒
商品
收纳盒
抽屉式收纳盒
棕色F6可组装抽屉式收纳盒
棕色F6可组装抽屉式收纳盒;外尺寸24013078MM;内尺寸21511565MM;
待入库
等待分类入库的零件总类
SchrodingersGat commentedon Aug 14, 2024
@zly20129 OK I think I have this worked out now.
Part setup:
Normal docker setup:
After installing fonts:
Note that the label formatting is not great, but it proves the concept.
Update default fonts for docker image
Update default fonts for docker image (#7881)
Update default fonts for docker image (#7881)
Update default fonts for docker image (#7881) (#7884)