CQtDeployer icon indicating copy to clipboard operation
CQtDeployer copied to clipboard

QFontDatabase: Cannot find font directory <deploy_dir>/lib/fonts. Note that Qt no longer ships fonts. Deploy some (from http://dejavu-fonts.org for example) or switch to fontconfig.

Open laxian opened this issue 3 years ago • 2 comments

Describe the bug There is no text on UI, and the terminal says: QFontDatabase: Cannot find font directory ~/qt_hmi/lib/fonts. Note that Qt no longer ships fonts. Deploy some (from http://dejavu-fonts.org for example) or switch to fontconfig.

To Reproduce Steps to reproduce the behavior:

  1. cqtdeployer qif -qmake /home/vision_algo/qt-everywhere-src-5.15.5/qtbase/bin/qmake -bin qt_hmi -extraLibs icu
  2. ./DistributionKit/Installerqt_hmi.run
  3. start from terminal to see running log ~/qt_hmi/qt_hmi.sh

Screenshots image

Desktop

  • OS: Ubuntu
  • Version 18.04
  • Qt: 5.15.5

laxian avatar Aug 02 '22 09:08 laxian

Looks as you compile your qt with system founts.

I have a 2 solution for fix this issue

Solution 1

Recompile your qt with the -qt-freetype. See qt docs to get more information.

  -freetype ............ Select used FreeType [system/qt/no]

Solution 2

Add freetype libs to your distributive. CQtDeployer not deploy system libs by default because it is not secure. You can force deploy all needed system libs to your distribution using deploySystem option,

But better solution is an add only freeType libs to your distro

cqtdeployer -extraLibs freetype,libpng

EndrII avatar Aug 02 '22 09:08 EndrII

Note that Qt no longer ships fonts. Deploy some (from http://dejavu-fonts.org for example) or switch to fontconfig.

About this. Qt not ships fonts in framework distribution, so CQtDeployer does not deploy them by default.

Looks to the official qt distribution directory

~/Qt/5.15.2/gcc_64/lib$ tree -d
.
├── cmake
│   ├── Qt5
│   ├── Qt53DAnimation
│   ├── Qt53DCore
│   ├── Qt53DExtras
│   ├── Qt53DInput
│   ├── Qt53DLogic
│   ├── Qt53DQuick
│   ├── Qt53DQuickAnimation
│   ├── Qt53DQuickExtras
│   ├── Qt53DQuickInput
│   ├── Qt53DQuickRender
│   ├── Qt53DQuickScene2D
│   ├── Qt53DRender
│   ├── Qt5AccessibilitySupport
│   ├── Qt5AttributionsScannerTools
│   ├── Qt5Bluetooth
│   ├── Qt5Bodymovin
│   ├── Qt5Charts
│   ├── Qt5Concurrent
│   ├── Qt5Core
│   ├── Qt5DataVisualization
│   ├── Qt5DBus
│   ├── Qt5Designer
│   ├── Qt5DesignerComponents
│   ├── Qt5DeviceDiscoverySupport
│   ├── Qt5DocTools
│   ├── Qt5EdidSupport
│   ├── Qt5EglFSDeviceIntegration
│   ├── Qt5EglFsKmsSupport
│   ├── Qt5EglSupport
│   ├── Qt5EventDispatcherSupport
│   ├── Qt5FbSupport
│   ├── Qt5FontDatabaseSupport
│   ├── Qt5Gamepad
│   ├── Qt5GlxSupport
│   ├── Qt5Gui
│   ├── Qt5Help
│   ├── Qt5InputSupport
│   ├── Qt5KmsSupport
│   ├── Qt5LinguistTools
│   ├── Qt5LinuxAccessibilitySupport
│   ├── Qt5Location
│   ├── Qt5Multimedia
│   ├── Qt5MultimediaGstTools
│   ├── Qt5MultimediaQuick
│   ├── Qt5MultimediaWidgets
│   ├── Qt5Network
│   ├── Qt5NetworkAuth
│   ├── Qt5Nfc
│   ├── Qt5OpenGL
│   ├── Qt5OpenGLExtensions
│   ├── Qt5PacketProtocol
│   ├── Qt5PlatformCompositorSupport
│   ├── Qt5Positioning
│   ├── Qt5PositioningQuick
│   ├── Qt5PrintSupport
│   ├── Qt5Purchasing
│   ├── Qt5Qml
│   ├── Qt5QmlDebug
│   ├── Qt5QmlDevTools
│   ├── Qt5QmlImportScanner
│   ├── Qt5QmlModels
│   ├── Qt5QmlWorkerScript
│   ├── Qt5Quick
│   ├── Qt5Quick3D
│   ├── Qt5Quick3DAssetImport
│   ├── Qt5Quick3DRender
│   ├── Qt5Quick3DRuntimeRender
│   ├── Qt5Quick3DUtils
│   ├── Qt5QuickCompiler
│   ├── Qt5QuickControls2
│   ├── Qt5QuickParticles
│   ├── Qt5QuickShapes
│   ├── Qt5QuickTemplates2
│   ├── Qt5QuickTest
│   ├── Qt5QuickWidgets
│   ├── Qt5RemoteObjects
│   ├── Qt5RepParser
│   ├── Qt5Script
│   ├── Qt5ScriptTools
│   ├── Qt5Scxml
│   ├── Qt5Sensors
│   ├── Qt5SerialBus
│   ├── Qt5SerialPort
│   ├── Qt5ServiceSupport
│   ├── Qt5Sql
│   ├── Qt5Svg
│   ├── Qt5Test
│   ├── Qt5TextToSpeech
│   ├── Qt5ThemeSupport
│   ├── Qt5UiPlugin
│   ├── Qt5UiTools
│   ├── Qt5VirtualKeyboard
│   ├── Qt5VulkanSupport
│   ├── Qt5WaylandClient
│   ├── Qt5WaylandCompositor
│   ├── Qt5WebChannel
│   ├── Qt5WebEngine
│   ├── Qt5WebEngineCore
│   ├── Qt5WebEngineWidgets
│   ├── Qt5WebSockets
│   ├── Qt5WebView
│   ├── Qt5Widgets
│   ├── Qt5X11Extras
│   ├── Qt5XcbQpa
│   ├── Qt5XkbCommonSupport
│   ├── Qt5Xml
│   └── Qt5XmlPatterns
├── metatypes
└── pkgconfig

111 directories

EndrII avatar Aug 02 '22 10:08 EndrII

@EndrII Thank you a lot,the solution 2 works! But there is another problem. When I start app after deployment,I got an error: `qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/gaofeng/qt_hmi/plugins//platforms:" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Aborted (core dumped)`

I put the file libxcb-xinput.so.0 into the lib folder of deployment dir, which solved the problem. Why?

laxian avatar Aug 23 '22 06:08 laxian

I found a solution that works. sudo apt-get install libxcb-xinput0 https://askubuntu.com/questions/1194024/libxcb-xinput-so-0-cannot-open-shared-object-file-no-such-file-or-directory

I really do not understand what I means. I'm a newcomer of QT. Is there any solution better? thanks for all your replies.

laxian avatar Aug 23 '22 06:08 laxian

@EndrII Thank you a lot,the solution 2 works! But there is another problem. When I start app after deployment,I got an error: `qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/gaofeng/qt_hmi/plugins//platforms:" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Aborted (core dumped)`

I put the file libxcb-xinput.so.0 into the lib folder of deployment dir, which solved the problem. Why?

All Qt plugins loaded dynamical in run time, so your application will be run successful anyway, but if the plugins have unresolved dependencies your app will be crashed or some functions will not work correctly.

About libxcb-xinput.so.0 This is system library, usually this library located in system that use X-Display system and not needed to deploy.

:~$ locate libxcb-xinput
/usr/lib/i386-linux-gnu/libxcb-xinput.so.0
/usr/lib/i386-linux-gnu/libxcb-xinput.so.0.1.0
/usr/lib/x86_64-linux-gnu/libxcb-xinput.so.0
/usr/lib/x86_64-linux-gnu/libxcb-xinput.so.0.1.0

But if you want to deploy this automatically, just allow to deploy all libxcb-xinput libs for cqtdeployer.

Add extraLibs option for your command.

cqtdeployer -extraLibs "libxcb-xinput,freetype,libpng" ... 

P.S. I think all libxcb libraries can be to add into white list of deploy. This is allowing to deploy xcb libs automatically for cqtdeployer.

EndrII avatar Aug 23 '22 07:08 EndrII

@laxian please close this issue if you solve it.

EndrII avatar Aug 23 '22 07:08 EndrII