Changeset 49474 in webkit
- Timestamp:
- Oct 12, 2009 3:25:03 PM (15 years ago)
- Location:
- branches/safari-4-branch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-4-branch/WebCore/ChangeLog
r49471 r49474 1 2009-10-12 Mark Rowe <mrowe@apple.com> 2 3 Merge r48775. 4 5 2009-09-25 Dan Bernstein <mitz@apple.com> 6 7 Reviewed by Jon Honeycutt. 8 9 WebCore part of 10 <rdar://problem/7211635> 2 byte characters are displayed as garbaged 11 <rdar://problem/7212626> garbled/gibberish text (off-by-one) 12 13 When the Windows Fonts directory contains more than one font file for a 14 given font name, which of the fonts gets assigned to the name in the 15 Core Graphics font database was determined arbitrarily and did not 16 always match the font GDI used for the same font name. The mismatch 17 caused character-to-glyph mapping to use one font and glyph rendering to 18 use another. 19 20 The fix is to update the Core Graphics font database from the registry 21 entries (that reflect the name-to-font mapping that GDI uses) after 22 populating it with the result of scanning the Fonts directory. As a 23 consequence, the directory needs to be scanned at startup every time the 24 registry key changes, so the last value of the registry key is kept 25 in the property list on disk so that it could be compared to the current 26 value on startup. 27 28 * platform/graphics/win/FontDatabase.cpp: 29 (WebCore::populateFontDatabaseFromPlist): Now takes a property list as 30 a parameter and avoids round-tripping through XML by calling 31 wkAddFontsFromPlist() instead of wkAddFontsFromPlistRepresentation(). 32 (WebCore::fontFilenamesFromRegistryKey): 33 (WebCore::cgFontDBKey): 34 (WebCore::writeFontDatabaseToPlist): Now takes the CG font DB property 35 list and a property list with the font filenames from the registry and 36 writes a dictionary with those property lists as values. 37 (WebCore::fontFilenamesFromRegistry): Added. Returns an array with the 38 values in the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts 39 registry key. 40 (WebCore::populateFontDatabase): Changed to read the contents of the 41 Fonts registry key and compare it with the last-saved value from the 42 property list, and to call wkAddFontsFromRegistry() after populating the 43 CG font DB from the file system. Uses wkCreateFontsPlist() instead of 44 wkCreateFontsPlistRepresentation() to avoid round-tripping through XML. 45 1 46 2009-10-12 Mark Rowe <mrowe@apple.com> 2 47 -
branches/safari-4-branch/WebCore/platform/graphics/win/FontDatabase.cpp
r29663 r49474 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 100 100 } 101 101 102 static bool populateFontDatabaseFromPlist() 103 { 104 RetainPtr<CFPropertyListRef> plist = readFontPlist(); 102 static bool populateFontDatabaseFromPlist(CFPropertyListRef plist) 103 { 105 104 if (!plist) 106 105 return false; 107 106 108 RetainPtr<CFDataRef> data(AdoptCF, CFPropertyListCreateXMLData(0, plist.get())); 109 if (!data) 110 return false; 111 112 wkAddFontsFromPlistRepresentation(data.get()); 107 wkAddFontsFromPlist(plist); 113 108 return true; 114 109 } … … 124 119 } 125 120 126 static void writeFontDatabaseToPlist() 127 { 128 RetainPtr<CFDataRef> data(AdoptCF, wkCreateFontsPlistRepresentation()); 121 static CFStringRef fontFilenamesFromRegistryKey() 122 { 123 static CFStringRef key = CFSTR("WebKitFontFilenamesFromRegistry"); 124 return key; 125 } 126 127 static CFStringRef cgFontDBKey() 128 { 129 static CFStringRef key = CFSTR("WebKitCGFontDB"); 130 return key; 131 } 132 133 static void writeFontDatabaseToPlist(CFPropertyListRef cgFontDBPropertyList, CFPropertyListRef filenamesFromRegistry) 134 { 135 RetainPtr<CFMutableDictionaryRef> dictionary(AdoptCF, CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 136 137 if (cgFontDBPropertyList) 138 CFDictionarySetValue(dictionary.get(), cgFontDBKey(), cgFontDBPropertyList); 139 if (filenamesFromRegistry) 140 CFDictionarySetValue(dictionary.get(), fontFilenamesFromRegistryKey(), filenamesFromRegistry); 141 142 RetainPtr<CFDataRef> data(AdoptCF, CFPropertyListCreateXMLData(kCFAllocatorDefault, dictionary.get())); 129 143 if (!data) 130 144 return; 131 145 132 146 safeCreateFile(fontsPlistPath(), data.get()); 147 } 148 149 static RetainPtr<CFArrayRef> fontFilenamesFromRegistry() 150 { 151 RetainPtr<CFMutableArrayRef> filenames(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); 152 153 HKEY key; 154 if (FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), 0, KEY_READ, &key))) 155 return filenames; 156 157 DWORD valueCount; 158 DWORD maxNameLength; 159 DWORD maxValueLength; 160 if (FAILED(RegQueryInfoKey(key, 0, 0, 0, 0, 0, 0, &valueCount, &maxNameLength, &maxValueLength, 0, 0))) { 161 RegCloseKey(key); 162 return filenames; 163 } 164 165 Vector<TCHAR> name(maxNameLength + 1); 166 Vector<BYTE> value(maxValueLength + 1); 167 168 for (size_t i = 0; i < valueCount; ++i) { 169 DWORD nameLength = name.size(); 170 DWORD valueLength = value.size(); 171 DWORD type; 172 if (FAILED(RegEnumValue(key, i, name.data(), &nameLength, 0, &type, value.data(), &valueLength))) 173 continue; 174 if (type != REG_SZ) 175 continue; 176 177 RetainPtr<CFDataRef> filename(AdoptCF, CFDataCreate(kCFAllocatorDefault, value.data(), valueLength)); 178 CFArrayAppendValue(filenames.get(), filename.get()); 179 } 180 181 RegCloseKey(key); 182 return filenames; 133 183 } 134 184 … … 140 190 initialized = true; 141 191 142 if (!systemHasFontsNewerThanFontsPlist()) 143 if (populateFontDatabaseFromPlist()) 192 RetainPtr<CFPropertyListRef> propertyList = readFontPlist(); 193 RetainPtr<CFArrayRef> lastFilenamesFromRegistry; 194 if (propertyList && CFGetTypeID(propertyList.get()) == CFDictionaryGetTypeID()) { 195 CFDictionaryRef dictionary = static_cast<CFDictionaryRef>(propertyList.get()); 196 CFArrayRef array = static_cast<CFArrayRef>(CFDictionaryGetValue(dictionary, fontFilenamesFromRegistryKey())); 197 if (array && CFGetTypeID(array) == CFArrayGetTypeID()) 198 lastFilenamesFromRegistry = array; 199 } 200 RetainPtr<CFArrayRef> currentFilenamesFromRegistry = fontFilenamesFromRegistry(); 201 bool registryChanged = !lastFilenamesFromRegistry || !CFEqual(lastFilenamesFromRegistry.get(), currentFilenamesFromRegistry.get()); 202 203 if (!registryChanged && !systemHasFontsNewerThanFontsPlist()) { 204 RetainPtr<CFPropertyListRef> cgFontDBPropertyList; 205 if (propertyList) { 206 if (CFGetTypeID(propertyList.get()) == CFDictionaryGetTypeID()) { 207 CFDictionaryRef dictionary = static_cast<CFDictionaryRef>(propertyList.get()); 208 cgFontDBPropertyList = static_cast<CFArrayRef>(CFDictionaryGetValue(dictionary, cgFontDBKey())); 209 } 210 // Older versions of WebKit stored the CG font DB property list at the root of the property list. 211 if (!cgFontDBPropertyList) 212 cgFontDBPropertyList = propertyList; 213 } 214 215 if (populateFontDatabaseFromPlist(cgFontDBPropertyList.get())) 144 216 return; 145 146 if (populateFontDatabaseFromFileSystem()) 147 writeFontDatabaseToPlist(); 217 } 218 219 if (populateFontDatabaseFromFileSystem()) { 220 wkAddFontsFromRegistry(); 221 RetainPtr<CFPropertyListRef> cgFontDBPropertyList(AdoptCF, wkCreateFontsPlist()); 222 writeFontDatabaseToPlist(cgFontDBPropertyList.get(), currentFilenamesFromRegistry.get()); 223 } 148 224 } 149 225 -
branches/safari-4-branch/WebKitLibraries/ChangeLog
r45776 r49474 1 2009-10-12 Mark Rowe <mrowe@apple.com> 2 3 Merge r48775. 4 5 2009-09-25 Dan Bernstein <mitz@apple.com> 6 7 Reviewed by Adam Roben. 8 9 WebKitSystemInterface changes for 10 <rdar://problem/7211635> 2 byte characters are displayed as garbaged 11 <rdar://problem/7212626> garbled/gibberish text (off-by-one) 12 13 * win/include/WebKitSystemInterface/WebKitSystemInterface.h: Added 14 wkAddFontsFromPlistRepresentation() and replaced 15 wkCreateFontsPlistRepresentation() with wkCreateFontsPlist() and 16 wkAddFontsFromPlistRepresentation() with wkAddFontsFromPlist(). 17 * win/lib/WebKitSystemInterface.lib: 18 * win/lib/WebKitSystemInterface_debug.lib: 19 1 20 2009-07-10 Eric Carlson <eric.carlson@apple.com> 2 21 -
branches/safari-4-branch/WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
r42767 r49474 57 57 void wkAddFontsInDirectory(CFStringRef); 58 58 void wkAddFontsAtPath(CFStringRef); 59 void wkAddFontsFromPlistRepresentation(CFDataRef); 60 CFDataRef wkCreateFontsPlistRepresentation(); 59 void wkAddFontsFromRegistry(); 60 void wkAddFontsFromPlist(CFPropertyListRef); 61 CFPropertyListRef wkCreateFontsPlist(); 61 62 62 63 void wkSetPatternBaseCTM(CGContextRef, CGAffineTransform);
Note: See TracChangeset
for help on using the changeset viewer.