Changeset 50859 in webkit
- Timestamp:
- Nov 11, 2009 7:20:15 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r50855 r50859 1 2009-11-11 Yusuke Sato <yusukes@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 [chromium] Remove t2embed.dll functions from FontCustomPlatformData.cpp for Chromium 6 https://bugs.webkit.org/show_bug.cgi?id=31345 7 8 Remove dependency on t2embed.dll so that Chromium for Windows can start even if t2embed.dll cannot be accessed. 9 10 * platform/graphics/chromium/FontCustomPlatformData.cpp: 11 (WebCore::FontCustomPlatformData::~FontCustomPlatformData): Remove TTDeleteEmbeddedFont() call. Always use RemoveFontMemResourceEx(). 12 (WebCore::FontCustomPlatformData::fontPlatformData): Remove TTGetNewFontName() call. 13 (WebCore::createFontCustomPlatformData): Remove TTLoadEmbeddedFont() call. Always use AddFontMemResourceEx() via renameAndActivateFont() in opentype/OpenTypeUtility.h. Remove EOTStream class as well. 14 1 15 2009-11-11 Beth Dakin <bdakin@apple.com> 2 16 -
trunk/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
r46885 r50859 47 47 #if PLATFORM(WIN_OS) 48 48 #include <objbase.h> 49 #include <t2embapi.h>50 #pragma comment(lib, "t2embed")51 49 #elif PLATFORM(LINUX) 52 50 #include <cstring> … … 58 56 { 59 57 #if PLATFORM(WIN_OS) 60 if (m_fontReference) { 61 if (m_name.isNull()) { 62 ULONG status; 63 TTDeleteEmbeddedFont(m_fontReference, 0, &status); 64 } else 65 RemoveFontMemResourceEx(m_fontReference); 66 } 58 if (m_fontReference) 59 RemoveFontMemResourceEx(m_fontReference); 67 60 #elif PLATFORM(LINUX) 68 61 if (m_fontReference) … … 77 70 78 71 LOGFONT logFont; 79 if (m_name.isNull()) 80 TTGetNewFontName(&m_fontReference, logFont.lfFaceName, LF_FACESIZE, 0, 0); 81 else { 82 // m_name comes from createUniqueFontName, which, in turn, gets 83 // it from base64-encoded uuid (128-bit). So, m_name 84 // can never be longer than LF_FACESIZE (32). 85 if (m_name.length() + 1 >= LF_FACESIZE) { 86 ASSERT_NOT_REACHED(); 87 return FontPlatformData(); 88 } 89 memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(), 90 sizeof(logFont.lfFaceName[0]) * (1 + m_name.length())); 72 // m_name comes from createUniqueFontName, which, in turn, gets 73 // it from base64-encoded uuid (128-bit). So, m_name 74 // can never be longer than LF_FACESIZE (32). 75 if (m_name.length() + 1 >= LF_FACESIZE) { 76 ASSERT_NOT_REACHED(); 77 return FontPlatformData(); 91 78 } 79 memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(), 80 sizeof(logFont.lfFaceName[0]) * (1 + m_name.length())); 92 81 93 82 // FIXME: almost identical to FillLogFont in FontCacheWin.cpp. … … 120 109 121 110 #if PLATFORM(WIN_OS) 122 // FIXME: EOTStream class and static functions in this #if block are123 // duplicated from platform/graphics/win/FontCustomPlatformData.cpp124 // and need to be shared.125 126 // Streams the concatenation of a header and font data.127 class EOTStream {128 public:129 EOTStream(const EOTHeader& eotHeader, const SharedBuffer* fontData, size_t overlayDst, size_t overlaySrc, size_t overlayLength)130 : m_eotHeader(eotHeader)131 , m_fontData(fontData)132 , m_overlayDst(overlayDst)133 , m_overlaySrc(overlaySrc)134 , m_overlayLength(overlayLength)135 , m_offset(0)136 , m_inHeader(true)137 {138 }139 140 size_t read(void* buffer, size_t count);141 142 private:143 const EOTHeader& m_eotHeader;144 const SharedBuffer* m_fontData;145 size_t m_overlayDst;146 size_t m_overlaySrc;147 size_t m_overlayLength;148 size_t m_offset;149 bool m_inHeader;150 };151 152 size_t EOTStream::read(void* buffer, size_t count)153 {154 size_t bytesToRead = count;155 if (m_inHeader) {156 size_t bytesFromHeader = std::min(m_eotHeader.size() - m_offset, count);157 memcpy(buffer, m_eotHeader.data() + m_offset, bytesFromHeader);158 m_offset += bytesFromHeader;159 bytesToRead -= bytesFromHeader;160 if (m_offset == m_eotHeader.size()) {161 m_inHeader = false;162 m_offset = 0;163 }164 }165 if (bytesToRead && !m_inHeader) {166 size_t bytesFromData = std::min(m_fontData->size() - m_offset, bytesToRead);167 memcpy(buffer, m_fontData->data() + m_offset, bytesFromData);168 if (m_offset < m_overlayDst + m_overlayLength && m_offset + bytesFromData >= m_overlayDst) {169 size_t dstOffset = std::max<int>(m_overlayDst - m_offset, 0);170 size_t srcOffset = std::max<int>(0, m_offset - m_overlayDst);171 size_t bytesToCopy = std::min(bytesFromData - dstOffset, m_overlayLength - srcOffset);172 memcpy(reinterpret_cast<char*>(buffer) + dstOffset, m_fontData->data() + m_overlaySrc + srcOffset, bytesToCopy);173 }174 m_offset += bytesFromData;175 bytesToRead -= bytesFromData;176 }177 return count - bytesToRead;178 }179 180 static unsigned long WINAPIV readEmbedProc(void* stream, void* buffer, unsigned long length)181 {182 return static_cast<EOTStream*>(stream)->read(buffer, length);183 }184 185 111 // Creates a unique and unpredictable font name, in order to avoid collisions and to 186 112 // not allow access from CSS. … … 247 173 248 174 #if PLATFORM(WIN_OS) 249 // Introduce the font to GDI. AddFontMemResourceEx cannot be used, because it will pollute the process's175 // Introduce the font to GDI. AddFontMemResourceEx should be used with care, because it will pollute the process's 250 176 // font namespace (Windows has no API for creating an HFONT from data without exposing the font to the 251 // entire process first). TTLoadEmbeddedFont lets us override the font family name, so using a unique name 252 // we avoid namespace collisions. 253 177 // entire process first). 254 178 String fontName = createUniqueFontName(); 255 256 // TTLoadEmbeddedFont works only with Embedded OpenType (.eot) data, 257 // so we need to create an EOT header and prepend it to the font data. 258 EOTHeader eotHeader; 259 size_t overlayDst; 260 size_t overlaySrc; 261 size_t overlayLength; 262 263 if (!getEOTHeader(buffer, eotHeader, overlayDst, overlaySrc, overlayLength)) 179 HANDLE fontReference = renameAndActivateFont(buffer, fontName); 180 if (!fontReference) 264 181 return 0; 265 266 HANDLE fontReference;267 ULONG privStatus;268 ULONG status;269 EOTStream eotStream(eotHeader, buffer, overlayDst, overlaySrc, overlayLength);270 271 LONG loadEmbeddedFontResult = TTLoadEmbeddedFont(&fontReference, TTLOAD_PRIVATE, &privStatus, LICENSE_PREVIEWPRINT, &status, readEmbedProc, &eotStream, const_cast<LPWSTR>(fontName.charactersWithNullTermination()), 0, 0);272 if (loadEmbeddedFontResult == E_NONE)273 fontName = String();274 else {275 fontReference = renameAndActivateFont(buffer, fontName);276 if (!fontReference)277 return 0;278 }279 280 182 return new FontCustomPlatformData(fontReference, fontName); 281 183 #elif PLATFORM(LINUX)
Note: See TracChangeset
for help on using the changeset viewer.