Results 1 to 1 of 1

Thread: QPainter and Freetype bitmap glyph rendering using fractional point coordinates

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Qt products
    MacOS X Windows

    Exclamation QPainter and Freetype bitmap glyph rendering using fractional point coordinates


    We are implementing WYSWYWG editor and writing Font Rendering Engine to comply our needs. We need glyph modifications at runtime and the same look and feel on different platforms, that's why we went implementing own Font Render engine (with Qt font engine we had several troubles with look and feel similarity).

    Our layout is scalable that's why we need fractional point advances.

    Trying to put glyph on QPainter canvas using drawImage() leads to discrete 1 pixel-based distance between glyphs.

    Here's an screenshot of this Screenshot 2015-12-09 19.22.56.png.

    I know the problem can be partially solved using sub-pixel positioning. Can you please help to extend this approach on QPainter usage (Antialisasing hint is turned on). I need some kind of algorithm to do it or proof it's not possible.

    For now we don't use LCD sub-pixel-antialiased glyphs, just A8 glyphs for simplicity. We disabled hinting either.

    How I understand this, how we try to implement this (please fix me if you see an error in algorithm, I'm just new to this):

    drawTextRun(run) pseudo code:

    0. pen=(0,0)
    1. spp = calculateSubpixelPosition(pen) // round to 1/4 pixel fraction, so 3 different glyphs per 1 symbol
    2. glyph = glyphCache.getGlyph(run[i], pixelSize, spp)
    3. advance = glyph.getAdvance() // advance is in FRACTIONAL, like 8.345
    4. painter.drawImage(QPointF(glyph.x, glyph.y), glyph.image); // When drawing image using fractional point coords QImage floors/rounds coordinates?!
    5. painter.translate(QPointF(advance,0));
    6. i = i+1, repeat from 2

    getGlyph() creates 1 of 3 glyphs representations, calling FT_Outline_Translate() to move glyph to the right on 1/4*x fractions.

    BUT drawImage still places image flooring/rounding fractional coordinates to int, so it ruins sub-pixel positioning work!

    I'd be very grateful for any hint to solve this problem. We need this ASAP.

    Thanks a lot for any hint/help on the issue!
    Last edited by leaxdc; 9th December 2015 at 19:07.

Similar Threads

  1. Cancelling last point displayed QPainter
    By ebsaith in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2013, 15:59
  2. coordinates and qt point
    By giugio in forum Qt Programming
    Replies: 0
    Last Post: 22nd November 2012, 14:04
  3. Get any point's Coordinates in a Curve
    By Schoumi in forum Qwt
    Replies: 8
    Last Post: 7th December 2011, 08:13
  4. Replies: 2
    Last Post: 20th September 2009, 03:59
  5. All font library has same glyph index for glyph ??
    By Gaurav K SIngh in forum Qt for Embedded and Mobile
    Replies: 16
    Last Post: 1st August 2007, 16:12

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.