Bug 19692

Summary: [Qt] Support CSS2 Custom Fonts
Product: WebKit Reporter: Pierre-Luc Beaudoin <pierre-luc.beaudoin>
Component: WebKit QtAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Enhancement CC: jonathon
Priority: P2 Keywords: Qt
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
URL: http://www.alistapart.com/articles/cssatten
Attachments:
Description Flags
Hacki implementation none

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.