Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFont stretch point size limitation

QFont stretch point size limitation

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pt_develop
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pt_develop
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved