Bug 19692 - [Qt] Support CSS2 Custom Fonts
Summary: [Qt] Support CSS2 Custom Fonts
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Enhancement
Assignee: Nobody
URL: http://www.alistapart.com/articles/cs...
Keywords: Qt
Depends on:
Blocks:
 
Reported: 2008-06-20 12:15 PDT by Pierre-Luc Beaudoin
Modified: 2008-12-12 01:42 PST (History)
1 user (show)

See Also:


Attachments
Hacki implementation (1.23 KB, patch)
2008-06-20 12:17 PDT, Pierre-Luc Beaudoin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Luc Beaudoin 2008-06-20 12:15:17 PDT
Supporting CSS2 custom fonts will be a great challenge since the Font in QtWebKit are very different from other ports.  This is due to the lack of glyph level API from Qt, which will is also preventing QtWebKit from passing Acid 3.
Comment 1 Pierre-Luc Beaudoin 2008-06-20 12:17:19 PDT
Created attachment 21859 [details]
Hacki implementation

In this hack, I was able to use the code that is already in place to get the Custom Font loaded.  This patch is an hack for many reasons:
- All fonts are loaded wether they are needed or not
- It by passes all the Font classes 
- It shortcuts the notifying 
- ...

Still, you can experience Custom Fonts with this patch.
Comment 2 Pierre-Luc Beaudoin 2008-06-20 12:19:23 PDT
A problem that will soon araise, is that once the font is loading into the QFontDatabase, only the family name from the .ttf file is actually available.  So if the CSS profices a different font-face name, QtWebKit won't be able to make the link between the given name and the actual name of the font.

Use of QFont::insertSubstitution should come over that issue, although you don't have access to both names anywhere in the code right now.
Comment 3 Pierre-Luc Beaudoin 2008-06-20 12:21:07 PDT
A quick look at other ports give us there pseudo call stack:

On page rendering:
Font::fontDataAt()
FontFallbackList::fontDataAt()
FontCache::getFontData()
CSSFontSelector->getFontData()
CSSFontFace->getFontData()
CSSFontFaceSource::getFontData()
CachedFont::beginLoadIfNeeded();
which will trigger the font request, and it will be downloaded

Once it is downloaded, 
CachedFont::checkNotify()
CSSFontFaceSource::fontLoaded(CachedFont*)
CSSFontFace::fontLoaded(CSSFontFaceSource*)
CSSSegmentedFontFace::fontLoaded(CSSFontFace*)
CSSFontSelector::fontLoaded(CSSSegmentedFontFace*)
m_document->renderer()->setNeedsLayoutAndPrefWidthsRecalc();
which will relayout the page using the new downloaded font.
Comment 4 Holger Freyther 2008-12-12 01:42:49 PST
With the recent font work the mentioned examples started to work.