| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAdvancedTypefaceMetrics.h" | 8 #include "SkAdvancedTypefaceMetrics.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| 11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 12 #include "SkDescriptor.h" | 12 #include "SkDescriptor.h" |
| 13 #include "SkFDot6.h" | 13 #include "SkFDot6.h" |
| 14 #include "SkFontDescriptor.h" | 14 #include "SkFontDescriptor.h" |
| 15 #include "SkFontHost_FreeType_common.h" | 15 #include "SkFontHost_FreeType_common.h" |
| 16 #include "SkGlyph.h" | 16 #include "SkGlyph.h" |
| 17 #include "SkMask.h" | 17 #include "SkMask.h" |
| 18 #include "SkMaskGamma.h" | 18 #include "SkMaskGamma.h" |
| 19 #include "SkMatrix22.h" | 19 #include "SkMatrix22.h" |
| 20 #include "SkMutex.h" | 20 #include "SkMutex.h" |
| 21 #include "SkOTUtils.h" | 21 #include "SkOTUtils.h" |
| 22 #include "SkPath.h" | 22 #include "SkPath.h" |
| 23 #include "SkScalerContext.h" | 23 #include "SkScalerContext.h" |
| 24 #include "SkStream.h" | 24 #include "SkStream.h" |
| 25 #include "SkString.h" | 25 #include "SkString.h" |
| 26 #include "SkTemplates.h" | 26 #include "SkTemplates.h" |
| 27 #include "SkTypes.h" | 27 #include "SkTypes.h" |
| 28 #include <memory> | 28 #include "SkUniquePtr.h" |
| 29 | 29 |
| 30 #if defined(SK_CAN_USE_DLOPEN) | 30 #if defined(SK_CAN_USE_DLOPEN) |
| 31 #include <dlfcn.h> | 31 #include <dlfcn.h> |
| 32 #endif | 32 #endif |
| 33 #include <ft2build.h> | 33 #include <ft2build.h> |
| 34 #include FT_ADVANCES_H | 34 #include FT_ADVANCES_H |
| 35 #include FT_BITMAP_H | 35 #include FT_BITMAP_H |
| 36 #include FT_FREETYPE_H | 36 #include FT_FREETYPE_H |
| 37 #include FT_LCD_FILTER_H | 37 #include FT_LCD_FILTER_H |
| 38 #include FT_MODULE_H | 38 #include FT_MODULE_H |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 , fStrikeIndex(-1) | 795 , fStrikeIndex(-1) |
| 796 { | 796 { |
| 797 SkAutoMutexAcquire ac(gFTMutex); | 797 SkAutoMutexAcquire ac(gFTMutex); |
| 798 | 798 |
| 799 if (!ref_ft_library()) { | 799 if (!ref_ft_library()) { |
| 800 sk_throw(); | 800 sk_throw(); |
| 801 } | 801 } |
| 802 | 802 |
| 803 // load the font file | 803 // load the font file |
| 804 using UnrefFTFace = SkFunctionWrapper<void, skstd::remove_pointer_t<FT_Face>
, unref_ft_face>; | 804 using UnrefFTFace = SkFunctionWrapper<void, skstd::remove_pointer_t<FT_Face>
, unref_ft_face>; |
| 805 std::unique_ptr<skstd::remove_pointer_t<FT_Face>, UnrefFTFace> ftFace(ref_ft
_face(typeface)); | 805 skstd::unique_ptr<skstd::remove_pointer_t<FT_Face>, UnrefFTFace> ftFace(ref_
ft_face(typeface)); |
| 806 if (nullptr == ftFace) { | 806 if (nullptr == ftFace) { |
| 807 SkDEBUGF(("Could not create FT_Face.\n")); | 807 SkDEBUGF(("Could not create FT_Face.\n")); |
| 808 return; | 808 return; |
| 809 } | 809 } |
| 810 | 810 |
| 811 fRec.computeMatrices(SkScalerContextRec::kFull_PreMatrixScale, &fScale, &fMa
trix22Scalar); | 811 fRec.computeMatrices(SkScalerContextRec::kFull_PreMatrixScale, &fScale, &fMa
trix22Scalar); |
| 812 fMatrix22Scalar.setSkewX(-fMatrix22Scalar.getSkewX()); | 812 fMatrix22Scalar.setSkewX(-fMatrix22Scalar.getSkewX()); |
| 813 fMatrix22Scalar.setSkewY(-fMatrix22Scalar.getSkewY()); | 813 fMatrix22Scalar.setSkewY(-fMatrix22Scalar.getSkewY()); |
| 814 | 814 |
| 815 fScaleX = SkScalarToFDot6(fScale.fX); | 815 fScaleX = SkScalarToFDot6(fScale.fX); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 if (fRec.fFlags & SkScalerContext::kVertical_Flag) { | 884 if (fRec.fFlags & SkScalerContext::kVertical_Flag) { |
| 885 loadFlags |= FT_LOAD_VERTICAL_LAYOUT; | 885 loadFlags |= FT_LOAD_VERTICAL_LAYOUT; |
| 886 } | 886 } |
| 887 | 887 |
| 888 loadFlags |= FT_LOAD_COLOR; | 888 loadFlags |= FT_LOAD_COLOR; |
| 889 | 889 |
| 890 fLoadGlyphFlags = loadFlags; | 890 fLoadGlyphFlags = loadFlags; |
| 891 } | 891 } |
| 892 | 892 |
| 893 using DoneFTSize = SkFunctionWrapper<FT_Error, skstd::remove_pointer_t<FT_Si
ze>, FT_Done_Size>; | 893 using DoneFTSize = SkFunctionWrapper<FT_Error, skstd::remove_pointer_t<FT_Si
ze>, FT_Done_Size>; |
| 894 std::unique_ptr<skstd::remove_pointer_t<FT_Size>, DoneFTSize> ftSize([&ftFac
e]() -> FT_Size { | 894 skstd::unique_ptr<skstd::remove_pointer_t<FT_Size>, DoneFTSize> ftSize([&ftF
ace]() -> FT_Size { |
| 895 FT_Size size; | 895 FT_Size size; |
| 896 FT_Error err = FT_New_Size(ftFace.get(), &size); | 896 FT_Error err = FT_New_Size(ftFace.get(), &size); |
| 897 if (err != 0) { | 897 if (err != 0) { |
| 898 SkDEBUGF(("FT_New_Size returned %x for face %s\n", err, ftFace->fami
ly_name)); | 898 SkDEBUGF(("FT_New_Size returned %x for face %s\n", err, ftFace->fami
ly_name)); |
| 899 return nullptr; | 899 return nullptr; |
| 900 } | 900 } |
| 901 return size; | 901 return size; |
| 902 }()); | 902 }()); |
| 903 if (nullptr == ftSize) { | 903 if (nullptr == ftSize) { |
| 904 SkDEBUGF(("Could not create FT_Size.\n")); | 904 SkDEBUGF(("Could not create FT_Size.\n")); |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", | 1806 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", |
| 1807 name.c_str(), | 1807 name.c_str(), |
| 1808 (skTag >> 24) & 0xFF, | 1808 (skTag >> 24) & 0xFF, |
| 1809 (skTag >> 16) & 0xFF, | 1809 (skTag >> 16) & 0xFF, |
| 1810 (skTag >> 8) & 0xFF, | 1810 (skTag >> 8) & 0xFF, |
| 1811 (skTag) & 0xFF)); | 1811 (skTag) & 0xFF)); |
| 1812 } | 1812 } |
| 1813 } | 1813 } |
| 1814 ) | 1814 ) |
| 1815 } | 1815 } |
| OLD | NEW |