Modified: trunk/Source/WebCore/ChangeLog (188796 => 188797)
--- trunk/Source/WebCore/ChangeLog 2015-08-21 23:30:40 UTC (rev 188796)
+++ trunk/Source/WebCore/ChangeLog 2015-08-21 23:34:07 UTC (rev 188797)
@@ -1,5 +1,20 @@
2015-08-21 Myles C. Maxfield <mmaxfi...@apple.com>
+ [Cocoa] Clean up Font class
+ https://bugs.webkit.org/show_bug.cgi?id=148216
+
+ Reviewed by Dean Jackson.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::platformGlyphInit): Deleted.
+ * platform/graphics/Font.h:
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::Font::platformInit):
+
+2015-08-21 Myles C. Maxfield <mmaxfi...@apple.com>
+
[Cocoa] Unify two more FontCache functions
https://bugs.webkit.org/show_bug.cgi?id=148217
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (188796 => 188797)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-21 23:30:40 UTC (rev 188796)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-21 23:34:07 UTC (rev 188797)
@@ -118,12 +118,7 @@
{
auto* glyphPageZero = glyphPage(0);
if (!glyphPageZero) {
- m_spaceGlyph = 0;
- m_spaceWidth = 0;
- m_zeroGlyph = 0;
- m_adjustedSpaceWidth = 0;
determinePitch();
- m_zeroWidthSpaceGlyph = 0;
return;
}
Modified: trunk/Source/WebCore/platform/graphics/Font.h (188796 => 188797)
--- trunk/Source/WebCore/platform/graphics/Font.h 2015-08-21 23:30:40 UTC (rev 188796)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2015-08-21 23:34:07 UTC (rev 188797)
@@ -258,12 +258,12 @@
RefPtr<OpenTypeVerticalData> m_verticalData;
#endif
- Glyph m_spaceGlyph;
- float m_spaceWidth;
- Glyph m_zeroGlyph;
- float m_adjustedSpaceWidth;
+ Glyph m_spaceGlyph { 0 };
+ float m_spaceWidth { 0 };
+ Glyph m_zeroGlyph { 0 };
+ float m_adjustedSpaceWidth { 0 };
- Glyph m_zeroWidthSpaceGlyph;
+ Glyph m_zeroWidthSpaceGlyph { 0 };
struct DerivedFontData {
#if !COMPILER(MSVC)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (188796 => 188797)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-08-21 23:30:40 UTC (rev 188796)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2015-08-21 23:34:07 UTC (rev 188797)
@@ -152,38 +152,33 @@
m_isSystemFont = CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(m_platformData.font())).get());
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101100
// Work around <rdar://problem/19433490>
CGGlyph dummyGlyphs[] = {0, 0};
CGSize dummySize[] = { CGSizeMake(0, 0), CGSizeMake(0, 0) };
CTFontTransformGlyphs(m_platformData.ctFont(), dummyGlyphs, dummySize, 2, kCTFontTransformApplyPositioning | kCTFontTransformApplyShaping);
-
- int iAscent;
- int iDescent;
- int iCapHeight;
- int iLineGap;
- unsigned unitsPerEm;
- iAscent = CGFontGetAscent(m_platformData.cgFont());
+#endif
+
+ unsigned unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont());
+
// Some fonts erroneously specify a positive descender value. We follow Core Text in assuming that
// such fonts meant the same distance, but in the reverse direction.
- iDescent = -abs(CGFontGetDescent(m_platformData.cgFont()));
- iCapHeight = CGFontGetCapHeight(m_platformData.cgFont());
- iLineGap = CGFontGetLeading(m_platformData.cgFont());
- unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont());
-
float pointSize = m_platformData.m_size;
- float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
- float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
- float capHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
+ float ascent = scaleEmToUnits(CGFontGetAscent(m_platformData.cgFont()), unitsPerEm) * pointSize;
+ float descent = -scaleEmToUnits(-abs(CGFontGetDescent(m_platformData.cgFont())), unitsPerEm) * pointSize;
+ float capHeight = scaleEmToUnits(CGFontGetCapHeight(m_platformData.cgFont()), unitsPerEm) * pointSize;
- float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
+ float lineGap = scaleEmToUnits(CGFontGetLeading(m_platformData.cgFont()), unitsPerEm) * pointSize;
// We need to adjust Times, Helvetica, and Courier to closely match the
// vertical metrics of their Microsoft counterparts that are the de facto
// web standard. The AppKit adjustment of 20% is too big and is
// incorrectly added to line spacing, so we use a 15% adjustment instead
// and add it to the ascent.
- NSString *familyName = [m_platformData.nsFont() familyName];
- if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"])
+ RetainPtr<CFStringRef> familyName = adoptCF(CTFontCopyFamilyName(m_platformData.font()));
+ if (familyName && (CFStringCompare(familyName.get(), CFSTR("Times"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
+ || CFStringCompare(familyName.get(), CFSTR("Helvetica"), kCFCompareCaseInsensitive) == kCFCompareEqualTo
+ || CFStringCompare(familyName.get(), CFSTR("Courier"), kCFCompareCaseInsensitive) == kCFCompareEqualTo))
ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
// Compute and store line spacing, before the line metrics hacks are applied.
@@ -191,7 +186,7 @@
// Hack Hiragino line metrics to allow room for marked text underlines.
// <rdar://problem/5386183>
- if (descent < 3 && lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) {
+ if (descent < 3 && lineGap >= 3 && familyName && CFStringHasPrefix(familyName.get(), CFSTR("Hiragino"))) {
lineGap -= 3 - descent;
descent = 3;
}
@@ -223,8 +218,6 @@
m_isSystemFont = CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(m_platformData.font())).get());
m_syntheticBoldOffset = m_platformData.m_syntheticBold ? ceilf(m_platformData.size() / 24.0f) : 0.f;
- m_spaceGlyph = 0;
- m_spaceWidth = 0;
CTFontRef ctFont = m_platformData.font();
FontServicesIOS fontService(ctFont);