Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2621)

Unified Diff: Source/platform/fonts/mac/SimpleFontDataMac.mm

Issue 147703002: Calculate Underline thickness from Font (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding Test cases in TestExpectations Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/FontMetrics.h ('k') | Source/platform/fonts/skia/SimpleFontDataSkia.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/mac/SimpleFontDataMac.mm
diff --git a/Source/platform/fonts/mac/SimpleFontDataMac.mm b/Source/platform/fonts/mac/SimpleFontDataMac.mm
index 4d5533eea80e2c21d4d52f908d99193eb260d405..de856d5862a9773eeae46a8deb25f13dcaf0ab77 100644
--- a/Source/platform/fonts/mac/SimpleFontDataMac.mm
+++ b/Source/platform/fonts/mac/SimpleFontDataMac.mm
@@ -155,7 +155,7 @@ void SimpleFontData::platformInit()
fallbackFontFamily = @"Times New Roman";
else
fallbackFontFamily = webFallbackFontFamily();
-
+
// Try setting up the alternate font.
// This is a last ditch effort to use a substitute font when something has gone wrong.
#if !ERROR_DISABLED
@@ -195,11 +195,12 @@ void SimpleFontData::platformInit()
WTF_LOG_ERROR("failed to set up font, using system font %s", m_platformData.font());
initFontData(this);
}
-
+
int iAscent;
int iDescent;
int iLineGap;
unsigned unitsPerEm;
+
iAscent = CGFontGetAscent(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.
@@ -211,6 +212,7 @@ void SimpleFontData::platformInit()
float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
+ float underlineThickness = CTFontGetUnderlineThickness(m_platformData.ctFont());
// We need to adjust Times, Helvetica, and Courier to closely match the
// vertical metrics of their Microsoft counterparts that are the de facto
@@ -230,7 +232,7 @@ void SimpleFontData::platformInit()
lineGap -= 3 - descent;
descent = 3;
}
-
+
if (platformData().orientation() == Vertical && !isTextOrientationFallback())
m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
@@ -253,6 +255,7 @@ void SimpleFontData::platformInit()
m_fontMetrics.setDescent(descent);
m_fontMetrics.setLineGap(lineGap);
m_fontMetrics.setXHeight(xHeight);
+ m_fontMetrics.setUnderlineThickness(underlineThickness);
}
static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCode tableName)
@@ -264,7 +267,7 @@ void SimpleFontData::platformCharWidthInit()
{
m_avgCharWidth = 0;
m_maxCharWidth = 0;
-
+
RetainPtr<CFDataRef> os2Table(AdoptCF, copyFontTableForTag(m_platformData, 'OS/2'));
if (os2Table && CFDataGetLength(os2Table.get()) >= 4) {
const UInt8* os2 = CFDataGetBytePtr(os2Table.get());
« no previous file with comments | « Source/platform/fonts/FontMetrics.h ('k') | Source/platform/fonts/skia/SimpleFontDataSkia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698