Nominate our 2022 Qt Champions!

[Closed] Qt SVG rendering falls over when QFontDatabase is initialised

  • hi
    I developed a c++ library with Qt Creator for linux that generate png images from svg files, these images is then passsed back to the caller in a byte buffer. I also written a c++ application with Qt Creator that uses this library for testing purposes, to verify that the library is working correctly. I then created proxy library for java via swig, to utilise the library from a java application to create images/png’s via the c++ library.

    Everything work correctly in the Qt Creator application that uses the library.
    When uses the library from java, the application falls over, when a svg file with a text element have to be rendered.

    The error output that i get from java, hints that the code is falling over in the c++ library when parsing fontnames in the QFontDatabase. This happens when the render method on the QSvgRenderer is executed.
    Below is a copy of some of the error when using the library from java output:
    “Problematic frame:
    C [×3ef16b] QFontDatabase::parseFontName(QString const&, QString&, QString&)+0×21b “

    I then added a local variable in the c++ library method where the i am rendering the svg as follows, in order to locate the problem:

    QFontDatabase fdb ;
    QFont font = fdb.font("Arial","bold",9);
    qDebug() << "C++ API: font rawname:" + ;
    When using the c++ library with above code through the Qt application, it works 100%.
    When using the c++ library from java, it falls over exactly when trying to contruct the QFontDatabase above.

    All i can think, what the problem is, is that somehow, somewhere “pre initialasing” stuff is happening for the QFontDatabase when using it from the Qt application, and not the same stuff “happened” when using the library from java?
    It looks like the QFontDatabase code rezides in the library, maybe i have to do additional calls in my c++ library to get the QFontDatabase to construct correctly?
    I have a feeling/suspision that something in QtGui have to be initialsed for the QFontDatabase, to work correctly when the c++ library is called from java or any other language, but i have no idea what?

    The svg file is very simple it looks like this:
    <!DOCTYPE svg PUBLIC ‘-//W3C//DTD SVG 1.1//EN’ ‘’>
    <svg width=“400px” height=“400px” viewBox=“0 0 400 400” id=“S-GPUC——*****”> <g id=“group_scale” transform=“scale(1)”> <g> <text x=“200” y=“232” >CBT</text> </g> </g>

    Any svg document with a text element in, let the application crash with:
    “Problematic frame:
    C [×3ef16b] QFontDatabase::parseFontName(QString const&, QString&, QString&)+0×21b”

    All other svg documents without text elements renders correctly.

    Any help or suggestions will be highly appreciated.
    Thank you in advance.

    I am using the following:
    Qt Creator 2.1.0
    Based on Qt 4.7.2 (64 bit)

    Operating System:
    Ubuntu 11.04 64bit

  • Please dont start duplicated topics.

    "Original post":

  • Closing thread due to duplicate post.

Log in to reply