Changeset 47975 in webkit
- Timestamp:
- Sep 2, 2009 9:37:52 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47974 r47975 1 2009-09-02 Yong Li <yong.li@torchmobile.com> 2 3 Reviewed by Adam Barth. 4 5 WINCE PORT: use shared buffer for custom font data 6 https://bugs.webkit.org/show_bug.cgi?id=27734 7 8 Refactored by Joe Mason <joe.mason@torchmobile.com> 9 10 * loader/CachedFont.cpp: 11 add WINCE to platforms using cached custom data 12 * platform/graphics/opentype/OpenTypeUtilities.cpp: 13 (WebCore::renameFont): implement for WinCE 14 * platform/graphics/opentype/OpenTypeUtilities.h: 15 build fixes 16 * platform/graphics/wince/FontCustomPlatformData.cpp: 17 (WebCore::setCustomFontCache): add accessor 18 (WebCore::createFontCustomPlatformData): change param to SharedBuffer 19 * platform/graphics/wince/FontCustomPlatformData.h: 20 update function signatures 21 1 22 2009-09-02 Yong Li <yong.li@torchmobile.com> 2 23 -
trunk/WebCore/platform/graphics/opentype/OpenTypeUtilities.cpp
r42060 r47975 1 1 /* 2 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Torch Mobile, Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 340 341 } 341 342 342 HANDLE renameAndActivateFont(SharedBuffer* fontData, const String& fontName) 343 // code shared by renameFont and renameAndActivateFont 344 // adds fontName to the font table in fontData, and writes the new font table to rewrittenFontTable 345 // returns the size of the name table (which is used by renameAndActivateFont), or 0 on early abort 346 static size_t renameFontInternal(SharedBuffer* fontData, const String& fontName, Vector<char> &rewrittenFontData) 343 347 { 344 348 size_t originalDataSize = fontData->size(); … … 358 362 size_t nameTableSize = ((offsetof(nameTable, nameRecords) + nameRecordCount * sizeof(nameRecord) + fontName.length() * sizeof(UChar)) & ~3) + 4; 359 363 360 Vector<char> rewrittenFontData(fontData->size() + nameTableSize);364 rewrittenFontData.resize(fontData->size() + nameTableSize); 361 365 char* data = rewrittenFontData.data(); 362 366 memcpy(data, fontData->data(), originalDataSize); … … 395 399 rewrittenSfnt->tables[t].checkSum = rewrittenSfnt->tables[t].checkSum + reinterpret_cast<BigEndianULong*>(name)[i]; 396 400 401 return nameTableSize; 402 } 403 404 #if PLATFORM(WINCE) 405 // AddFontMemResourceEx does not exist on WinCE, so we must handle the font data manually 406 // This function just renames the font and overwrites the old font data with the new 407 bool renameFont(SharedBuffer* fontData, const String& fontName) 408 { 409 // abort if the data is too small to be a font header with a "tables" entry 410 if (fontData->size() < offsetof(sfntHeader, tables)) 411 return false; 412 413 // abort if the data is too small to hold all the tables specified in the header 414 const sfntHeader* header = reinterpret_cast<const sfntHeader*>(fontData->data()); 415 if (fontData->size() < offsetof(sfntHeader, tables) + header->numTables * sizeof(TableDirectoryEntry)) 416 return false; 417 418 Vector<char> rewrittenFontData; 419 if (!renameFontInternal(fontData, fontName, rewrittenFontData)) 420 return false; 421 422 fontData->clear(); 423 fontData->append(rewrittenFontData.data(), rewrittenFontData.size()); 424 return true; 425 } 426 #else 427 // Rename the font and install the new font data into the system 428 HANDLE renameAndActivateFont(SharedBuffer* fontData, const String& fontName) 429 { 430 Vector<char> rewrittenFontData; 431 size_t nameTableSize = renameFontInternal(fontData, fontName, rewrittenFontData); 432 if (!nameTableSize) 433 return 0; 434 397 435 DWORD numFonts = 0; 398 HANDLE fontHandle = AddFontMemResourceEx( data, originalDataSize+ nameTableSize, 0, &numFonts);436 HANDLE fontHandle = AddFontMemResourceEx(rewrittenFontData.data(), fontData->size() + nameTableSize, 0, &numFonts); 399 437 400 438 if (fontHandle && numFonts != 1) { … … 405 443 return fontHandle; 406 444 } 407 408 } 445 #endif 446 447 } -
trunk/WebCore/platform/graphics/opentype/OpenTypeUtilities.h
r42060 r47975 1 1 /* 2 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Torch Mobile, Inc. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 36 37 class SharedBuffer; 37 38 39 #if PLATFORM(WINCE) 40 typedef unsigned __int8 UInt8; 41 #endif 42 38 43 struct EOTHeader { 39 44 EOTHeader(); -
trunk/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
r46196 r47975 34 34 bool renameFont(SharedBuffer* fontData, const String& fontName); 35 35 36 void setCustomFontCache(CustomFontCache* cache) 37 { 38 g_customFontCache = cache; 39 } 40 36 41 FontCustomPlatformData::~FontCustomPlatformData() 37 42 { … … 67 72 } 68 73 69 FontCustomPlatformData* createFontCustomPlatformData( CachedFont* cachedFont)74 FontCustomPlatformData* createFontCustomPlatformData(const SharedBuffer* buffer) 70 75 { 71 if (g_customFontCache && cachedFont->CachedResource::data()) {76 if (g_customFontCache) { 72 77 String fontName = createUniqueFontName(); 73 if (renameFont(cachedFont->CachedResource::data(), fontName) && g_customFontCache->registerFont(fontName, cachedFont)) 78 RefPtr<SharedBuffer> localBuffer = SharedBuffer::create(buffer->data(), buffer->size()); 79 if (renameFont(localBuffer.get(), fontName) && g_customFontCache->registerFont(fontName, localBuffer.get())) 74 80 return new FontCustomPlatformData(fontName); 75 81 } -
trunk/WebCore/platform/graphics/wince/FontCustomPlatformData.h
r46196 r47975 33 33 class CustomFontCache { 34 34 public: 35 virtual bool registerFont(const String& fontName, CachedFont*) = 0;35 virtual bool registerFont(const String& fontName, const SharedBuffer*) = 0; 36 36 virtual void unregisterFont(const String& fontName) = 0; 37 37 }; … … 49 49 }; 50 50 51 FontCustomPlatformData* createFontCustomPlatformData( CachedFont*);52 51 FontCustomPlatformData* createFontCustomPlatformData(const SharedBuffer*); 52 void setCustomFontCache(CustomFontCache*); 53 53 } 54 54
Note: See TracChangeset
for help on using the changeset viewer.