Results 1 to 10 of 10

Thread: Qt 5.3.0 display Arabic text wrong :(

  1. #1
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Exclamation Qt 5.3.0 display Arabic text wrong :(

    I just used painter->drawText() to draw Arabic text(more than two lines)... but it display absolutely wrong! while i use QML to draw arabic text, it displays right....I am soooo confused, ive debuged the code, the glyph position( of course the positions are all wrong),,,, i thought it's the problem of new version harfbuzz-ng....but what confused me most that QML text and painter->drawtext() they are use the same harfbuzz ( i set a break point in harfbuzz-arabic.c) .... I am always thinking it's not hard for Qt itself to find out this bug,,,so how it happened like that? or i miss something? (i set the layout and wrapmode already,still same problem)....anyone could pls give me a hand?
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    You could use a QTextDocument instance to do the text layouting for you and then use its drawContents() method to draw the layouted text into a QPainter.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Thank you so much for you quick reply Yep, i just tried what you told me here, it works right for arabic and mix texts...but they must also share the same harfbuzz, what do you think of QPainter->drawText(), did you try the to use this one to draw text? same problem with me, right? QTextDocument may could be a good replacement, but dtawText is also widely used, i really wanna know what's wrong with it, ive debugged it(from the function "getGlyphPosition") but dont really know where the problem is...

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Quote Originally Posted by aniasen View Post
    Thank you so much for you quick reply Yep, i just tried what you told me here, it works right for arabic and mix texts...but they must also share the same harfbuzz
    A single QTextDocument only uses one layouting engine.

    Quote Originally Posted by aniasen View Post
    QTextDocument may could be a good replacement, but dtawText is also widely used
    I assume QTextDocument uses QPainter::drawText(), but on top of that performs text layouting.
    So it is not an either/or choice, more a with/without layout one.

    Cheers,
    _

  5. #5
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Quote Originally Posted by anda_skoa View Post
    A single QTextDocument only uses one layouting engine.


    I assume QTextDocument uses QPainter::drawText(), but on top of that performs text layouting.
    So it is not an either/or choice, more a with/without layout one.

    Cheers,
    _
    Thanks again! Acutally i dont really get what you mean I just wanna know if you guys had met the same problem using drawText ever, and if you guys have any idears about there the bug is?

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Please provide minimum compilable example reproducing the problem, so we can see your actual code and check if there is something wrong or not.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #7
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Quote Originally Posted by faldzip View Post
    Please provide minimum compilable example reproducing the problem, so we can see your actual code and check if there is something wrong or not.
    Oh yeah, sorry, i should have posted it. just very simple example like here, I dont really think its the problem of my code, i used the same code in qt4.8.3, it works fine...

    //just reinplement virtual function paintEvent and use QPainter instance to paint it

    void MainWindow:aintEvent(QPaintEvent *)
    {
    QPainter painter;
    painter.begin(this);

    QRect rect1 = QRect(20, 20, 760, 420);
    QRect rect2 = QRect(50,50,700,400);
    QPen pen=QPen(Qt::red);

    painter.setPen(pen);
    QFont font;
    font.setFamily("Droid Arabic Naskh");
    font.setItalic(false);
    font.setPixelSize(47);
    painter.setFont(font);

    QTextOption textOption;
    textOption.setTextDirection(Qt::LeftToRight);

    painter.drawText(rect1,QString::fromWCharArray(L"W elcome to the world of العالم في navigatio"),textOption);


    painter.end();
    }

  8. #8
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Thank god, finally i found how it happens....qt5.3.0 uses new unicode 6.3 while qt4.8.3 uses Unicode6.2... they have different ways to itemizer strings...like arabic text, in qt4.8.3,,e.g "العالم في" it will be itemizered into 3 items, second item is space button...while in qt5.3.0, it will just itemizer into 1 items...so when it counts width to draw text, it gets full width while just draw part of arabic string.......confused?! sorry im not native english speaker.....ok here is the place and they way to fix it... in file "qtextlayout.cpp" , line 2025,,, x position shouldnt be positioned by si.width as si is the item of all arabic text with space..... so should be " x += gf.width; " just hope you guys can see it and wont spend too much time on this stupid bugs by Qt....cheers, and thank you all

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Quote Originally Posted by aniasen View Post
    just hope you guys can see it and wont spend too much time on this stupid bugs by Qt....cheers, and thank you all
    Have you reported the problem and the fix so other won't run into the bug anymore?

    Cheers,
    _

  10. #10
    Join Date
    Oct 2013
    Location
    shanghai
    Posts
    14
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Qt 5.3.0 display Arabic text wrong :(

    Quote Originally Posted by anda_skoa View Post
    Have you reported the problem and the fix so other won't run into the bug anymore?

    Cheers,
    _
    Yeah, I did, you could visit QTBUG-40617 and they have confirmed it thank you so much btw!
    Last edited by anda_skoa; 15th August 2014 at 10:25. Reason: make link clickable

Similar Threads

  1. Replies: 0
    Last Post: 30th January 2014, 14:35
  2. Please help with Arabic text printing and PDF creation
    By ahmedb in forum Qt Programming
    Replies: 8
    Last Post: 11th November 2013, 22:10
  3. Arabic text rendering; issues with parentheses
    By TropicalPenguin in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2013, 10:53
  4. How to display text from a file to a text browser
    By ironmantis7x in forum Newbie
    Replies: 11
    Last Post: 14th June 2012, 16:23
  5. sort row by column , when getting text alwas wrong
    By umen in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2011, 09:35

Tags for this Thread

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.