check for exceeding int range when we stash the values in the cache
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 29 Aug 2012 19:46:06 +0000 (19:46 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 29 Aug 2012 19:46:06 +0000 (19:46 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@5339 2bbb7eff-a529-9590-31e7-b0007b416f81

src/ports/SkFontHost_mac_coretext.cpp

index 21fb2ed..307985f 100644 (file)
@@ -1016,8 +1016,8 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) {
     }
 
     glyph->zeroMetrics();
-    glyph->fAdvanceX =  SkFloatToFixed(theAdvance.width);
-    glyph->fAdvanceY = -SkFloatToFixed(theAdvance.height);
+    glyph->fAdvanceX =  SkFloatToFixed_Check(theAdvance.width);
+    glyph->fAdvanceY = -SkFloatToFixed_Check(theAdvance.height);
 
     if (CGRectIsEmpty_inline(theBounds)) {
         return;
@@ -1060,14 +1060,14 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) {
             theBounds.origin.y = SkScalarToFloat(adjust.fTop) - 1;
         }
         // Lion returns fractions in the bounds
-        glyph->fWidth = sk_float_ceil2int(theBounds.size.width);
-        glyph->fHeight = sk_float_ceil2int(theBounds.size.height);
+        glyph->fWidth = SkToU16(sk_float_ceil2int(theBounds.size.width));
+        glyph->fHeight = SkToU16(sk_float_ceil2int(theBounds.size.height));
     } else {
-        glyph->fWidth = sk_float_round2int(theBounds.size.width);
-        glyph->fHeight = sk_float_round2int(theBounds.size.height);
+        glyph->fWidth = SkToU16(sk_float_round2int(theBounds.size.width));
+        glyph->fHeight = SkToU16(sk_float_round2int(theBounds.size.height));
     }
-    glyph->fTop      = -sk_float_round2int(CGRectGetMaxY_inline(theBounds));
-    glyph->fLeft     =  sk_float_round2int(CGRectGetMinX_inline(theBounds));
+    glyph->fTop      = SkToS16(-sk_float_round2int(CGRectGetMaxY_inline(theBounds)));
+    glyph->fLeft     = SkToS16(sk_float_round2int(CGRectGetMinX_inline(theBounds)));
     SkIPoint offset;
     if (fVertical && (isSnowLeopard() || lionAdjustedMetrics)) {
     // SnowLeopard doesn't respect vertical metrics, so compute them manually.