Changeset 46885 in webkit
- Timestamp:
- Aug 6, 2009 10:39:44 PM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r46884 r46885 1 2009-08-06 Yusuke Sato <yusukes@chromium.org> 2 3 Reviewed by David Levin. 4 5 Chromium Linux: add support for @font-face 6 https://bugs.webkit.org/show_bug.cgi?id=28015 7 8 * loader/CachedFont.cpp: 9 (WebCore::CachedFont::~CachedFont): 10 (WebCore::CachedFont::ensureCustomFontData): 11 (WebCore::CachedFont::platformDataFromCustomData): 12 (WebCore::CachedFont::allClientsRemoved): 13 14 Modified #ifdefs so that chromium linux can load remote fonts. 15 16 * platform/graphics/chromium/FontCustomPlatformData.cpp: 17 (WebCore::FontCustomPlatformData::~FontCustomPlatformData): 18 (WebCore::FontCustomPlatformData::fontPlatformData): 19 (WebCore::createFontCustomPlatformData): 20 21 Create SkTypeface for a web font by calling SkTypeface::CreateFromStream function. 22 23 (WebCore::RemoteFontStream::RemoteFontStream): 24 (WebCore::RemoteFontStream::~RemoteFontStream): 25 (WebCore::RemoteFontStream::rewind): 26 (WebCore::RemoteFontStream::read): 27 28 New class that implements SkStream interface and wraps wtf's SharedBuffer. 29 30 * platform/graphics/chromium/FontCustomPlatformData.h: 31 (WebCore::FontCustomPlatformData::FontCustomPlatformData): 32 33 Added member variables for Linux. 34 1 35 2009-08-06 Yong Li <yong.li@torchmobile.com> 2 36 -
trunk/WebCore/loader/CachedFont.cpp
r44749 r46885 32 32 #include "DOMImplementation.h" 33 33 #include "FontPlatformData.h" 34 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && PLATFORM(WIN_OS))34 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (PLATFORM(WIN_OS) || PLATFORM(LINUX))) 35 35 #include "FontCustomPlatformData.h" 36 36 #endif … … 61 61 CachedFont::~CachedFont() 62 62 { 63 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && PLATFORM(WIN_OS))63 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (PLATFORM(WIN_OS) || PLATFORM(LINUX))) 64 64 delete m_fontData; 65 65 #endif … … 99 99 bool CachedFont::ensureCustomFontData() 100 100 { 101 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && PLATFORM(WIN_OS))101 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (PLATFORM(WIN_OS) || PLATFORM(LINUX))) 102 102 #if ENABLE(SVG_FONTS) 103 103 ASSERT(!m_isSVGFont); … … 118 118 return FontPlatformData(size, bold, italic); 119 119 #endif 120 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && PLATFORM(WIN_OS))120 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (PLATFORM(WIN_OS) || PLATFORM(LINUX))) 121 121 ASSERT(m_fontData); 122 122 return m_fontData->fontPlatformData(static_cast<int>(size), bold, italic, renderingMode); … … 174 174 void CachedFont::allClientsRemoved() 175 175 { 176 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && PLATFORM(WIN_OS))176 #if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (PLATFORM(WIN_OS) || PLATFORM(LINUX))) 177 177 if (m_fontData) { 178 178 delete m_fontData; -
trunk/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
r42060 r46885 37 37 #include "ChromiumBridge.h" 38 38 #include "OpenTypeUtilities.h" 39 #elif PLATFORM(LINUX) 40 #include "SkStream.h" 39 41 #endif 40 42 … … 47 49 #include <t2embapi.h> 48 50 #pragma comment(lib, "t2embed") 51 #elif PLATFORM(LINUX) 52 #include <cstring> 49 53 #endif 50 54 … … 61 65 RemoveFontMemResourceEx(m_fontReference); 62 66 } 67 #elif PLATFORM(LINUX) 68 if (m_fontReference) 69 m_fontReference->unref(); 63 70 #endif 64 71 } … … 103 110 HFONT hfont = CreateFontIndirect(&logFont); 104 111 return FontPlatformData(hfont, size); 112 #elif PLATFORM(LINUX) 113 ASSERT(m_fontReference); 114 return FontPlatformData(m_fontReference, size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic()); 105 115 #else 106 116 notImplemented(); … … 187 197 #endif 188 198 199 #if PLATFORM(LINUX) 200 class RemoteFontStream : public SkStream { 201 public: 202 explicit RemoteFontStream(PassRefPtr<SharedBuffer> buffer) 203 : m_buffer(buffer) 204 , m_offset(0) 205 { 206 } 207 208 virtual ~RemoteFontStream() 209 { 210 } 211 212 virtual bool rewind() 213 { 214 m_offset = 0; 215 return true; 216 } 217 218 virtual size_t read(void* buffer, size_t size) 219 { 220 if (!buffer && !size) { 221 // This is request for the length of the stream. 222 return m_buffer->size(); 223 } 224 if (!buffer) { 225 // This is a request to skip bytes. This operation is not supported. 226 return 0; 227 } 228 // This is a request to read bytes. 229 if (!m_buffer->data() || !m_buffer->size()) 230 return 0; 231 size_t left = m_buffer->size() - m_offset; 232 size_t toRead = (left > size) ? size : left; 233 std::memcpy(buffer, m_buffer->data() + m_offset, toRead); 234 m_offset += toRead; 235 return toRead; 236 } 237 238 private: 239 RefPtr<SharedBuffer> m_buffer; 240 size_t m_offset; 241 }; 242 #endif 243 189 244 FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) 190 245 { … … 224 279 225 280 return new FontCustomPlatformData(fontReference, fontName); 281 #elif PLATFORM(LINUX) 282 RemoteFontStream stream(buffer); 283 SkTypeface* typeface = SkTypeface::CreateFromStream(&stream); 284 if (!typeface) 285 return 0; 286 return new FontCustomPlatformData(typeface); 226 287 #else 227 notImplemented(); ;288 notImplemented(); 228 289 return 0; 229 290 #endif -
trunk/WebCore/platform/graphics/chromium/FontCustomPlatformData.h
r39875 r46885 33 33 #define FontCustomPlatformData_h 34 34 35 #include "FontRenderingMode.h" 35 36 #include <wtf/Noncopyable.h> 36 37 37 38 #if PLATFORM(WIN_OS) 38 #include "FontRenderingMode.h"39 39 #include "PlatformString.h" 40 40 #include <windows.h> 41 #elif PLATFORM(LINUX) 42 #include "SkTypeface.h" 41 43 #endif 42 44 … … 52 54 , m_name(name) 53 55 {} 56 #elif PLATFORM(LINUX) 57 explicit FontCustomPlatformData(SkTypeface* typeface) 58 : m_fontReference(typeface) 59 {} 54 60 #endif 55 61 … … 62 68 HANDLE m_fontReference; 63 69 String m_name; 70 #elif PLATFORM(LINUX) 71 SkTypeface* m_fontReference; 64 72 #endif 65 73 };
Note: See TracChangeset
for help on using the changeset viewer.