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