Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

displaying Arabic fonts in QtWebKit

I wrote a program with QtWebkit. I used Arabic fonts in this application. But the text as shown below was inapplicable. Whether there is a solution to fix it? text shown inapplicable in QtWebkit :
(source: shiaupload.ir)

text shown inapplicable:

an example code in here

html code: {

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html>
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head>


<style>
/*Twe Arabic font for test:*/
@font-face {
        font-family: '__me_quran';
        src: url(me_quran.ttf) format('truetype');
    }
@font-face {
        font-family: '__traditionalArabic';
        src: url(trado.ttf) format('truetype');
    }
 #para1
{
 font-family :/*__me_quran*/__traditionalArabic;
 text-align : justify;/*In this project i need justify alinement*/
 direction:rtl;
}


</style>
<script type="text/javascript" >
    var step=1;
    function plusZoom1(){
        document.getElementById("para1").style.zoom = parseFloat(step);
        step +=0.5;
    }

    function minusZoom1(){
        step -=0.5;
        document.getElementById("para1").style.zoom = parseFloat(step);
    }
</script>
<body>
<input type="button" value="+" onclick="plusZoom1();" />
<input type="button" value="-" onclick="minusZoom1();" />
<p id="para1">
       بِسْمِ اَللّٰهِ اَلرَّحْمٰنِ اَلرَّحِيمِ ( 1 )  اَلْحَمْدُ لِلّٰهِ رَبِّ اَلْعٰالَمِينَ ( 2 )  اَلرَّحْمٰنِ اَلرَّحِيمِ ( 3 )  مٰالِكِ يَوْمِ اَلدِّينِ ( 4 )  إِيّٰاكَ نَعْبُدُ وَ إِيّٰاكَ نَسْتَعِينُ ( 5 )  اِهْدِنَا اَلصِّرٰاطَ اَلْمُسْتَقِيمَ ( 6 )  صِرٰاطَ اَلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ اَلْمَغْضُوبِ عَلَيْهِمْ وَ لاَ اَلضّٰالِّينَ ( 7 ) 
</p>
</body>
</html>

}

qt code : {

#include <QtGui/QApplication>
#include <QWebView>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWebView wv;
    wv.setUrl(QUrl::QUrl("qrc:/rc/a.html"));
    wv.show();

    return a.exec();
}

}

like image 518
hassan deldar Avatar asked Sep 04 '12 19:09

hassan deldar


People also ask

Does calibri support Arabic?

Standard Microsoft fonts such as Times, Arial and Calibri will work fine with Arabic as long as you have Arabic support enabled on your system.

How do I change my font to Arabic?

Minimize Notepad and press Windows key + I to open the Windows 11 Settings. In the left pane, select the Personalization tab. In the right pane, select Fonts > Scroll down to find the font you want to use and copy its name. Go back to Notepad and replace FONT-STYLE with the desired font's name.

What is the best font for Arabic?

Arabic. Times New Roman* and Arial* are standard, professional fonts used in print and are legible for beginning Arabic learners. Other fonts that come on PCs include Traditional Arabic, Arabic Transparent, Arabic Typesetting, Aldhabi, Andalus, Sakkal Majalla, Segoe UI, Simplified Arabic, and Tahoma.

Which font is used for Arabic language?

Noto Sans Arabic is an unmodulated (“sans serif”) design for texts in the Middle Eastern Arabic script.


1 Answers

I faced similar problem long time back. Qt was not displaying some Arabic characters as they should appear. I had to change Qt's font drawing mechanism and use 'FreeType' font library for drawing fonts. You can use FreeType. More information here: http://freetype.sourceforge.net/index2.html

Or you may use some other graphics engine to bypass Qt's drawing - which can display these fonts.

like image 152
Aman Avatar answered Sep 19 '22 03:09

Aman