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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 722 } |
723 #endif | 723 #endif |
724 } | 724 } |
725 | 725 |
726 int SkTypeface_FreeType::onGetUPEM() const { | 726 int SkTypeface_FreeType::onGetUPEM() const { |
727 AutoFTAccess fta(this); | 727 AutoFTAccess fta(this); |
728 FT_Face face = fta.face(); | 728 FT_Face face = fta.face(); |
729 return face ? face->units_per_EM : 0; | 729 return face ? face->units_per_EM : 0; |
730 } | 730 } |
731 | 731 |
| 732 bool SkTypeface_FreeType::onGetKerningPairAdjustments(const uint16_t glyphs[], |
| 733 int count, int32_t adjustments[]) const { |
| 734 AutoFTAccess fta(this); |
| 735 FT_Face face = fta.face(); |
| 736 if (!face || !FT_HAS_KERNING(face)) { |
| 737 return false; |
| 738 } |
| 739 |
| 740 for (int i = 0; i < count - 1; ++i) { |
| 741 FT_Vector delta; |
| 742 FT_Error err = FT_Get_Kerning(face, glyphs[i], glyphs[i+1], |
| 743 FT_KERNING_UNSCALED, &delta); |
| 744 if (err) { |
| 745 return false; |
| 746 } |
| 747 adjustments[i] = delta.x; |
| 748 } |
| 749 return true; |
| 750 } |
| 751 |
732 SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface, | 752 SkScalerContext_FreeType::SkScalerContext_FreeType(SkTypeface* typeface, |
733 const SkDescriptor* desc) | 753 const SkDescriptor* desc) |
734 : SkScalerContext_FreeType_Base(typeface, desc) { | 754 : SkScalerContext_FreeType_Base(typeface, desc) { |
735 SkAutoMutexAcquire ac(gFTMutex); | 755 SkAutoMutexAcquire ac(gFTMutex); |
736 | 756 |
737 if (gFTCount == 0) { | 757 if (gFTCount == 0) { |
738 if (!InitFreetype()) { | 758 if (!InitFreetype()) { |
739 sk_throw(); | 759 sk_throw(); |
740 } | 760 } |
741 } | 761 } |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 *style = (SkTypeface::Style) tempStyle; | 1521 *style = (SkTypeface::Style) tempStyle; |
1502 } | 1522 } |
1503 if (isFixedPitch) { | 1523 if (isFixedPitch) { |
1504 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1524 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
1505 } | 1525 } |
1506 | 1526 |
1507 FT_Done_Face(face); | 1527 FT_Done_Face(face); |
1508 FT_Done_FreeType(library); | 1528 FT_Done_FreeType(library); |
1509 return true; | 1529 return true; |
1510 } | 1530 } |
OLD | NEW |