WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
opentypecg.patch (text/plain), 23.36 KB, created by
Frédéric Wang Nélar
on 2015-11-03 14:17:50 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Frédéric Wang Nélar
Created:
2015-11-03 14:17:50 PST
Size:
23.36 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 72acf71..beea5a9 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2015-11-03 Frederic Wang <fred.wang@free.fr> >+ >+ Add support for the USE_TYPO_METRICS flag on iOS >+ https://bugs.webkit.org/show_bug.cgi?id=131839 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ The code shared by iOS, OS X and AppleWin is moved into a separate OpenTypeCG module. >+ >+ No new tests because this is already tested by fonts/use-typo-metrics-1.html >+ >+ * PlatformAppleWin.cmake: Add OpenTypeCG files. >+ * PlatformMac.cmake: ditto. >+ * WebCore.vcxproj/WebCore.vcxproj: ditto. >+ * WebCore.vcxproj/WebCore.vcxproj.filters: ditto. >+ * WebCore.xcodeproj/project.pbxproj: ditto. >+ * platform/graphics/cocoa/FontCocoa.mm: >+ (WebCore::Font::platformInit): Use functions from OpenTypeCG. >+ (WebCore::fontHasMathTable): Deleted. >+ * platform/graphics/ios/FontServicesIOS.mm: >+ (WebCore::FontServicesIOS::FontServicesIOS): Use the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set. >+ * platform/graphics/opentype/OpenTypeCG.h: Added. >+ * platform/graphics/opentype/OpenTypeCG.cpp: Added. >+ (WebCore::OpenType::fontHasMathTable): Move this code from FontCocoa.mm. >+ (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. >+ (WebCore::OpenType::tryGetTypoMetrics): Move this code from FontCocoa.mm. >+ * platform/graphics/opentype/OpenTypeTypes.h: Add missing Glyph.h header needed by TableWithCoverage::getCoverageIndex. >+ * platform/graphics/win/SimpleFontDataCGWin.cpp: >+ (WebCore::Font::platformInit): Use functions from OpenTypeCG. >+ > 2015-11-03 Joseph Pecoraro <pecoraro@apple.com> > > Web Inspector: Move ScriptDebugServer::Task to WorkerScriptDebugServer where it is actually used >diff --git a/Source/WebCore/PlatformAppleWin.cmake b/Source/WebCore/PlatformAppleWin.cmake >index 52e01dc..e5209cb 100644 >--- a/Source/WebCore/PlatformAppleWin.cmake >+++ b/Source/WebCore/PlatformAppleWin.cmake >@@ -82,6 +82,8 @@ list(APPEND WebCore_SOURCES > platform/graphics/cg/SubimageCacheWithTimer.cpp > platform/graphics/cg/TransformationMatrixCG.cpp > >+ platform/graphics/opentype/OpenTypeCG.cpp >+ > platform/graphics/win/FontCGWin.cpp > platform/graphics/win/FontCustomPlatformData.cpp > platform/graphics/win/FontPlatformDataCGWin.cpp >diff --git a/Source/WebCore/PlatformMac.cmake b/Source/WebCore/PlatformMac.cmake >index ff8a46e..05d893f 100644 >--- a/Source/WebCore/PlatformMac.cmake >+++ b/Source/WebCore/PlatformMac.cmake >@@ -442,6 +442,7 @@ list(APPEND WebCore_SOURCES > platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp > platform/graphics/opengl/TemporaryOpenGLSetting.cpp > >+ platform/graphics/opentype/OpenTypeCG.cpp > platform/graphics/opentype/OpenTypeMathData.cpp > > platform/mac/BlockExceptions.mm >diff --git a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >index 162e3f4..782f1a3 100644 >--- a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >+++ b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj >@@ -8462,6 +8462,12 @@ > <ClCompile Include="..\platform\graphics\win\IntRectWin.cpp" /> > <ClCompile Include="..\platform\graphics\win\IntSizeWin.cpp" /> > <ClCompile Include="..\platform\graphics\win\MediaPlayerPrivateFullscreenWindow.cpp" /> >+ <ClCompile Include="..\platform\graphics\opentype\OpenTypeCG.cpp"> >+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild> >+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild> >+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild> >+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild> >+ </ClCompile> > <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp" /> > <ClCompile Include="..\platform\graphics\opentype\OpenTypeUtilities.cpp" /> > <ClCompile Include="..\platform\graphics\opentype\OpenTypeVerticalData.cpp" /> >diff --git a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >index 1ef3321..2e41190 100644 >--- a/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >+++ b/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters >@@ -7128,6 +7128,9 @@ > <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSWebGLRenderingContextBase.cpp"> > <Filter>DerivedSources</Filter> > </ClCompile> >+ <ClCompile Include="..\platform\graphics\opentype\OpenTypeCG.cpp"> >+ <Filter>platform\graphics\opentype</Filter> >+ </ClCompile> > <ClCompile Include="..\platform\graphics\opentype\OpenTypeMathData.cpp"> > <Filter>platform\graphics\opentype</Filter> > </ClCompile> >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 50b9cde..7847889 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4985,6 +4985,8 @@ > B2C3DA6B0D006CD600EF6F26 /* FontSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA5A0D006CD600EF6F26 /* FontSelector.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B2C3DA6C0D006CD600EF6F26 /* GlyphBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B2C96D8D0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */; }; >+ B2D3DA640D006CD600EF6F3A /* OpenTypeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */; }; >+ B2D3DA650D006CD600EF6F3A /* OpenTypeCG.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */; }; > B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B2D3EA650D006CD600EF6F28 /* OpenTypeTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D3EA540D006CD600EF6F28 /* OpenTypeTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -12709,6 +12711,8 @@ > B2C3DA5A0D006CD600EF6F26 /* FontSelector.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontSelector.h; sourceTree = "<group>"; }; > B2C3DA5B0D006CD600EF6F26 /* GlyphBuffer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GlyphBuffer.h; sourceTree = "<group>"; }; > B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGPathSegCustom.cpp; sourceTree = "<group>"; }; >+ B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenTypeCG.cpp; sourceTree = "<group>"; }; >+ B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenTypeCG.h; sourceTree = "<group>"; }; > B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = OpenTypeMathData.cpp; sourceTree = "<group>"; }; > B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenTypeMathData.h; sourceTree = "<group>"; }; > B2D3EA540D006CD600EF6F28 /* OpenTypeTypes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OpenTypeTypes.h; sourceTree = "<group>"; }; >@@ -16266,6 +16270,8 @@ > 3721493318F0B6D600156EDC /* opentype */ = { > isa = PBXGroup; > children = ( >+ B2D3DA530D006CD600EF6F3A /* OpenTypeCG.cpp */, >+ B2D3DA540D006CD600EF6F3A /* OpenTypeCG.h */, > B2D3DA530D006CD600EF6F27 /* OpenTypeMathData.cpp */, > B2D3DA540D006CD600EF6F27 /* OpenTypeMathData.h */, > B2D3EA540D006CD600EF6F28 /* OpenTypeTypes.h */, >@@ -26728,6 +26734,7 @@ > FDA3E95A134A49EF008D4B5A /* OfflineAudioCompletionEvent.h in Headers */, > FDA9325E16703B2A008982DC /* OfflineAudioContext.h in Headers */, > FDA3E95C134A49EF008D4B5A /* OfflineAudioDestinationNode.h in Headers */, >+ B2D3DA650D006CD600EF6F3A /* OpenTypeCG.h in Headers */, > B2D3DA650D006CD600EF6F27 /* OpenTypeMathData.h in Headers */, > B2D3EA650D006CD600EF6F28 /* OpenTypeTypes.h in Headers */, > CDE7FC45181904B1002BBB77 /* OrderIterator.h in Headers */, >@@ -30363,6 +30370,7 @@ > FDA3E959134A49EF008D4B5A /* OfflineAudioCompletionEvent.cpp in Sources */, > FDA9325D16703B2A008982DC /* OfflineAudioContext.cpp in Sources */, > FDA3E95B134A49EF008D4B5A /* OfflineAudioDestinationNode.cpp in Sources */, >+ B2D3DA640D006CD600EF6F3A /* OpenTypeCG.cpp in Sources */, > B2D3DA640D006CD600EF6F27 /* OpenTypeMathData.cpp in Sources */, > CDE7FC44181904B1002BBB77 /* OrderIterator.cpp in Sources */, > 0014628A103CD1DE000B20DB /* OriginAccessEntry.cpp in Sources */, >diff --git a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm b/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm >index 51edd84..8813611 100644 >--- a/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm >+++ b/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm >@@ -58,7 +58,7 @@ @end > #endif > > #if USE(APPKIT) >-#include "OpenTypeTypes.h" >+#import "OpenTypeCG.h" > #endif > > namespace WebCore { >@@ -77,18 +77,6 @@ static bool fontHasVerticalGlyphs(CTFontRef ctFont) > } > > #if USE(APPKIT) >-static bool fontHasMathTable(CTFontRef ctFont) >-{ >- RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions)); >- CFIndex numTables = CFArrayGetCount(tableTags.get()); >- for (CFIndex index = 0; index < numTables; ++index) { >- CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index); >- if (tag == 'MATH') >- return true; >- } >- return false; >-} >- > static NSString *webFallbackFontFamily(void) > { > static NSString *webFallbackFontFamily = [[[NSFont systemFontOfSize:16.0f] familyName] retain]; >@@ -188,25 +176,13 @@ void Font::platformInit() > > // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: > // "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." >- // We only apply this rule in the important case of fonts with a MATH table. >- if (fontHasMathTable(m_platformData.ctFont())) { >- if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), kCTFontTableOS2)) { >- // For the structure of the OS/2 table, see >- // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html >- const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; >- const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; >- const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; >- const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; >- if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) { >- const UInt8* os2Data = CFDataGetBytePtr(os2Table); >- const unsigned short useTypoMetricsMask = 1 << 7; >- if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) { >- ascent = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)), unitsPerEm) * pointSize; >- descent = -scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)), unitsPerEm) * pointSize; >- lineGap = scaleEmToUnits(*(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)), unitsPerEm) * pointSize; >- } >- } >- CFRelease(os2Table); >+ // On OS X, we only apply this rule in the important case of fonts with a MATH table. >+ if (OpenType::fontHasMathTable(m_platformData.ctFont())) { >+ short typoAscent, typoDescent, typoLineGap; >+ if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) { >+ ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize; >+ descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize; >+ lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize; > } > } > >diff --git a/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm b/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >index 15483c1..aef63de 100644 >--- a/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >+++ b/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >@@ -28,6 +28,7 @@ > #import "CoreGraphicsSPI.h" > #import "DynamicLinkerSPI.h" > #import "FontMetrics.h" >+#import "OpenTypeCG.h" > #import <wtf/RetainPtr.h> > > namespace WebCore { >@@ -95,6 +96,19 @@ FontServicesIOS::FontServicesIOS(CTFontRef font) > descent = (scaleEmToUnits(615, 2048) * pointSize); > } > } >+ // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: >+ // "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." >+ // On iOS, we only apply this rule in the important case of fonts with a MATH table. >+ if (OpenType::fontHasMathTable(font)) { >+ short typoAscent, typoDescent, typoLineGap; >+ if (OpenType::tryGetTypoMetrics(cgFont.get(), typoAscent, typoDescent, typoLineGap)) { >+ unsigned unitsPerEm = CGFontGetUnitsPerEm(cgFont.get()); >+ float pointSize = CTFontGetSize(font); >+ ascent = scaleEmToUnits(typoAscent, unitsPerEm) * pointSize; >+ descent = -scaleEmToUnits(typoDescent, unitsPerEm) * pointSize; >+ lineGap = scaleEmToUnits(typoLineGap, unitsPerEm) * pointSize; >+ } >+ } > CGFloat adjustment = (shouldUseAdjustment(font, isiOS7OrLater)) ? ceil((ascent + descent) * kLineHeightAdjustment) : 0; > > m_ascent = ascent + adjustment; >diff --git a/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp b/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp >new file mode 100644 >index 0000000..82826f5 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/opentype/OpenTypeCG.cpp >@@ -0,0 +1,84 @@ >+/* >+ * Copyright (C) 2015 Frederic Wang (fred.wang@free.fr). All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "OpenTypeCG.h" >+ >+#include "OpenTypeTypes.h" >+ >+namespace WebCore { >+namespace OpenType { >+ >+#if PLATFORM(WIN) >+static const unsigned long kCTFontTableOS2 = 'OS/2'; >+#endif >+ >+#if PLATFORM(COCOA) >+bool fontHasMathTable(CTFontRef ctFont) >+{ >+ RetainPtr<CFArrayRef> tableTags = adoptCF(CTFontCopyAvailableTables(ctFont, kCTFontTableOptionNoOptions)); >+ CFIndex numTables = CFArrayGetCount(tableTags.get()); >+ for (CFIndex index = 0; index < numTables; ++index) { >+ CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index); >+ if (tag == 'MATH') >+ return true; >+ } >+ return false; >+} >+#endif >+ >+static inline short readShortFromTable(const UInt8* os2Data, CFIndex offset) >+{ >+ return *(reinterpret_cast<const OpenType::Int16*>(os2Data + offset)); >+} >+ >+bool tryGetTypoMetrics(CGFontRef cgFont, short& ascent, short& descent, short& lineGap) >+{ >+ bool result = false; >+ if (CFDataRef os2Table = CGFontCopyTableForTag(cgFont, kCTFontTableOS2)) { >+ // For the structure of the OS/2 table, see >+ // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html >+ const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; >+ const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; >+ const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; >+ const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; >+ if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) { >+ const UInt8* os2Data = CFDataGetBytePtr(os2Table); >+ // We test the use typo bit on the least significant byte of fsSelection. >+ const UInt8 useTypoMetricsMask = 1 << 7; >+ if (*(os2Data + fsSelectionOffset + 1) & useTypoMetricsMask) { >+ ascent = readShortFromTable(os2Data, sTypoAscenderOffset); >+ descent = readShortFromTable(os2Data, sTypoDescenderOffset); >+ lineGap = readShortFromTable(os2Data, sTypoLineGapOffset); >+ result = true; >+ } >+ } >+ CFRelease(os2Table); >+ } >+ return result; >+} >+ >+} // namespace OpenType >+} // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h b/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h >new file mode 100644 >index 0000000..bd4babf >--- /dev/null >+++ b/Source/WebCore/platform/graphics/opentype/OpenTypeCG.h >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (C) 2015 Frederic Wang (fred.wang@free.fr). All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef OpenTypeCG_h >+#define OpenTypeCG_h >+ >+#include <CoreGraphics/CoreGraphics.h> >+#if PLATFORM(COCOA) >+#include <CoreText/CoreText.h> >+#endif >+ >+namespace WebCore { >+namespace OpenType { >+ >+#if PLATFORM(COCOA) >+bool fontHasMathTable(CTFontRef); >+#endif >+bool tryGetTypoMetrics(CGFontRef, short& ascent, short& descent, short& lineGap); >+ >+} // namespace OpenType >+} // namespace WebCore >+#endif // OpenTypeCG_h >diff --git a/Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h b/Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h >index a2fba1d..e89fb59 100644 >--- a/Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h >+++ b/Source/WebCore/platform/graphics/opentype/OpenTypeTypes.h >@@ -25,6 +25,10 @@ > #ifndef OpenTypeTypes_h > #define OpenTypeTypes_h > >+#if ENABLE(OPENTYPE_MATH) >+#include "Glyph.h" >+#endif >+ > #include "SharedBuffer.h" > > namespace WebCore { >diff --git a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp >index 2405936..0449253 100644 >--- a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp >+++ b/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp >@@ -34,7 +34,7 @@ > #include "FontDescription.h" > #include "GlyphPage.h" > #include "HWndDC.h" >-#include "OpenTypeTypes.h" >+#include "OpenTypeCG.h" > #include <ApplicationServices/ApplicationServices.h> > #include <WebKitSystemInterface/WebKitSystemInterface.h> > #include <mlang.h> >@@ -67,23 +67,11 @@ void Font::platformInit() > > // The Open Font Format describes the OS/2 USE_TYPO_METRICS flag as follows: > // "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." >- if (CFDataRef os2Table = CGFontCopyTableForTag(m_platformData.cgFont(), 'OS/2')) { >- // For the structure of the OS/2 table, see >- // https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html >- const CFIndex fsSelectionOffset = 16 * 2 + 10 + 4 * 4 + 4 * 1; >- const CFIndex sTypoAscenderOffset = fsSelectionOffset + 3 * 2; >- const CFIndex sTypoDescenderOffset = sTypoAscenderOffset + 2; >- const CFIndex sTypoLineGapOffset = sTypoDescenderOffset + 2; >- if (CFDataGetLength(os2Table) >= sTypoLineGapOffset + 2) { >- const UInt8* os2Data = CFDataGetBytePtr(os2Table); >- const unsigned short useTypoMetricsMask = 1 << 7; >- if (*(reinterpret_cast<const OpenType::UInt16*>(os2Data + fsSelectionOffset)) & useTypoMetricsMask) { >- iAscent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoAscenderOffset)); >- iDescent = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoDescenderOffset)); >- iLineGap = *(reinterpret_cast<const OpenType::Int16*>(os2Data + sTypoLineGapOffset)); >- } >- } >- CFRelease(os2Table); >+ short typoAscent, typoDescent, typoLineGap; >+ if (OpenType::tryGetTypoMetrics(m_platformData.cgFont(), typoAscent, typoDescent, typoLineGap)) { >+ iAscent = typoAscent; >+ iDescent = typoDescent; >+ iLineGap = typoLineGap; > } > > unsigned unitsPerEm = CGFontGetUnitsPerEm(font);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 131839
:
263416
|
263497
|
263596
|
263616
|
263903
|
263907
|
264672
|
264674
|
264678
|
264680
|
264682
|
264686
|
264687
|
264688
|
264689
|
264712
| 264723