Chromium Code Reviews| 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" |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 if (fFace != nullptr) { | 941 if (fFace != nullptr) { |
| 942 unref_ft_face(fFace); | 942 unref_ft_face(fFace); |
| 943 } | 943 } |
| 944 | 944 |
| 945 unref_ft_library(); | 945 unref_ft_library(); |
| 946 } | 946 } |
| 947 | 947 |
| 948 /* We call this before each use of the fFace, since we may be sharing | 948 /* We call this before each use of the fFace, since we may be sharing |
| 949 this face with other context (at different sizes). | 949 this face with other context (at different sizes). |
| 950 */ | 950 */ |
| 951 FT_Error SkScalerContext_FreeType::setupSize() { | 951 FT_Error SkScalerContext_FreeType::setupSize() { |
|
herb_g
2015/11/03 19:09:28
Maybe change the name to indicate that this routin
| |
| 952 gFTMutex.assertHeld(); | |
| 952 FT_Error err = FT_Activate_Size(fFTSize); | 953 FT_Error err = FT_Activate_Size(fFTSize); |
| 953 if (err != 0) { | 954 if (err != 0) { |
| 954 SkDEBUGF(("SkScalerContext_FreeType::FT_Activate_Size(%s %s, 0x%x, 0x%x) returned 0x%x\n", | 955 SkDEBUGF(("SkScalerContext_FreeType::FT_Activate_Size(%s %s, 0x%x, 0x%x) returned 0x%x\n", |
| 955 fFace->family_name, fFace->style_name, fScaleX, fScaleY, err)) ; | 956 fFace->family_name, fFace->style_name, fScaleX, fScaleY, err)) ; |
| 956 fFTSize = nullptr; | 957 fFTSize = nullptr; |
| 957 return err; | 958 return err; |
| 958 } | 959 } |
| 959 | 960 |
| 960 // seems we need to reset this every time (not sure why, but without it | 961 // seems we need to reset this every time (not sure why, but without it |
| 961 // I get random italics from some other fFTSize) | 962 // I get random italics from some other fFTSize) |
| 962 FT_Set_Transform(fFace, &fMatrix22, nullptr); | 963 FT_Set_Transform(fFace, &fMatrix22, nullptr); |
| 963 return 0; | 964 return 0; |
| 964 } | 965 } |
| 965 | 966 |
| 966 unsigned SkScalerContext_FreeType::generateGlyphCount() { | 967 unsigned SkScalerContext_FreeType::generateGlyphCount() { |
| 967 return fFace->num_glyphs; | 968 return fFace->num_glyphs; |
| 968 } | 969 } |
| 969 | 970 |
| 970 uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni) { | 971 uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni) { |
| 972 SkAutoMutexAcquire ac(gFTMutex); | |
| 971 return SkToU16(FT_Get_Char_Index( fFace, uni )); | 973 return SkToU16(FT_Get_Char_Index( fFace, uni )); |
| 972 } | 974 } |
| 973 | 975 |
| 974 SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) { | 976 SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) { |
| 977 SkAutoMutexAcquire ac(gFTMutex); | |
| 975 // iterate through each cmap entry, looking for matching glyph indices | 978 // iterate through each cmap entry, looking for matching glyph indices |
| 976 FT_UInt glyphIndex; | 979 FT_UInt glyphIndex; |
| 977 SkUnichar charCode = FT_Get_First_Char( fFace, &glyphIndex ); | 980 SkUnichar charCode = FT_Get_First_Char( fFace, &glyphIndex ); |
| 978 | 981 |
| 979 while (glyphIndex != 0) { | 982 while (glyphIndex != 0) { |
| 980 if (glyphIndex == glyph) { | 983 if (glyphIndex == glyph) { |
| 981 return charCode; | 984 return charCode; |
| 982 } | 985 } |
| 983 charCode = FT_Get_Next_Char( fFace, charCode, &glyphIndex ); | 986 charCode = FT_Get_Next_Char( fFace, charCode, &glyphIndex ); |
| 984 } | 987 } |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1731 (*axes)[i].fTag = ftAxis.tag; | 1734 (*axes)[i].fTag = ftAxis.tag; |
| 1732 (*axes)[i].fMinimum = ftAxis.minimum; | 1735 (*axes)[i].fMinimum = ftAxis.minimum; |
| 1733 (*axes)[i].fDefault = ftAxis.def; | 1736 (*axes)[i].fDefault = ftAxis.def; |
| 1734 (*axes)[i].fMaximum = ftAxis.maximum; | 1737 (*axes)[i].fMaximum = ftAxis.maximum; |
| 1735 } | 1738 } |
| 1736 } | 1739 } |
| 1737 | 1740 |
| 1738 FT_Done_Face(face); | 1741 FT_Done_Face(face); |
| 1739 return true; | 1742 return true; |
| 1740 } | 1743 } |
| OLD | NEW |