OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 } | 1280 } |
1281 | 1281 |
1282 FontMetrics storage; | 1282 FontMetrics storage; |
1283 if (NULL == metrics) { | 1283 if (NULL == metrics) { |
1284 metrics = &storage; | 1284 metrics = &storage; |
1285 } | 1285 } |
1286 | 1286 |
1287 paint.descriptorProc(NULL, zoomPtr, FontMetricsDescProc, metrics, true); | 1287 paint.descriptorProc(NULL, zoomPtr, FontMetricsDescProc, metrics, true); |
1288 | 1288 |
1289 if (scale) { | 1289 if (scale) { |
1290 // Assuming Font will have correct metrics for Underline Thickness and P osition | |
1291 metrics->fFontMetricsFlag = 0x03; | |
1292 | |
1290 metrics->fTop = SkScalarMul(metrics->fTop, scale); | 1293 metrics->fTop = SkScalarMul(metrics->fTop, scale); |
1291 metrics->fAscent = SkScalarMul(metrics->fAscent, scale); | 1294 metrics->fAscent = SkScalarMul(metrics->fAscent, scale); |
1292 metrics->fDescent = SkScalarMul(metrics->fDescent, scale); | 1295 metrics->fDescent = SkScalarMul(metrics->fDescent, scale); |
1293 metrics->fBottom = SkScalarMul(metrics->fBottom, scale); | 1296 metrics->fBottom = SkScalarMul(metrics->fBottom, scale); |
1294 metrics->fLeading = SkScalarMul(metrics->fLeading, scale); | 1297 metrics->fLeading = SkScalarMul(metrics->fLeading, scale); |
1295 metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale); | 1298 metrics->fAvgCharWidth = SkScalarMul(metrics->fAvgCharWidth, scale); |
1296 metrics->fXMin = SkScalarMul(metrics->fXMin, scale); | 1299 metrics->fXMin = SkScalarMul(metrics->fXMin, scale); |
1297 metrics->fXMax = SkScalarMul(metrics->fXMax, scale); | 1300 metrics->fXMax = SkScalarMul(metrics->fXMax, scale); |
1298 metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale); | 1301 metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale); |
1302 | |
1303 metrics->fUnderlineThickness = SkScalarMul(metrics->fUnderlineThickness, scale); | |
1304 // Following is to check if we have faulty underline thciness metrics | |
1305 if ( (metrics->fUnderlineThickness == 0) || (metrics->fUnderlineThicknes s >= metrics->fAscent/2)) | |
bungeman-skia
2014/02/17 19:10:06
Why would these checks only be done when there is
h.joshi
2014/02/18 05:48:48
Added these to check faulty font metrics for Under
| |
1306 { | |
1307 metrics->fFontMetricsFlag = metrics->fFontMetricsFlag ^ FontMetrics ::kUnderlineThinknessIsValid_FontMetricFlag; | |
1308 } | |
1309 | |
1310 metrics->fUnderlinePosition = SkScalarMul(metrics->fUnderlinePosition, s cale); | |
1311 // Following is to check if we have faulty underlien position metrics | |
1312 if(SkScalarAbs(metrics->fUnderlinePosition) >= (metrics->fDescent + metr ics->fLeading)) | |
1313 { | |
1314 metrics->fFontMetricsFlag = metrics->fFontMetricsFlag ^FontMetrics:: kUnderlinePositionIsValid_FontMetricsflag; | |
1315 } | |
1299 } | 1316 } |
1300 return metrics->fDescent - metrics->fAscent + metrics->fLeading; | 1317 return metrics->fDescent - metrics->fAscent + metrics->fLeading; |
1301 } | 1318 } |
1302 | 1319 |
1303 /////////////////////////////////////////////////////////////////////////////// | 1320 /////////////////////////////////////////////////////////////////////////////// |
1304 | 1321 |
1305 static void set_bounds(const SkGlyph& g, SkRect* bounds, SkScalar scale) { | 1322 static void set_bounds(const SkGlyph& g, SkRect* bounds, SkScalar scale) { |
1306 bounds->set(g.fLeft * scale, | 1323 bounds->set(g.fLeft * scale, |
1307 g.fTop * scale, | 1324 g.fTop * scale, |
1308 (g.fLeft + g.fWidth) * scale, | 1325 (g.fLeft + g.fWidth) * scale, |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2250 this->getMaskFilter()->computeFastBounds(*storage, storage); | 2267 this->getMaskFilter()->computeFastBounds(*storage, storage); |
2251 } | 2268 } |
2252 | 2269 |
2253 if (this->getImageFilter()) { | 2270 if (this->getImageFilter()) { |
2254 this->getImageFilter()->computeFastBounds(*storage, storage); | 2271 this->getImageFilter()->computeFastBounds(*storage, storage); |
2255 } | 2272 } |
2256 | 2273 |
2257 return *storage; | 2274 return *storage; |
2258 } | 2275 } |
2259 | 2276 |
2277 bool SkPaint::isFontMetricsFlagSet(FontMetrics * fObject, FontMetrics::FontMetri csFlags flag) const | |
2278 { | |
2279 if(fObject != NULL) { | |
2280 return SkToBool(fObject->fFontMetricsFlag & flag); | |
2281 } | |
2282 return false; | |
2283 } | |
2284 | |
2260 #ifdef SK_DEVELOPER | 2285 #ifdef SK_DEVELOPER |
2261 void SkPaint::toString(SkString* str) const { | 2286 void SkPaint::toString(SkString* str) const { |
2262 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); | 2287 str->append("<dl><dt>SkPaint:</dt><dd><dl>"); |
2263 | 2288 |
2264 SkTypeface* typeface = this->getTypeface(); | 2289 SkTypeface* typeface = this->getTypeface(); |
2265 if (NULL != typeface) { | 2290 if (NULL != typeface) { |
2266 SkDynamicMemoryWStream ostream; | 2291 SkDynamicMemoryWStream ostream; |
2267 typeface->serialize(&ostream); | 2292 typeface->serialize(&ostream); |
2268 SkAutoTUnref<SkData> data(ostream.copyToData()); | 2293 SkAutoTUnref<SkData> data(ostream.copyToData()); |
2269 | 2294 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2543 case SkXfermode::kPlus_Mode: | 2568 case SkXfermode::kPlus_Mode: |
2544 return 0 == this->getAlpha(); | 2569 return 0 == this->getAlpha(); |
2545 case SkXfermode::kDst_Mode: | 2570 case SkXfermode::kDst_Mode: |
2546 return true; | 2571 return true; |
2547 default: | 2572 default: |
2548 break; | 2573 break; |
2549 } | 2574 } |
2550 } | 2575 } |
2551 return false; | 2576 return false; |
2552 } | 2577 } |
OLD | NEW |