Results 1 to 5 of 5

Thread: QPainter::drawText() with TT font does not print on printer- HELP

  1. #1
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default QPainter::drawText() with TT font does not print on printer- HELP

    Hi there...
    I am ihaving problems in printing using a true type telugu language font..


    I have some code like this

    Qt Code:
    1. QString fontFamilyName="AnupamaMedium"; // Telugu Font (True Type)
    2. //fontFamilyName="Arial";
    3. font.setFamily(fontFamilyName);
    4. font.setPointSize(26);
    5.  
    6. QChar qchar=140;//decimal value of 'Å’'
    7. textToDraw=qchar;//shows as a square in debugger watch window
    8. textToDraw="Å’";//shows as a square in debugger watch window
    9. QByteArray barr="Å’";//This shows CORRECT in debugger watch window
    10. pos=QPoint(50,50);
    11. //"Å’" != "CE"... its a charecter of telugu font with value 140.
    To copy to clipboard, switch view to plain text mode 

    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
    Attached Files Attached Files
    Last edited by jpn; 17th December 2007 at 19:10. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPainter::drawText() with TT font does not print on printer- HELP

    Quote Originally Posted by MrDeath View Post
    QChar qchar=140;//decimal value of 'Å’'
    Are you sure? According to Unicode chart it should be 338.

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPainter::drawText() with TT font does not print on printer- HELP

    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...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPainter::drawText() with TT font does not print on printer- HELP

    Quote Originally Posted by MrDeath View Post
    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 ?

  5. The following user says thank you to jacek for this useful post:

    nish (18th December 2007)

  6. #5
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPainter::drawText() with TT font does not print on printer- HELP

    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..

Similar Threads

  1. Change font in QPainter::drawText
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 19th May 2006, 16:21

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.