Results 1 to 2 of 2

Thread: html tags + arabic + Qt

  1. #1

    Default html tags + arabic + Qt

    Hello,

    I am confusing with some strange things when using html tags with Arabic text.

    For first for render text in Qlabel i use code:

    Qt Code:
    1. QChar data[] = {1576,1616,1587,1618,1605,1616,
    2. 1649,1604,1604,1617,1614,1607,1616,
    3. 1649,1604,1585,1617,1614,1581,1618,
    4. 1605,1614,1648,1606,1616,1649,1604,
    5. 1585,1617,1614,1581,1616,1610,1605,1616};
    6.  
    7. QString p(data,35);
    8.  
    9. ui->label->setFont(QFont("Scheherazade",45));
    10. ui->label->setText(p);
    To copy to clipboard, switch view to plain text mode 

    The output:
    query1.png
    there is all right and rendering is properly.

    So i am using, for example, <em>arabic symbol</em> and write this code:

    Qt Code:
    1. // 60,101,109,62 is <em> tag
    2. // 60,47,101,109,62 is </em> tag
    3.  
    4. QChar data[] = {60,101,109,62,1576,1616,60,47,101,109,62,
    5. 1587,1618,1605,1616,
    6. 1649,1604,1604,1617,1614,1607,1616,
    7. 1649,1604,1585,1617,1614,1581,1618,
    8. 1605,1614,1648,1606,1616,1649,1604,
    9. 1585,1617,1614,1581,1616,1610,1605,1616};
    10.  
    11. QString p(data,44);
    12.  
    13. ui->label->setFont(QFont("Scheherazade",45));
    14. ui->label->setText(p);
    To copy to clipboard, switch view to plain text mode 

    The output:
    query2.png

    also for this example <span style="color:red">arabic symbol</span>

    Qt Code:
    1. QChar data[] = {
    2. // <span style="color:red">
    3. 60,115,112,97,110,32,115,116,121,108,101,
    4. 61,34,99,111,108,111,114,58,114,101,100,34,62,
    5.  
    6. 1576,1616,
    7.  
    8. 60,47,115,112,97,110,62, //</span>
    9.  
    10. 1587,1618,1605,1616,
    11. 1649,1604,1604,1617,1614,1607,1616,
    12. 1649,1604,1585,1617,1614,1581,1618,
    13. 1605,1614,1648,1606,1616,1649,1604,
    14. 1585,1617,1614,1581,1616,1610,1605,1616};
    15.  
    16. QString p(data,66);
    17.  
    18. ui->label->setFont(QFont("Scheherazade",45));
    19. ui->label->setText(p);
    To copy to clipboard, switch view to plain text mode 

    The output:
    query3.png

    example for only first symbol
    Qt Code:
    1. QChar data[] = {
    2. // <span style="color:red">
    3. 60,115,112,97,110,32,115,116,121,108,101,
    4. 61,34,99,111,108,111,114,58,114,101,100,34,62,
    5.  
    6. 1576,
    7.  
    8. 60,47,115,112,97,110,62, //</span>
    9.  
    10. 1616,1587,1618,1605,1616,
    11. 1649,1604,1604,1617,1614,1607,1616,
    12. 1649,1604,1585,1617,1614,1581,1618,
    13. 1605,1614,1648,1606,1616,1649,1604,
    14. 1585,1617,1614,1581,1616,1610,1605,1616};
    15.  
    16. QString p(data,66);
    17.  
    18. ui->label->setFont(QFont("Scheherazade",45));
    19. ui->label->setText(p);
    To copy to clipboard, switch view to plain text mode 

    The output:

    query4.png

    Why when using html tags rendering is wrong? i check (color and em) in libreoffice with this font and all ok. But qt can't rendering it properly. Need help.

    PS. The task is rendering highlighted Arabic text on Qt widgets (QLabel, QTextEdit, etc.)

  2. #2

    Default Re: html tags + arabic + Qt

    Problem was solved.

    For correct rendering you must using &#x200D (zero-width joiner Unicode character).

    <p>عرب&#x200d;<span style="color: Red;">&#x200d;ي</span></p>

    You have to use it twice: at end of highlighted character and at start of other word's part. So character in word is connecting with special invisible character that hasn't width. When they rendering, render engine use connected form of Arabic letters. Because zwj hasn't width word not breaks.

Similar Threads

  1. QTextDocument and HTML tags
    By naga in forum Qt Programming
    Replies: 2
    Last Post: 13th December 2011, 12:22
  2. QRegExp for extracting the string between two HTML tags...
    By tuthmosis in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2010, 07:55
  3. Matching HTML tags
    By pucara_faa in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2010, 14:19
  4. Html tags in QTreeView
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2009, 02:41
  5. QFontMetrics and HTML tags
    By vonCZ in forum Newbie
    Replies: 1
    Last Post: 14th August 2008, 13:13

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.