| 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 "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 SkScalar underlineThickness, underlinePosition; | 1400 SkScalar underlineThickness, underlinePosition; |
| 1401 if (face->face_flags & FT_FACE_FLAG_SCALABLE) { // scalable outline font | 1401 if (face->face_flags & FT_FACE_FLAG_SCALABLE) { // scalable outline font |
| 1402 ascent = -SkIntToScalar(face->ascender) / upem; | 1402 ascent = -SkIntToScalar(face->ascender) / upem; |
| 1403 descent = -SkIntToScalar(face->descender) / upem; | 1403 descent = -SkIntToScalar(face->descender) / upem; |
| 1404 leading = SkIntToScalar(face->height + (face->descender - face->ascender
)) / upem; | 1404 leading = SkIntToScalar(face->height + (face->descender - face->ascender
)) / upem; |
| 1405 xmin = SkIntToScalar(face->bbox.xMin) / upem; | 1405 xmin = SkIntToScalar(face->bbox.xMin) / upem; |
| 1406 xmax = SkIntToScalar(face->bbox.xMax) / upem; | 1406 xmax = SkIntToScalar(face->bbox.xMax) / upem; |
| 1407 ymin = -SkIntToScalar(face->bbox.yMin) / upem; | 1407 ymin = -SkIntToScalar(face->bbox.yMin) / upem; |
| 1408 ymax = -SkIntToScalar(face->bbox.yMax) / upem; | 1408 ymax = -SkIntToScalar(face->bbox.yMax) / upem; |
| 1409 underlineThickness = SkIntToScalar(face->underline_thickness) / upem; | 1409 underlineThickness = SkIntToScalar(face->underline_thickness) / upem; |
| 1410 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX | |
| 1411 underlinePosition = -SkIntToScalar(face->underline_position) / upem; | |
| 1412 #else | |
| 1413 underlinePosition = -SkIntToScalar(face->underline_position + | 1410 underlinePosition = -SkIntToScalar(face->underline_position + |
| 1414 face->underline_thickness / 2) / upem
; | 1411 face->underline_thickness / 2) / upem
; |
| 1415 #endif | |
| 1416 | 1412 |
| 1417 if(mx) { | 1413 if(mx) { |
| 1418 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | 1414 mx->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
| 1419 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | 1415 mx->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
| 1420 } | 1416 } |
| 1421 if(my){ | 1417 if(my){ |
| 1422 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | 1418 my->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
| 1423 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | 1419 my->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
| 1424 } | 1420 } |
| 1425 // we may be able to synthesize x_height and cap_height from outline | 1421 // we may be able to synthesize x_height and cap_height from outline |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 mx->fTop = ymax * mxy; | 1477 mx->fTop = ymax * mxy; |
| 1482 mx->fAscent = ascent * mxy; | 1478 mx->fAscent = ascent * mxy; |
| 1483 mx->fDescent = descent * mxy; | 1479 mx->fDescent = descent * mxy; |
| 1484 mx->fBottom = ymin * mxy; | 1480 mx->fBottom = ymin * mxy; |
| 1485 mx->fLeading = leading * mxy; | 1481 mx->fLeading = leading * mxy; |
| 1486 mx->fAvgCharWidth = avgCharWidth * mxy; | 1482 mx->fAvgCharWidth = avgCharWidth * mxy; |
| 1487 mx->fXMin = xmin; | 1483 mx->fXMin = xmin; |
| 1488 mx->fXMax = xmax; | 1484 mx->fXMax = xmax; |
| 1489 mx->fXHeight = x_height; | 1485 mx->fXHeight = x_height; |
| 1490 mx->fCapHeight = cap_height; | 1486 mx->fCapHeight = cap_height; |
| 1491 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX | |
| 1492 mx->fUnderlineThickness = underlineThickness; | |
| 1493 mx->fUnderlinePosition = underlinePosition; | |
| 1494 #else | |
| 1495 mx->fUnderlineThickness = underlineThickness * mxy; | 1487 mx->fUnderlineThickness = underlineThickness * mxy; |
| 1496 mx->fUnderlinePosition = underlinePosition * mxy; | 1488 mx->fUnderlinePosition = underlinePosition * mxy; |
| 1497 #endif | |
| 1498 } | 1489 } |
| 1499 if (my) { | 1490 if (my) { |
| 1500 my->fTop = ymax * myy; | 1491 my->fTop = ymax * myy; |
| 1501 my->fAscent = ascent * myy; | 1492 my->fAscent = ascent * myy; |
| 1502 my->fDescent = descent * myy; | 1493 my->fDescent = descent * myy; |
| 1503 my->fBottom = ymin * myy; | 1494 my->fBottom = ymin * myy; |
| 1504 my->fLeading = leading * myy; | 1495 my->fLeading = leading * myy; |
| 1505 my->fAvgCharWidth = avgCharWidth * myy; | 1496 my->fAvgCharWidth = avgCharWidth * myy; |
| 1506 my->fXMin = xmin; | 1497 my->fXMin = xmin; |
| 1507 my->fXMax = xmax; | 1498 my->fXMax = xmax; |
| 1508 my->fXHeight = x_height; | 1499 my->fXHeight = x_height; |
| 1509 my->fCapHeight = cap_height; | 1500 my->fCapHeight = cap_height; |
| 1510 #ifdef SK_IGNORE_UNDERLINE_POSITION_FIX | |
| 1511 my->fUnderlineThickness = underlineThickness; | |
| 1512 my->fUnderlinePosition = underlinePosition; | |
| 1513 #else | |
| 1514 my->fUnderlineThickness = underlineThickness * myy; | 1501 my->fUnderlineThickness = underlineThickness * myy; |
| 1515 my->fUnderlinePosition = underlinePosition * myy; | 1502 my->fUnderlinePosition = underlinePosition * myy; |
| 1516 #endif | |
| 1517 } | 1503 } |
| 1518 } | 1504 } |
| 1519 | 1505 |
| 1520 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph
) | 1506 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph
) |
| 1521 { | 1507 { |
| 1522 // check to see if the embolden bit is set | 1508 // check to see if the embolden bit is set |
| 1523 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { | 1509 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { |
| 1524 return; | 1510 return; |
| 1525 } | 1511 } |
| 1526 | 1512 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 *style = (SkTypeface::Style) tempStyle; | 1728 *style = (SkTypeface::Style) tempStyle; |
| 1743 } | 1729 } |
| 1744 if (isFixedPitch) { | 1730 if (isFixedPitch) { |
| 1745 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1731 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
| 1746 } | 1732 } |
| 1747 | 1733 |
| 1748 FT_Done_Face(face); | 1734 FT_Done_Face(face); |
| 1749 FT_Done_FreeType(library); | 1735 FT_Done_FreeType(library); |
| 1750 return true; | 1736 return true; |
| 1751 } | 1737 } |
| OLD | NEW |