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 iOS
use-typo-ios.patch (text/plain), 4.14 KB, created by
Frédéric Wang Nélar
on 2015-10-22 22:49:45 PDT
(
hide
)
Description:
Patch iOS
Filename:
MIME Type:
Creator:
Frédéric Wang Nélar
Created:
2015-10-22 22:49:45 PDT
Size:
4.14 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b648fe0..9c3e06d 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2015-10-22 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 typo the typo metrics for fonts with a MATH table when the OS/2 USE_TYPO_METRICS flag is set. >+ >+ No new tests because this is already tested by fonts/use-typo-metrics-1.html >+ >+ * platform/graphics/ios/FontServicesIOS.mm: >+ (WebCore::fontHasMathTable): >+ (WebCore::FontServicesIOS::FontServicesIOS): >+ > 2015-10-22 Alex Christensen <achristensen@webkit.org> > > Initial NSURLSession WebResourceLoader implementation >diff --git a/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm b/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >index 15483c1..e30760c 100644 >--- a/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >+++ b/Source/WebCore/platform/graphics/ios/FontServicesIOS.mm >@@ -28,12 +28,25 @@ > #import "CoreGraphicsSPI.h" > #import "DynamicLinkerSPI.h" > #import "FontMetrics.h" >+#import "OpenTypeTypes.h" > #import <wtf/RetainPtr.h> > > namespace WebCore { > > static const float kLineHeightAdjustment = 0.15f; > >+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 == kCTFontTableMATH) >+ return true; >+ } >+ return false; >+} >+ > static bool shouldUseAdjustment(CTFontRef font, bool isiOS7OrLater) > { > RetainPtr<NSString> familyName = adoptNS((NSString *)CTFontCopyFamilyName(font)); >@@ -95,6 +108,31 @@ 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." >+ // We only apply this rule in the important case of fonts with a MATH table. >+ if (fontHasMathTable(font)) { >+ if (CFDataRef os2Table = CGFontCopyTableForTag(cgFont.get(), 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) { >+ unsigned unitsPerEm = CGFontGetUnitsPerEm(cgFont.get()); >+ float pointSize = CTFontGetSize(font); >+ 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); >+ } >+ } > CGFloat adjustment = (shouldUseAdjustment(font, isiOS7OrLater)) ? ceil((ascent + descent) * kLineHeightAdjustment) : 0; > > m_ascent = ascent + adjustment;
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