首页 > 代码库 > Qt-4.8 WebKit + QtWebKit-2.3.x上CSS3 Web Fonts支持的一些记录

Qt-4.8 WebKit + QtWebKit-2.3.x上CSS3 Web Fonts支持的一些记录

 Chrome 37Firefox 32IE 8
TTF(TrueType)
OTF(OpenType)
WOFF
SVG
local()
EOT
WOFF 2.0

TTF/OTF格式的字体文件属于Web Fonts默认支持的;

WOFF需要开启一个条件宏,也没什么问题
EOT是IE专用的

SVG需要启用ENABLE(SVG_FONTS),问题是最终链接时报错:


g++ -fuse-ld=gold -Wl,--gc-sections -Wl,--no-undefined -Wl,-O1 -Wl,-rpath,/home/cteng/qt48/WebKitBuild/Release/lib -Wl,-rpath,/opt/browser13/qt/lib -o ../../bin/QtTestBrowser obj/release/QtInitializeTestFonts.o obj/release/locationedit.o obj/release/launcherwindow.o obj/release/main.o obj/release/mainwindow.o obj/release/urlloader.o obj/release/utils.o obj/release/webpage.o obj/release/webview.o obj/release/fpstimer.o obj/release/cookiejar.o obj/release/moc_locationedit.o obj/release/moc_launcherwindow.o obj/release/moc_mainwindow.o obj/release/moc_urlloader.o obj/release/moc_webinspector.o obj/release/moc_webpage.o obj/release/moc_webview.o obj/release/moc_fpstimer.o obj/release/moc_cookiejar.o obj/release/qrc_QtTestBrowser.o -L/home/cteng/qt48/WebKitBuild/Release/lib -L/opt/browser13/qt/plugins/platforms -L/opt/browser13/qt/plugins/generic -L/opt/browser13/qt/lib -L/usr/X11R6/lib -lQtWebKit -lgio-2.0 -lgstapp-0.10 -lgstpbutils-0.10 -lgstvideo-0.10 -lgstaudio-0.10 -lgstbase-0.10 -lgstinterfaces-0.10 -pthread -lgstfft-0.10 -lm -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lglib-2.0 -lQtSql -L/opt/browser13/qt/lib -lQtXmlPatterns -lQtOpenGL -L/usr/lib/i386-linux-gnu -lQtGui -lQtNetwork -lQtCore -lGLESv2 -lpthread 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::GlyphPageTreeNode::getRoot(unsigned int)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::GlyphPageTreeNode::getChild(WebCore::FontData const*, unsigned int)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::WidthIterator::WidthIterator(WebCore::Font const*, WebCore::TextRun const&, WTF::HashSet<WebCore::SimpleFontData const*, WTF::PtrHash<WebCore::SimpleFontData const*>, WTF::HashTraits<WebCore::SimpleFontData const*> >*, bool, bool)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::Font::glyphDataForCharacter(unsigned int, bool, WebCore::FontDataVariant) const‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(unsigned short const*, int, int, int)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::WidthIterator::advance(int, WebCore::GlyphBuffer*)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::SimpleFontData::widthForGlyph(unsigned short) const‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::Font::glyphDataAndPageForCharacter(unsigned int, bool, WebCore::FontDataVariant) const‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::SurrogatePairAwareTextIterator::advance(unsigned int)‘ 
/home/cteng/qt48/WebKitBuild/Release/lib/libQtWebKit.so: undefined reference to `WebCore::SurrogatePairAwareTextIterator::consume(unsigned int&, unsigned int&)‘ 


进一步调查发现,函数依赖于QRawFont特性,而这个特性在qt-4.8上不支持:


#if !(PLATFORM(QT) && !HAVE(QRAWFONT)) 
ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const 

    if (isZeroWidthSpaceGlyph(glyph)) 
        return FloatRect(); 

    FloatRect bounds; 
    if (m_glyphToBoundsMap) { 
        bounds = m_glyphToBoundsMap->metricsForGlyph(glyph); 
        if (bounds.width() != cGlyphSizeUnknown) 
            return bounds; 
    } 

    bounds = platformBoundsForGlyph(glyph); 
    if (!m_glyphToBoundsMap) 
        m_glyphToBoundsMap = adoptPtr(new GlyphMetricsMap<FloatRect>); 
    m_glyphToBoundsMap->setMetricsForGlyph(glyph, bounds); 
    return bounds; 


ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const 

    if (isZeroWidthSpaceGlyph(glyph)) 
        return 0; 

    float width = m_glyphToWidthMap.metricsForGlyph(glyph); 
    if (width != cGlyphSizeUnknown) 
        return width; 

    if (m_fontData) 
        width = m_fontData->widthForSVGGlyph(glyph, m_platformData.size()); 
#if ENABLE(OPENTYPE_VERTICAL) 
    else if (m_verticalData) 
#if USE(CG) || USE(CAIRO) || PLATFORM(WX) || USE(SKIA_ON_MAC_CHROMIUM) 
        width = m_verticalData->advanceHeight(this, glyph) + m_syntheticBoldOffset; 
#else 
        width = m_verticalData->advanceHeight(this, glyph); 
#endif 
#endif 
    else 
        width = platformWidthForGlyph(glyph); 

    m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 
    return width; 

#endif // HAVE(QRAWFONT) 



Qt-4.8 WebKit + QtWebKit-2.3.x上CSS3 Web Fonts支持的一些记录