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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 fFace, fScaleX, fScaleY, err)); | 1015 fFace, fScaleX, fScaleY, err)); |
1016 fFace = NULL; | 1016 fFace = NULL; |
1017 return; | 1017 return; |
1018 } | 1018 } |
1019 FT_Set_Transform(fFace, &fMatrix22, NULL); | 1019 FT_Set_Transform(fFace, &fMatrix22, NULL); |
1020 } else if (FT_HAS_FIXED_SIZES(fFace)) { | 1020 } else if (FT_HAS_FIXED_SIZES(fFace)) { |
1021 fStrikeIndex = chooseBitmapStrike(fFace, fScaleY); | 1021 fStrikeIndex = chooseBitmapStrike(fFace, fScaleY); |
1022 if (fStrikeIndex == -1) { | 1022 if (fStrikeIndex == -1) { |
1023 SkDEBUGF(("no glyphs for font \"%s\" size %f?\n", | 1023 SkDEBUGF(("no glyphs for font \"%s\" size %f?\n", |
1024 fFace->family_name, SkFixedToScalar(fScaleY))) ; | 1024 fFace->family_name, SkFixedToScalar(fScaleY))) ; |
1025 updateImageFromPath(true); | |
reed1
2014/09/05 13:29:42
nit: prefix method calls with this->
h.joshi
2014/09/05 14:06:31
Done.
| |
1025 } else { | 1026 } else { |
1026 // FreeType does no provide linear metrics for bitmap fonts. | 1027 // FreeType does no provide linear metrics for bitmap fonts. |
1027 linearMetrics = false; | 1028 linearMetrics = false; |
1028 | 1029 |
1029 // FreeType documentation says: | 1030 // FreeType documentation says: |
1030 // FT_LOAD_NO_BITMAP -- Ignore bitmap strikes when loading. | 1031 // FT_LOAD_NO_BITMAP -- Ignore bitmap strikes when loading. |
1031 // Bitmap-only fonts ignore this flag. | 1032 // Bitmap-only fonts ignore this flag. |
1032 // | 1033 // |
1033 // However, in FreeType 2.5.1 color bitmap only fonts do not ignore this flag. | 1034 // However, in FreeType 2.5.1 color bitmap only fonts do not ignore this flag. |
1034 // Force this flag off for bitmap only fonts. | 1035 // Force this flag off for bitmap only fonts. |
1035 fLoadGlyphFlags &= ~FT_LOAD_NO_BITMAP; | 1036 fLoadGlyphFlags &= ~FT_LOAD_NO_BITMAP; |
1037 updateImageFromPath(false); | |
1036 } | 1038 } |
1037 } else { | 1039 } else { |
1038 SkDEBUGF(("unknown kind of font \"%s\" size %f?\n", | 1040 SkDEBUGF(("unknown kind of font \"%s\" size %f?\n", |
1039 fFace->family_name, SkFixedToScalar(fScaleY))) ; | 1041 fFace->family_name, SkFixedToScalar(fScaleY))) ; |
1040 } | 1042 } |
1041 | 1043 |
1042 fDoLinearMetrics = linearMetrics; | 1044 fDoLinearMetrics = linearMetrics; |
1043 } | 1045 } |
1044 | 1046 |
1045 SkScalerContext_FreeType::~SkScalerContext_FreeType() { | 1047 SkScalerContext_FreeType::~SkScalerContext_FreeType() { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1253 if (fRec.fFlags & SkScalerContext::kVertical_Flag) { | 1255 if (fRec.fFlags & SkScalerContext::kVertical_Flag) { |
1254 FT_Vector vector; | 1256 FT_Vector vector; |
1255 vector.x = fFace->glyph->metrics.vertBearingX - fFace->glyph->metric s.horiBearingX; | 1257 vector.x = fFace->glyph->metrics.vertBearingX - fFace->glyph->metric s.horiBearingX; |
1256 vector.y = -fFace->glyph->metrics.vertBearingY - fFace->glyph->metri cs.horiBearingY; | 1258 vector.y = -fFace->glyph->metrics.vertBearingY - fFace->glyph->metri cs.horiBearingY; |
1257 FT_Vector_Transform(&vector, &fMatrix22); | 1259 FT_Vector_Transform(&vector, &fMatrix22); |
1258 fFace->glyph->bitmap_left += SkFDot6Floor(vector.x); | 1260 fFace->glyph->bitmap_left += SkFDot6Floor(vector.x); |
1259 fFace->glyph->bitmap_top += SkFDot6Floor(vector.y); | 1261 fFace->glyph->bitmap_top += SkFDot6Floor(vector.y); |
1260 } | 1262 } |
1261 | 1263 |
1262 if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) { | 1264 if (fFace->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) { |
1265 updateImageFromPath(false); | |
1263 glyph->fMaskFormat = SkMask::kARGB32_Format; | 1266 glyph->fMaskFormat = SkMask::kARGB32_Format; |
1264 } | 1267 } else |
1268 updateImageFromPath(true); | |
1265 | 1269 |
1266 glyph->fWidth = SkToU16(fFace->glyph->bitmap.width); | 1270 glyph->fWidth = SkToU16(fFace->glyph->bitmap.width); |
1267 glyph->fHeight = SkToU16(fFace->glyph->bitmap.rows); | 1271 glyph->fHeight = SkToU16(fFace->glyph->bitmap.rows); |
1268 glyph->fTop = -SkToS16(fFace->glyph->bitmap_top); | 1272 glyph->fTop = -SkToS16(fFace->glyph->bitmap_top); |
1269 glyph->fLeft = SkToS16(fFace->glyph->bitmap_left); | 1273 glyph->fLeft = SkToS16(fFace->glyph->bitmap_left); |
1270 break; | 1274 break; |
1271 | 1275 |
1272 default: | 1276 default: |
1273 SkDEBUGFAIL("unknown glyph format"); | 1277 SkDEBUGFAIL("unknown glyph format"); |
1274 goto ERROR; | 1278 goto ERROR; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1720 *style = (SkTypeface::Style) tempStyle; | 1724 *style = (SkTypeface::Style) tempStyle; |
1721 } | 1725 } |
1722 if (isFixedPitch) { | 1726 if (isFixedPitch) { |
1723 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1727 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
1724 } | 1728 } |
1725 | 1729 |
1726 FT_Done_Face(face); | 1730 FT_Done_Face(face); |
1727 FT_Done_FreeType(library); | 1731 FT_Done_FreeType(library); |
1728 return true; | 1732 return true; |
1729 } | 1733 } |
OLD | NEW |