QFont stretch point size limitation



  • Hi all;

    I'm trying to convert OpenOffice odt objects to images (jpeg,gif,png,etc.) for a project I'm working on and have run into a problem converting formula objects. The problem appears to be that the QFont stretch functionality ( i.e., font.setStretch(int factor)) does not work when the font point size is greater or equal to 48. It seems to work well when the point size is less than 48.

    I have tested this with various fonts (e.g, OpenSymbol, Segoe UI, DejaVu Sans, Ariel, Times New Roman,...) using font.setFamily() and various sizes using font.setPointSizeF() and font.setPointSize() to confirm the point size limitation. I ran into this limitation when I needed to compress large brackets such as [ or { in the OpenOffice generated formula objects.

    I've searched the Qt documentation, forums and googled the network but have not been able to find any other mention of this limitation. I'm wondering if anyone else has run up against this limitation. If so, have you figured out a work around?



  • I've found a work around that in some ways works better than the stretch function for my purposes.

    The procedure I used was to create a temporary QImage object that just fit the unstretched text dimensions. Then I used a temporary QPainter object to draw the unstretched text on the temporary image. Finally I used the regular QPainter object's function drawImage to draw the stretched text onto the original image. Since the temporary image is scaled to fit whatever QRect object is provided this allowed me to scale the width (i.e., stretch or compress) and height independently.

    The method has a couple of drawbacks. Getting the spacing correct was a little tricky but the major drawback is that the method scales a bitmap not a font. I still use the stretch function when the font is less than 48 points but for largerfonts this method seems to work ok.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.