Results 1 to 5 of 5

Thread: garbled text in iOS

  1. #1
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default garbled text in iOS

    Hi,

    I'm having problem with the font in iOS which seems to be pixelated or garbled.
    However it displayed perfectly in Android.

    The font was set using the following properties in qml file:

    Qt Code:
    1. font {
    2. pixelSize: 30
    3. fontFamily: "Arial"
    4. }
    To copy to clipboard, switch view to plain text mode 

    I already tried removing the aliases using the following properties but to no avail.

    setStyleStrategy(QFont::NoAntialias);
    setStyleStrategy(QFont::NoSubpixelAntialias);


    And

    setRenderHint(QPainter::Antialiasing, true);


    TIA.

  2. #2
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: garbled text in iOS

    It seems that the problem is with the scaling issue.
    When i run it into iphone 4S and 5/5S simulator, the text seems garbled and blurred rectangle.
    However if i'll run it itno iphone 6/6+ simulator, the text is okay however it isn't clear due to blurred rectangle.

    Qt Code:
    1. painter->setRenderHint(QPainter::Antialiasing, true);
    2.  
    3. painter->drawRoundedRect(rect, 2, 2);
    4.  
    5. // QPoints
    6.  
    7. painter->setRenderHint(QPainter::Antialiasing, false);
    8.  
    9. painter->drawPolygon(points, 5);
    To copy to clipboard, switch view to plain text mode 

    Please advise. TIA.
    Last edited by joko; 17th March 2015 at 12:39.

  3. #3
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: garbled text in iOS

    Update:

    Just found out that the device i'm testing width has retina display (4S).
    Please advise any tips that needs to be implemented since this is only happening on iOS build.

    Qt Code:
    1. void TabBar::paintBox(QPainter *painter, int x, const QString &text, const QSize &size, int index)
    2. {
    3.  
    4. painter->save();
    5.  
    6. QColor backgroundColor = active ? activeBg_ : inactiveBg_;
    7. QColor textColor = active ? activeFg_ : inactiveFg_;
    8.  
    9. painter->setBrush(backgroundColor);
    10.  
    11. QRect rect;
    12. QPoint points[6];
    13.  
    14. const int &width = size.width();
    15. const int &height = size.height();
    16.  
    17. int arrow = height / 2;
    18. if (arrow % 2 != 0)
    19. {
    20. arrow++;
    21. }
    22.  
    23. if (index == 0) {
    24. rect = QRect(x, 0, width, height);
    25.  
    26. painter->setRenderHint(QPainter::Antialiasing, true);
    27. painter->drawRoundedRect(rect, 2, 2);
    28.  
    29. points[0] = QPoint(width - 2, -1);
    30. points[1] = QPoint(width - 1, -1);
    31. points[2] = QPoint(width + arrow, height / 2);
    32. points[3] = QPoint(width - 1, height);
    33. points[4] = QPoint(width - 2, height);
    34.  
    35. painter->setRenderHint(QPainter::Antialiasing, false);
    36. painter->drawPolygon(points, 5);
    37.  
    38. rect.adjust(0, 0, 5, 0);
    39. } else {
    40. points[0] = QPoint(x, -1);
    41. points[1] = QPoint(x + width, -1);
    42. points[2] = QPoint(x + width + arrow, height / 2);
    43. points[3] = QPoint(x + width, height);
    44. points[4] = QPoint(x, height);
    45. points[5] = QPoint(x + arrow, height / 2);
    46.  
    47. painter->drawPolygon(points, 6);
    48. rect = QRect(x + arrow + 3, 0, width - arrow, height);
    49. }
    50.  
    51. painter->setPen(textColor);
    52. painter->drawText(rect, Qt::AlignCenter, text);
    53.  
    54. painter->restore();
    55. }
    To copy to clipboard, switch view to plain text mode 

    Sorry, i'm still new to QML c++ class such as QPainter.

    Thanks.
    Last edited by joko; 18th March 2015 at 14:04.

  4. #4
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: garbled text in iOS

    I stumbled upon this bug, seems that this is similar to my problem:

    https://bugreports.qt.io/browse/QTBUG-40489

    However, when I tried building the app on iPad which has retina display also, it showed perfectly.
    Seems that this is only happening to iOS mobile devices based on simulators testing.

    Btw, the class was implemented using QQuickPaintedItem.

    sample.png

    If you'll noticed on the picture above, the text and the edges weren't crisp and clear, it seems blurry.

    Please advise, TIA.

  5. #5
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: garbled text in iOS

    Hi Qt Masters,

    I'm still experiencing this issue, please advise.

    Thanks

Similar Threads

  1. Replies: 8
    Last Post: 7th November 2012, 19:20
  2. Garbled marks when moving items in QGraphicsScene
    By extralucas in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2010, 22:23
  3. XML resource is garbled?
    By space_otter in forum Qt Programming
    Replies: 8
    Last Post: 22nd June 2010, 01:09
  4. MySQL database ,Garbled
    By weixj2003ld in forum Qt Programming
    Replies: 7
    Last Post: 9th June 2009, 14:24
  5. Garbled fonts in QGraphicsView
    By StevenB in forum Qt Programming
    Replies: 6
    Last Post: 30th September 2007, 07:56

Bookmarks

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.