Supporting Qt application fonts on Symbian
authorAlessandro Portale <alessandro.portale@nokia.com>
Wed, 19 Jan 2011 12:16:13 +0000 (13:16 +0100)
committerJason McDonald <jason.mcdonald@nokia.com>
Thu, 20 Jan 2011 09:43:43 +0000 (19:43 +1000)
commit1600d0777f12e8dd180c9b32f192284f33468934
treea1c0955a9516ee441aaa4ada1a81641b81ba6c77
parent101ecddd24e194761cde0d84a421657c1206c506
Supporting Qt application fonts on Symbian

This patch finally implements the missing application font support on
Symbian. QFontDatabase's addApplicationFont[FromData],
applicationFontFamilies and removeApplicationFont are now functional and
allow an application to load, use and unload fonts at run-time.

The underlying Symbian API comes with some restrictions/specialties.
Most of them are worked around in this patch, the missing ones are left
as part of QTBUG-16514:

- The font file must be a file, not a memory buffer. Web fonts and qrc
fonts come as memory buffers. These buffers are saved to a temporary
.ttf file and the file is loaded by the underlying Symbian API. The
temporary file can only be deleted after the font is unloaded.

- The font file must be in a public location in order to be loadable by
Symbian. It can for example not reside in the private application
directory. Therefore, all application fonts (also those that are on the
file system) become a temporary .ttf file in c:\temp\.

- Symbian3/PR2 will come with a font table API which provides direct
access to font tables. Symbian3/PR1 and below are missing this API,
therefore, an own TFontStore is (ab)used to read font tables out of a
font. This patch is considering both code paths in several occasions,
making the Qt Symbian font implementation significantly less
maintainable.

- The fonts are loaded into Symbian's central font server. Loaded fonts
from different processes can have colliding font typeface names (not
file names) on that server. The server does not separate loaded fonts by
their origin processes. Working around such collisions is part of
QTBUG-16514.

The number of fonts loadable at the same time by a Qt application is
limited to the random value 5. Just to prevent abuse of the font
server's memory.

As usual, this patch was looked at by colleagues, and it was adjusted
according to the feedback. But since the bus factor for the
interaction of Qt's and Symbian's font systems is 1, I reviewed this
patch, myself.

Task-Number: QTBUG-6611
Autotest: tst_QFontDatabase::addAppFont
(cherry picked from commit 770fb729929764a1f1c5fbd3d54714cf811c81e0)
src/gui/kernel/qapplication_s60.cpp
src/gui/text/qfontdatabase.cpp
src/gui/text/qfontdatabase_s60.cpp
tests/auto/qfontdatabase/tst_qfontdatabase.cpp