PDA

View Full Version : QPainter::drawText() with TT font does not print on printer- HELP



nish
17th December 2007, 13:53
Hi there...
I am ihaving problems in printing using a true type telugu language font..


I have some code like this


QString fontFamilyName="AnupamaMedium"; // Telugu Font (True Type)
//fontFamilyName="Arial";
font.setFamily(fontFamilyName);
font.setPointSize(26);

QChar qchar=140;//decimal value of 'Å’'
textToDraw=qchar;//shows as a square in debugger watch window
textToDraw="Å’";//shows as a square in debugger watch window
QByteArray barr="Å’";//This shows CORRECT in debugger watch window
pos=QPoint(50,50);
//"Å’" != "CE"... its a charecter of telugu font with value 140.

then QPainter::drawText(pos,textToDraw) is called in the paintEvent() and in
the printing function. the charecter draws well in the paintevent but not on the printer.

i think there is something to do with QString(or QTextCodec) here but i dont know what.

There is no problem with the font,,, because the same character shows and prints in
notepad.

I am attaching the sample code... please have a look and help.
thanks in advance.

PS- the font file is included in the zip

jacek
17th December 2007, 14:18
QChar qchar=140;//decimal value of 'Å’'
Are you sure? According to Unicode chart it should be 338.

nish
17th December 2007, 14:25
the character map application in windows shows the value as 0x8C(140 in hex)

install the font on your machine and and u can verify it too.
thx for replying so fast...

jacek
17th December 2007, 14:53
install the font on your machine and and u can verify it too.
Are we talking about one of these characters: http://unicode.org/charts/PDF/U0C00.pdf ?
Or U0152 from this chart: http://unicode.org/charts/PDF/U0100.pdf ?

nish
18th December 2007, 08:31
hey.. thx man.. my problem is solved...
i got the hint when is saw the unicode chart u pointed out..

i did it like this...

QChar unicodeChar1(0x0152); //'Œ'
textToDraw="Some telugu text and the this char-> Œ";
textToDraw.replace('Œ',unicodeChar1);

and everything printed good..
i have to did this for 10-15 more characters any whole problem was solved.

thx for your reply man..
bye
take care..