From c8d0aa0270f55419b802c7f8cfaaa86add3694f6 Mon Sep 17 00:00:00 2001 From: "dino@apple.com" Date: Thu, 30 Apr 2015 23:26:11 +0000 Subject: [PATCH] -apple-system-font-monospaced-numbers doesn't work on iOS https://bugs.webkit.org/show_bug.cgi?id=144478 Reviewed by Brent Fulgham. Source/WebCore: Make sure to start from the system font descriptor when asking for a monospaced numeric alternate. Test: platform/ios-simulator/fast/text/system-monospaced-numbers.html * platform/graphics/ios/FontCacheIOS.mm: (WebCore::createCTFontWithFamilyNameAndWeight): LayoutTests: A test that draws two lines of different numbers and checks they are the same width. * platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt: Added. * platform/ios-simulator/fast/text/system-monospaced-numbers.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183653 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 14 ++++++++++ .../text/system-monospaced-numbers-expected.txt | 7 +++++ .../fast/text/system-monospaced-numbers.html | 31 ++++++++++++++++++++++ Source/WebCore/ChangeLog | 16 +++++++++++ .../WebCore/platform/graphics/ios/FontCacheIOS.mm | 8 +++--- 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt create mode 100644 LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 98917b0..96f0bee 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,17 @@ +2015-04-30 Dean Jackson + + -apple-system-font-monospaced-numbers doesn't work on iOS + https://bugs.webkit.org/show_bug.cgi?id=144478 + + + Reviewed by Brent Fulgham. + + A test that draws two lines of different numbers and checks + they are the same width. + + * platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt: Added. + * platform/ios-simulator/fast/text/system-monospaced-numbers.html: Added. + 2015-04-30 Joseph Pecoraro Unreviewed, ios-simulator gardening diff --git a/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt b/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt new file mode 100644 index 0000000..ebee32b --- /dev/null +++ b/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers-expected.txt @@ -0,0 +1,7 @@ +These next two lines should be the same width + +00:11:22.33 + +11:11:11.11 + +PASS: widths were the same diff --git a/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers.html b/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers.html new file mode 100644 index 0000000..6721161 --- /dev/null +++ b/LayoutTests/platform/ios-simulator/fast/text/system-monospaced-numbers.html @@ -0,0 +1,31 @@ + + +

These next two lines should be the same width

+

00:11:22.33

+

11:11:11.11

+ +

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 2fe06cd..ed4c73c 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2015-04-30 Dean Jackson + + -apple-system-font-monospaced-numbers doesn't work on iOS + https://bugs.webkit.org/show_bug.cgi?id=144478 + + + Reviewed by Brent Fulgham. + + Make sure to start from the system font descriptor when + asking for a monospaced numeric alternate. + + Test: platform/ios-simulator/fast/text/system-monospaced-numbers.html + + * platform/graphics/ios/FontCacheIOS.mm: + (WebCore::createCTFontWithFamilyNameAndWeight): + 2015-04-30 Oliver Hunt DOM bindings should not be using a reference type to point to a temporary object diff --git a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm b/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm index de82924..6b81bfff 100644 --- a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm +++ b/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm @@ -625,11 +625,9 @@ static CTFontRef createCTFontWithFamilyNameAndWeight(const String& familyName, C static NeverDestroyed systemUIMonospacedNumbersFontWithApplePrefix("-apple-system-font-monospaced-numbers", AtomicString::ConstructFromLiteral); if (equalIgnoringCase(familyName, systemUIMonospacedNumbersFontWithApplePrefix)) { - NSDictionary *attributes = @{ (NSString *)kCTFontFeatureTypeIdentifierKey : @(kNumberSpacingType), - (NSString *)kCTFontFeatureSelectorIdentifierKey : @(kMonospacedNumbersSelector) }; - - RetainPtr fontDescriptor = adoptCF(CTFontDescriptorCreateWithAttributesAndOptions((CFDictionaryRef)attributes, kCTFontDescriptorOptionSystemUIFont | kCTFontDescriptorOptionPreferAppleSystemFont)); - return CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr); + RetainPtr systemFontDescriptor = adoptCF(CTFontDescriptorCreateForUIType(kCTFontUIFontSystem, size, nullptr)); + RetainPtr monospaceFontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithFeature(systemFontDescriptor.get(), (CFNumberRef)@(kNumberSpacingType), (CFNumberRef)@(kMonospacedNumbersSelector))); + return CTFontCreateWithFontDescriptor(monospaceFontDescriptor.get(), size, nullptr); } -- 1.8.3.1