Results 1 to 17 of 17

Thread: QWebView doesn't display correctly unicode

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWebView doesn't display correctly unicode

    well when open and read by python there are utf-8 encoded characters:
    <html>\n<head><title>\xc4\xbe\xc5\xa1\xc4\x8d\xc5\ xa5\xc5\xbe\xc3\xbd\xc3\xa1\xc3\xad\xc3\xa9\xc3\xa 4\xc3\xba\xc3\xb4!!!</title>\n<meta http-equiv=Content-Type content=text/html; charset=UTF-8>\n</head>\n<body bgcolor='blue'>\n<center><H1>\xc4\xbe\xc5\xa1\xc4\ x8d\xc5\xa5\xc5\xbe\xc3\xbd\xc3\xa1\xc3\xad\xc3\xa 9\xc3\xa4\xc3\xba\xc3\xb4</H1></center>\n<hr>\xd0\x9f\xd1\x80\xd0\xb8 \xd0\xb4\xd0\xbe\xd1\x81\xd1\x82\xd1\x83\xd0\xbf\x d0\xb5 \xd0\xba \xd1\x81\xd0\xb0\xd0\xb9\xd1\x82\xd1\x83 \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb8\xd0\xb7\xd0\xbe\x d1\x88\xd0\xbb\xd0\xb0 \xd0\xbe\xd1\x88\xd0\xb8\xd0\xb1\xd0\xba\xd0\xb0. \xd0\x9f\xd0\xbe\xd0\xb6\xd0\xb0\xd0\xbb\xd1\x83\x d0\xb9\xd1\x81\xd1\x82\xd0\xb0 \xd0\xbf\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb5\xd1\x80\x d1\x8c\xd1\x82\xd0\xb5 \xd0\xb2\xd0\xb0\xd1\x88\xd0\xb5 \xd0\xbf\xd0\xbe\xd0\xb4\xd0\xba\xd0\xbb\xd1\x8e\x d1\x87\xd0\xb5\xd0\xbd\xd0\xb8\xd0\xb5 \xd0\xba \xd0\xb8\xd0\xbd\xd1\x82\xd0\xb5\xd1\x80\xd0\xbd\x d0\xb5\xd1\x82\xd1\x83.\n</body>\n</html>

    so encoding should be correct.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView doesn't display correctly unicode

    I meant the file from my example. Besides I can't really see the utf-8 encoding among this garbage
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWebView doesn't display correctly unicode

    What file you mean from your example?
    OK start from beginning:
    I create a file index.html with utf-8 encoding and also save file as utf-8:
    Qt Code:
    1. <html>
    2. <head>
    3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    4. </head>
    5. <body>
    6. <h1>ľščťžýáÃ*</h1>
    7. </body>
    8. </html>
    To copy to clipboard, switch view to plain text mode 

    The use this code to display content (web is filename):
    Qt Code:
    1. QTextStream in(&web);
    2. in.setCodec("utf8");
    3. view->setHtml(in.readAll(), QUrl("file:///home/www/"));
    To copy to clipboard, switch view to plain text mode 

    but on display I can see only ýáÃ*.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView doesn't display correctly unicode

    Quote Originally Posted by binaural View Post
    What file you mean from your example?
    The one with the label code. I suggest you start with getting that to work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWebView doesn't display correctly unicode

    Well problem found. Problem was in font type. It seems unicode font doesn't support special characters. After enabling freetype text is correctly displayed.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView doesn't display correctly unicode

    Quote Originally Posted by binaural View Post
    It seems unicode font doesn't support special characters. After enabling freetype text is correctly displayed.
    Aren't you mixing two terms here? "Unicode font" is not about font format, it's about font encoding. Freetype fonts are "unicode fonts" too.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QWebView doesn't display correctly unicode

    Yes maybe I wasn't precise. I was playing with fonts and if I don't compile freetype support to qt default font for displaying was family unifont (unifont_160_50.qpf). After installing truetype default font became (Dejavu Sans) which could correctly display all character which I need. I would say that unifont doesn't contain all special character.

    With Dejavu Sans font text is correctly displayed but default font weight is bigger like for unifont and items are shifted. I try to change font weight by:
    Qt Code:
    1. QFont web_font("DejaVu Sans", 6);
    2.  
    3. qDebug() << font.weight() << " " << font.pointSize();
    4.  
    5. web_font.setPointSize(6);
    6. web_font.setWeight(20);
    7. view->setFont(web_font);
    To copy to clipboard, switch view to plain text mode 

    but there's no effect (text has same weight and size). Is there any option which I'm missing to set?

    Thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView doesn't display correctly unicode

    .qpf fonts are bitmap fonts. But you can generate your own .qpf from a font of your choice so I guess you can make one from DejaVu Sans and have proper glyphs available in .qpf.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 31st August 2011, 16:15
  2. Unicode Font Display Problem
    By QbelcorT in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd September 2009, 06:11
  3. Reg QWebview Display
    By Tavit in forum Qt Programming
    Replies: 0
    Last Post: 5th August 2009, 15:19
  4. Problems to display a QFont in a View/Model correctly
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 8th July 2009, 12:26
  5. QTableView does not display time string correctly
    By ad5xj in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2007, 20:35

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.