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

Unified Diff: app/gfx/font_mac.mm

Issue 351024: Fixed font height on OS X. Also added some unittests. (Closed)
Patch Set: Expanded on comment. Created 11 years, 1 month 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 | « app/gfx/font.h ('k') | app/gfx/font_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/font_mac.mm
diff --git a/app/gfx/font_mac.mm b/app/gfx/font_mac.mm
index 56cc6bc6a9350da180f4c20a571c78776cfee01b..abbf6f4fef5a2789bd51a8cabf16f6e3770adfc3 100644
--- a/app/gfx/font_mac.mm
+++ b/app/gfx/font_mac.mm
@@ -7,6 +7,7 @@
#include <Cocoa/Cocoa.h>
#include "base/logging.h"
+#include "base/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
namespace gfx {
@@ -33,10 +34,9 @@ Font::Font()
void Font::calculateMetrics() {
NSFont* font = nativeFont();
- // TODO(akalin): This is the wrong height to use! Use either the height
- // of the bounding rect for the font or ascender - descender; this needs
- // further investigation. Width may be wrong, too.
- height_ = [font xHeight];
+ scoped_nsobject<NSLayoutManager> layout_manager(
+ [[NSLayoutManager alloc] init]);
+ height_ = [layout_manager defaultLineHeightForFont:font];
ascent_ = [font ascender];
avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width;
}
« no previous file with comments | « app/gfx/font.h ('k') | app/gfx/font_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698