Changeset 192017 in webkit
- Timestamp:
- Nov 4, 2015 12:50:31 AM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r192016 r192017 1 2015-11-04 Frederic Wang <fred.wang@free.fr> 2 3 Add support for the USE_TYPO_METRICS flag on iOS 4 https://bugs.webkit.org/show_bug.cgi?id=131839 5 6 Reviewed by Darin Adler. 7 8 Make the iOS Font service use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set. 9 The code shared by iOS, OS X and AppleWin is moved into a separate OpenTypeCG module. 10 11 No new tests because this is already tested by fonts/use-typo-metrics-1.html 12 13 * PlatformAppleWin.cmake: Add OpenTypeCG files. 14 * PlatformMac.cmake: ditto. 15 * WebCore.vcxproj/WebCore.vcxproj: ditto. 16 * WebCore.vcxproj/WebCore.vcxproj.filters: ditto. 17 * WebCore.xcodeproj/project.pbxproj: ditto. 18 * platform/graphics/cocoa/FontCocoa.mm: 19 (WebCore::Font::platformInit): Use functions from OpenTypeCG. 20 (WebCore::fontHasMathTable): Deleted. 21 * platform/graphics/ios/FontServicesIOS.mm: 22 (WebCore::FontServicesIOS::FontServicesIOS): Use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set. 23 * platform/graphics/opentype/OpenTypeCG.h: Added. 24 * platform/graphics/opentype/OpenTypeCG.cpp: Added. 25 (WebCore::OpenType::fontHasMathTable): Move this code from FontCocoa.mm. 26 (WebCore::OpenType::readShortFromTable): Inline function to read a 16-bit big endian integer from the OS/2 table and to cast it into a short integer. 27 (WebCore::OpenType::tryGetTypoMetrics): Move this code from FontCocoa.mm. 28 * platform/graphics/opentype/OpenTypeTypes.h: Add missing Glyph.h header needed by TableWithCoverage::getCoverageIndex. 29 * platform/graphics/win/SimpleFontDataCGWin.cpp: 30 (WebCore::Font::platformInit): Use functions from OpenTypeCG. 31 1 32 2015-11-04 Chris Dumez <cdumez@apple.com> 2 33 -
trunk/Source/WebCore/PlatformAppleWin.cmake
r190421 r192017 83 83 platform/graphics/cg/TransformationMatrixCG.cpp 84 84 85 platform/graphics/opentype/OpenTypeCG.cpp 86 85 87 platform/graphics/win/FontCGWin.cpp 86 88 platform/graphics/win/FontCustomPlatformData.cpp -
trunk/Source/WebCore/PlatformMac.cmake
r191912 r192017 443 443 platform/graphics/opengl/TemporaryOpenGLSetting.cpp 444 444 445 platform/graphics/opentype/OpenTypeCG.cpp 445 446 platform/graphics/opentype/OpenTypeMathData.cpp 446 447 -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r191719 r192017 8463 8463 <ClCompile Include="..\platform\graphics\win\IntSizeWin.cpp" /> 8464 8464 <ClCompile Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.cpp" /> 8465 <ClCompile Include="..\platform\graphics\opentype\OpenTypeCG.cpp"> 8466 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild> 8467 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild> 8468 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild> 8469 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild> 8470 </ClCompile> 8465 8471 <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp" /> 8466 8472 <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r191719 r192017 7129 7129 <Filter>DerivedSources</Filter> 7130 7130 </ClCompile> 7131 <ClCompile Include="..\platform\graphics\opentype\OpenTypeCG.cpp"> 7132 <Filter>platform\graphics\opentype</Filter> 7133 </ClCompile> 7131 7134 <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp"> 7132 7135 <Filter>platform\graphics\opentype</Filter> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r192014 r192017 4996 4996 B2C3DA6C0D006CD600EF6F26 /* GlyphBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4997 4997 B2C96D8D0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */; }; 4998 B2D3DA640D006CD600EF6F3A /* OpenTypeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */; }; 4999 B2D3DA650D006CD600EF6F3A /* OpenTypeCG.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4998 5000 B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */; }; 4999 5001 B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 12730 12732 B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphBuffer.h; sourceTree = "<group>"; }; 12731 12733 B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGPathSegCustom.cpp; sourceTree = "<group>"; }; 12734 B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenTypeCG.cpp; sourceTree = "<group>"; }; 12735 B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenTypeCG.h; sourceTree = "<group>"; }; 12732 12736 B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenTypeMathData.cpp; sourceTree = "<group>"; }; 12733 12737 B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenTypeMathData.h; sourceTree = "<group>"; }; … … 16287 16291 isa = PBXGroup; 16288 16292 children = ( 16293 B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */, 16294 B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */, 16289 16295 B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */, 16290 16296 B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */, … … 26762 26768 FDA9325E16703B2A008982DC /* OfflineAudioContext.h in Headers */, 26763 26769 FDA3E95C134A49EF008D4B5A /* OfflineAudioDestinationNode.h in Headers */, 26770 B2D3DA650D006CD600EF6F3A /* OpenTypeCG.h in Headers */, 26764 26771 B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */, 26765 26772 B2D3EA650D006CD600EF6F28 /* OpenTypeTypes.h in Headers */, … … 30402 30409 FDA9325D16703B2A008982DC /* OfflineAudioContext.cpp in Sources */, 30403 30410 FDA3E95B134A49EF008D4B5A /* OfflineAudioDestinationNode.cpp in Sources */, 30411 B2D3DA640D006CD600EF6F3A /* OpenTypeCG.cpp in Sources */, 30404 30412 B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */, 30405 30413 CDE7FC44181904B1002BBB77 /* OrderIterator.cpp in Sources */, -
trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm
r191871 r192017 59 59 60 60 #if USE(APPKIT) 61 #i nclude "OpenTypeTypes.h"61 #import "OpenTypeCG.h" 62 62 #endif 63 63 … … 78 78 79 79 #if USE(APPKIT) 80 static bool fontHasMathTable(CTFontRef ctFont)81 {82 RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions));83 CFIndex numTables = CFArrayGetCount(tableTags.get());84 for (CFIndex index = 0; index < numTables; ++index) {85 CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);86 if (tag == 'MATH')87 return true;88 }89 return false;90 }91 92 80 static NSString *webFallbackFontFamily(void) 93 81 { … … 189 177 // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: 190 178 // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font." 191 // We only apply this rule in the important case of fonts with a MATH table. 192 if (fontHasMathTable(m_platformData.ctFont())) { 193 if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), kCTFontTableOS2)) { 194 // For the structure of the OS/2 table, see 195 // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html 196 const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; 197 const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; 198 const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; 199 const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; 200 if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) { 201 const UInt8* os2Data = CFDataGetBytePtr(os2Table); 202 const unsigned short useTypoMetricsMask = 1 << 7; 203 if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) { 204 ascent = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)), unitsPerEm) * pointSize; 205 descent = -scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)), unitsPerEm) * pointSize; 206 lineGap = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)), unitsPerEm) * pointSize; 207 } 208 } 209 CFRelease(os2Table); 179 // On OS X, we only apply this rule in the important case of fonts with a MATH table. 180 if (OpenType::fontHasMathTable(m_platformData.ctFont())) { 181 short typoAscent, typoDescent, typoLineGap; 182 if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) { 183 ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize; 184 descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize; 185 lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize; 210 186 } 211 187 } -
trunk/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm
r176265 r192017 29 29 #import "DynamicLinkerSPI.h" 30 30 #import "FontMetrics.h" 31 #import "OpenTypeCG.h" 31 32 #import <wtf/RetainPtr.h> 32 33 … … 96 97 } 97 98 } 99 // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: 100 // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font." 101 // On iOS, we only apply this rule in the important case of fonts with a MATH table. 102 if (OpenType::fontHasMathTable(font)) { 103 short typoAscent, typoDescent, typoLineGap; 104 if (OpenType::tryGetTypoMetrics(cgFont.get(), typoAscent, typoDescent, typoLineGap)) { 105 unsigned unitsPerEm = CGFontGetUnitsPerEm(cgFont.get()); 106 float pointSize = CTFontGetSize(font); 107 ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize; 108 descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize; 109 lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize; 110 } 111 } 98 112 CGFloat adjustment = (shouldUseAdjustment(font, isiOS7OrLater)) ? ceil((ascent + descent) * kLineHeightAdjustment) : 0; 99 113 -
trunk/Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h
r166640 r192017 25 25 #ifndef OpenTypeTypes_h 26 26 #define OpenTypeTypes_h 27 28 #if ENABLE(OPENTYPE_MATH) 29 #include "Glyph.h" 30 #endif 27 31 28 32 #include "SharedBuffer.h" -
trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
r191893 r192017 35 35 #include "GlyphPage.h" 36 36 #include "HWndDC.h" 37 #include "OpenType Types.h"37 #include "OpenTypeCG.h" 38 38 #include <ApplicationServices/ApplicationServices.h> 39 39 #include <WebKitSystemInterface/WebKitSystemInterface.h> … … 68 68 // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: 69 69 // "If set, it is strongly recommended to use OS/2.sTypoAscender - OS/2.sTypoDescender+ OS/2.sTypoLineGap as a value for default line spacing for this font." 70 if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), 'OS/2')) { 71 // For the structure of the OS/2 table, see 72 // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html 73 const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; 74 const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; 75 const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; 76 const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; 77 if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) { 78 const UInt8* os2Data = CFDataGetBytePtr(os2Table); 79 const unsigned short useTypoMetricsMask = 1 << 7; 80 if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) { 81 iAscent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)); 82 iDescent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)); 83 iLineGap = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)); 84 } 85 } 86 CFRelease(os2Table); 70 short typoAscent, typoDescent, typoLineGap; 71 if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) { 72 iAscent = typoAscent; 73 iDescent = typoDescent; 74 iLineGap = typoLineGap; 87 75 } 88 76
Note: See TracChangeset
for help on using the changeset viewer.