Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / platform_font_ios.mm
index aba239b..0fd824f 100644 (file)
@@ -6,10 +6,13 @@
 
 #import <UIKit/UIKit.h>
 
+#include <cmath>
+
 #include "base/basictypes.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/gfx/font.h"
+#include "ui/gfx/font_render_params.h"
 
 namespace gfx {
 
@@ -75,6 +78,12 @@ int PlatformFontIOS::GetFontSize() const {
   return font_size_;
 }
 
+const FontRenderParams& PlatformFontIOS::GetFontRenderParams() const {
+  NOTIMPLEMENTED();
+  static FontRenderParams params;
+  return params;
+}
+
 NativeFont PlatformFontIOS::GetNativeFont() const {
   return [UIFont fontWithName:base::SysUTF8ToNSString(font_name_)
                          size:font_size_];
@@ -103,7 +112,12 @@ void PlatformFontIOS::CalculateMetrics() {
   height_ = font.lineHeight;
   ascent_ = font.ascender;
   cap_height_ = font.capHeight;
-  average_width_ = [@"x" sizeWithFont:font].width;
+  if (font) {
+    NSDictionary* attributes = @{ NSFontAttributeName : font };
+    average_width_ = std::ceil([@"x" sizeWithAttributes:attributes].width);
+  } else {
+    average_width_ = 0;
+  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////