[Qt-interest] External font loading in Qt Webkit
Rajeev J Sebastian
rajeev.sebastian at gmail.com
Sun Jul 19 18:23:50 CEST 2009
On Sun, Jul 19, 2009 at 9:43 PM, Strahinja
Markovic<strahinja.markovic at gmail.com> wrote:
> Dear newsgroup,
>
> I believe I have found a bug in Qt. It pertains to external font loading
> with the “@font-face” CSS property.
>
> Two issues are present:
>
> 1. If we load both the regular and the italic versions of a font face from
> different font files and then specify that an HTML element should use that
> font face, the regular version of the font is displayed, but not the italic.
>
> Example CSS code:
>
> @font-face { font-family: "Fontin"; src: url(Fontin-Regular.ttf); }
> @font-face { font-family: "Fontin"; font-style: italic; src:
> url(Fontin-Italic.ttf); }
> body { font-family: "Fontin" }
>
> The regular style is displayed correctly, the italic isn’t. Same thing
> happens for bold versions and different font families/font files. Needless
> to say, this works in Firefox 3.5 and Safari 4.0.2.
>
> 2. My application uses the “contentEditable” property to enable editing of
> the loaded HTML file. If the user tries to make some regular text italic
> with “CTRL + I” (or invokes the command in some other way), the text isn’t
> displayed italic (because of issue #1, naturally). But if he then closes the
> application, it crashes with a segfault.
>
> I have also tried loading the fonts by hand with
> “QFontDatabase::addApplicationFont(const QString & fileName)” and it made no
> difference for either issue.
>
> I am providing a small test application that demonstrates issue #1. But for
> reasons that are beyond my comprehension, I am unable to replicate issue #2
> in a test application, although it is very easy to replicate in my program.
>
> Make sure that the font files are in the same folder as your executable, and
> that they are not installed in the system.
>
> I do have the next best thing for issue #2: start the “Browser” demo
> application that comes with Qt and open the “test.xhtml” file that comes
> with my test app for issue #1. Even without setting “contentEditable” to
> true and making some text italic by hand, it will crash on exit with a
> segfault. It will also display issue #1, that is, it won’t display italic
> text as italic. I have analyzed the stack trace for the crash in the
> “Browser” application and in my own, and they are practically identical: it’s
> the same bug, although it’s invoked in slightly different ways. I have
> included the stack trace for my application for reference.
>
> I have zipped up the font files and the source files for the test
> application and I have made it available at this location:
> http://www.sendspace.com/file/rqkh07
>
> For convenience, convention and posterity, the source files are inlined in
> this email, and the font files used in the example can be downloaded
> separately from here: http://www.josbuivenga.demon.nl/fontin.html
>
> This has all been tested on Vista x64 and Ubuntu 9.04. The Qt versions used
> were 4.5.2 and 4.5.0, respectively.
>
> Sincerely,
>
> Strahinja Markovic
>
>
> ************ test.xhtml ***************
>
> <?xml version="1.0" encoding="utf-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <style type="text/css">
> @font-face { font-family: "Fontin"; src: url(Fontin-Regular.ttf); }
> @font-face { font-family: "Fontin"; font-style: italic; src:
> url(Fontin-Italic.ttf); }
> body { font-family: "Fontin" }
> </style>
> </head>
> <body>
> <p>Normal text.</p>
> <p><i>Italic text.</i></p>
> </body>
> </html>
Maybe you should try:
<p class="emph">Italic text</p>
and a CSS rule:
p.emph { font-style: italic; }
Regards
Rajeev J Sebastian
More information about the Qt-interest-old
mailing list