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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 bool got_m, got_x; | 595 bool got_m, got_x; |
596 got_m = GetLetterCBox(face, 'M', &m_bbox); | 596 got_m = GetLetterCBox(face, 'M', &m_bbox); |
597 got_x = GetLetterCBox(face, 'X', &x_bbox); | 597 got_x = GetLetterCBox(face, 'X', &x_bbox); |
598 if (got_m && got_x) { | 598 if (got_m && got_x) { |
599 info->fCapHeight = (m_bbox.yMax - m_bbox.yMin + x_bbox.yMax - | 599 info->fCapHeight = (m_bbox.yMax - m_bbox.yMin + x_bbox.yMax - |
600 x_bbox.yMin) / 2; | 600 x_bbox.yMin) / 2; |
601 } else if (got_m && !got_x) { | 601 } else if (got_m && !got_x) { |
602 info->fCapHeight = m_bbox.yMax - m_bbox.yMin; | 602 info->fCapHeight = m_bbox.yMax - m_bbox.yMin; |
603 } else if (!got_m && got_x) { | 603 } else if (!got_m && got_x) { |
604 info->fCapHeight = x_bbox.yMax - x_bbox.yMin; | 604 info->fCapHeight = x_bbox.yMax - x_bbox.yMin; |
| 605 } else { |
| 606 // Last resort, use the ascent. |
| 607 info->fCapHeight = info->fAscent; |
605 } | 608 } |
606 } | 609 } |
607 | 610 |
608 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, | 611 info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, |
609 face->bbox.xMax, face->bbox.yMin); | 612 face->bbox.xMax, face->bbox.yMin); |
610 | 613 |
611 if (!canEmbed(face) || !FT_IS_SCALABLE(face) || | 614 if (!canEmbed(face) || !FT_IS_SCALABLE(face) || |
612 info->fType == SkAdvancedTypefaceMetrics::kOther_Font) { | 615 info->fType == SkAdvancedTypefaceMetrics::kOther_Font) { |
613 perGlyphInfo = SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo; | 616 perGlyphInfo = SkAdvancedTypefaceMetrics::kNo_PerGlyphInfo; |
614 } | 617 } |
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 *style = (SkTypeface::Style) tempStyle; | 1665 *style = (SkTypeface::Style) tempStyle; |
1663 } | 1666 } |
1664 if (isFixedPitch) { | 1667 if (isFixedPitch) { |
1665 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1668 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
1666 } | 1669 } |
1667 | 1670 |
1668 FT_Done_Face(face); | 1671 FT_Done_Face(face); |
1669 FT_Done_FreeType(library); | 1672 FT_Done_FreeType(library); |
1670 return true; | 1673 return true; |
1671 } | 1674 } |
OLD | NEW |