Font problem when deploying a Qt-based application to Ubuntu 10.10
Hi,
I'm deploying an application compiled against Qt (4.7.2, built from sources) to a pristine Ubuntu 10.10 system (default installation, no additional package installed, not even Qt).
Together with the application, I deploy a copy of the Qt libraries it requires (libQtCore4.so.4, libQtGui4.so.4, etc.) along the application's binary so that it can be run even if Qt is not installed on the system. (I'm aware this might not be The Right Way to deploy a Qt-based app; however it has some advantages and before I move on to a more standard scheme I'd like to make this one work.)
The application runs fine, however the font used to render the widgets gives absolutely horrid results:
http://appleseedhq.net/stuff/applese...nt-problem.png
I installed qtconfig and ran it. qtconfig itself displays correctly and the default font appears to be Ubuntu size 11. However this has no effect on the look of my application.
Any idea?
Cheers,
Franz
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
It almost looks like some sort of double wide character issue.
have you tried running the app with sudo?
what is the output from ldd?
For future reference - I'm just starting to learn InstallJammer to create linux installer packages, works quite nicely.
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
Hi schnitzel,
Thanks for your reply.
There is no difference when I run the app with sudo.
Here's the output of ldd:
$ ldd ./appleseed.studio
linux-vdso.so.1 => (0x00007fffdc7be000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00007feb04db9000)
libicuuc.so.42 => /usr/lib/libicuuc.so.42 (0x00007feb04a5d000)
libappleseed.so => ./libappleseed.so (0x00007feb0391c000)
libappleseed.shared.so => ./libappleseed.shared.so (0x00007feb036f8000)
libQtOpenGL.so.4 => ./libQtOpenGL.so.4 (0x00007feb033b5000)
libQtGui.so.4 => ./libQtGui.so.4 (0x00007feb02306000)
libQtCore.so.4 => ./libQtCore.so.4 (0x00007feb01d9d000)
libGLU.so.1 => /usr/lib/libGLU.so.1 (0x00007feb01b2a000)
libGL.so.1 => /usr/lib/mesa/libGL.so.1 (0x00007feb018b9000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x00007feb01583000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00007feb01370000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007feb0106a000)
libm.so.6 => /lib/libm.so.6 (0x00007feb00de7000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007feb00bd0000)
libc.so.6 => /lib/libc.so.6 (0x00007feb0084d000)
/lib64/ld-linux-x86-64.so.2 (0x00007feb04fe5000)
libicudata.so.42 => /usr/lib/libicudata.so.42 (0x00007feaff708000)
libdl.so.2 => /lib/libdl.so.2 (0x00007feaff503000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007feaff2f9000)
libpng15.so.15 => ./libpng15.so.15 (0x00007feaff0ce000)
libz.so.1 => /lib/libz.so.1 (0x00007feafeeb5000)
librt.so.1 => /lib/librt.so.1 (0x00007feafecad000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x00007feafeaa9000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00007feafe8a3000)
libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0x00007feafe69d000)
libdrm.so.2 => /lib/libdrm.so.2 (0x00007feafe491000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007feafe274000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00007feafe070000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007feafde6a000)
Note that I need to do
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/appleseed
prior to running the app so that the dynamic linker finds the Qt libraries (and the app-specific shared libraries like libappleseed.so and libappleseed.shared.so). Could this have an effect? I've noted that once I've done that in a terminal, qtconfig doesn't run from this terminal:
$ qtconfig
qtconfig: symbol lookup error: /usr/lib/libQtNetwork.so.4: undefined symbol: _ZN14QObjectPrivate15checkWindowRoleEv
(but it runs again as soon as I remove LD_LIBRARY_PATH).
Cheers,
Franz
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
I recommend the following for running the app so it can find all the libs:
create a file 'run-appleseed' with the following contents:
Code:
#!/bin/sh
if [ -n "." ] ; then
if [ "${LD_LIBRARY_PATH+set}" = "set" ] ; then
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:."
else
export LD_LIBRARY_PATH="."
fi
fi
exec ./appleseed.studio
this way, it doesn't affect the global LD_LIBRARY_PATH settings.
I just tried my app in a fresh ubuntu 10.10 install and did not see any font issue like you do.
Are you using a different than default font for your application?
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
Hey schnitzel,
Thanks for the script, it's indeed more convenient that way.
To answer your question: no, I'm not using a different font, I'm just using the default one.
Would you mind giving a try to my application on your clean Ubuntu system? The archive is completely self-contained. Unzip it somewhere, rename stylesheets/default.qss to e.g. stylesheets/default2.qss to disable stylesheets, go to bin/ and type run-appleseed.sh&. You'll get an error message saying that the stylesheet could not be loaded, but that's ok. (Note however that the problem is the same with the stylesheet.)
Here's the application archive:
http://appleseedhq.net/stuff/applese...nux64.gcc4.zip.
It's a 100 MB download as everything is compiled in debug with all symbols.
Thanks for your help.
Cheers,
Franz
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
Unfortunately, I don't have access to a 64 bit machine. Can you rebuild it for 32bit?
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
Quote:
Originally Posted by
schnitzel
Unfortunately, I don't have access to a 64 bit machine. Can you rebuild it for 32bit?
Ah, too bad. I can't easily recompile the app in 32-bit as I don't have a 32-bit system handy.
I have some new info about the issue though. The textedit Qt demo has the same problem as my app when I instruct the dynamic linker to use the Qt shared libs that I compiled myself:
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ; ./textedit
http://appleseedhq.net/stuff/textedit-font-problem.png
It looks like the Batang font (the first one in the list?) is used for the widgets. Note that if I run ./textedit without setting LD_LIBRARY_PATH first (so it'll be using Qt libs from /usr/lib) everything's fine.
So it seems the problem comes from my Qt libraries. I compiled an unmodified Qt 4.7.2 from sources using ./configure -opensource -debug followed by make ; make install. Nothing fancy.
Maybe I need to include/deploy some kind of configuration files together with my app? Fonts maybe?
Cheers,
Franz
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
More findings:
I ran Qt's textedit demo with strace, first when leaving LD_LIBRARY_PATH unmodified (so Qt libs in /usr/lib will be used), then when setting LD_LIBRARY_PATH to . to use my own Qt libs. Here are the results:
By diff'ing the two files, I found out that when LD_LIBRARY_PATH is not set (so Qt libs in /usr/lib are used) fonts are loaded:
access("/etc/fonts/fonts.conf", R_OK) = 0
stat("/etc/fonts/fonts.conf", {st_mode=S_IFREG|0644, st_size=5287, ...}) = 0
open("/etc/fonts/fonts.conf", O_RDONLY) = 7
read(7, "<?xml version=\"1.0\"?>\n<!DOCTYPE "..., 8192) = 5287
access("/etc/fonts/conf.d", R_OK) = 0
stat("/etc/fonts/conf.d", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/etc/fonts/conf.d", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 8
fcntl(8, F_GETFD) = 0x1 (flags FD_CLOEXEC)
brk(0x1929000) = 0x1929000
getdents(8, /* 38 entries */, 32768) = 1632
getdents(8, /* 0 entries */, 32768) = 0
access("/etc/fonts/conf.d/10-antialias.conf", R_OK) = 0
stat("/etc/fonts/conf.d/10-antialias.conf", {st_mode=S_IFREG|0644, st_size=223, ...}) = 0
open("/etc/fonts/conf.d/10-antialias.conf", O_RDONLY) = 9
read(9, "<?xml version=\"1.0\"?>\n<!DOCTYPE "..., 8192) = 223
read(9, "", 8192) = 0
close(9) = 0
access("/etc/fonts/conf.d/10-hinting-slight.conf", R_OK) = 0
When LD_LIBRARY_PATH is set, fonts don't seem to be loaded.
From the same strace logs, it appears that fonts are loaded when LD_LIBRARY_PATH is left unset because the library /usr/lib/libfontconfig.so.1 is loaded. When LD_LIBRARY_PATH is set, libfontconfig.so.1 is never loaded.
Cheers,
Franz
Added after 5 minutes:
Could the root cause of my troubles be that when I built Qt 4.7.2 from sources on my 64-bit Ubuntu 10.10 system, configure didn't find fontconfig?
Cheers,
Franz
Re: Font problem when deploying a Qt-based application to Ubuntu 10.10
Alright, in case someone had the same problems as I did and found this thread: the cause of all the troubles was that Qt was compiled without support for fontconfig. Just installing the -dev package for fontconfig and reconfiguring/rebuilding Qt completely solved the problem.
Cheers,
Franz