BlueIceCream
15th December 2012, 17:01
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:
QChar data[] = {1576,1616,1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,35);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8502
there is all right and rendering is properly.
So i am using, for example, <em>arabic symbol</em> and write this code:
// 60,101,109,62 is <em> tag
// 60,47,101,109,62 is </em> tag
QChar data[] = {60,101,109,62,1576,1616,60,47,101,109,62,
1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,44);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8503
also for this example <span style="color:red">arabic symbol</span>
QChar data[] = {
// <span style="color:red">
60,115,112,97,110,32,115,116,121,108,101,
61,34,99,111,108,111,114,58,114,101,100,34,62,
1576,1616,
60,47,115,112,97,110,62, //</span>
1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,66);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8504
example for only first symbol
QChar data[] = {
// <span style="color:red">
60,115,112,97,110,32,115,116,121,108,101,
61,34,99,111,108,111,114,58,114,101,100,34,62,
1576,
60,47,115,112,97,110,62, //</span>
1616,1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,66);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8505
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.)
I am confusing with some strange things when using html tags with Arabic text.
For first for render text in Qlabel i use code:
QChar data[] = {1576,1616,1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,35);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8502
there is all right and rendering is properly.
So i am using, for example, <em>arabic symbol</em> and write this code:
// 60,101,109,62 is <em> tag
// 60,47,101,109,62 is </em> tag
QChar data[] = {60,101,109,62,1576,1616,60,47,101,109,62,
1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,44);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8503
also for this example <span style="color:red">arabic symbol</span>
QChar data[] = {
// <span style="color:red">
60,115,112,97,110,32,115,116,121,108,101,
61,34,99,111,108,111,114,58,114,101,100,34,62,
1576,1616,
60,47,115,112,97,110,62, //</span>
1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,66);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8504
example for only first symbol
QChar data[] = {
// <span style="color:red">
60,115,112,97,110,32,115,116,121,108,101,
61,34,99,111,108,111,114,58,114,101,100,34,62,
1576,
60,47,115,112,97,110,62, //</span>
1616,1587,1618,1605,1616,
1649,1604,1604,1617,1614,1607,1616,
1649,1604,1585,1617,1614,1581,1618,
1605,1614,1648,1606,1616,1649,1604,
1585,1617,1614,1581,1616,1610,1605,1616};
QString p(data,66);
ui->label->setFont(QFont("Scheherazade",45));
ui->label->setText(p);
The output:
8505
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.)