Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1046)

Side by Side Diff: src/ports/SkFontHost_FreeType.cpp

Issue 434623002: Remove ALL font fallback logic from Skia. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix win font host Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontConfigInterface_android.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 SkAutoMutexAcquire ac(gFTMutex); 1108 SkAutoMutexAcquire ac(gFTMutex);
1109 1109
1110 if (this->setupSize()) { 1110 if (this->setupSize()) {
1111 glyph->zeroMetrics(); 1111 glyph->zeroMetrics();
1112 return; 1112 return;
1113 } 1113 }
1114 1114
1115 FT_Error error; 1115 FT_Error error;
1116 FT_Fixed advance; 1116 FT_Fixed advance;
1117 1117
1118 error = FT_Get_Advance( fFace, glyph->getGlyphID(fBaseGlyphCount), 1118 error = FT_Get_Advance( fFace, glyph->getGlyphID(),
1119 fLoadGlyphFlags | FT_ADVANCE_FLAG_FAST_ONLY, 1119 fLoadGlyphFlags | FT_ADVANCE_FLAG_FAST_ONLY,
1120 &advance ); 1120 &advance );
1121 if (0 == error) { 1121 if (0 == error) {
1122 glyph->fRsbDelta = 0; 1122 glyph->fRsbDelta = 0;
1123 glyph->fLsbDelta = 0; 1123 glyph->fLsbDelta = 0;
1124 glyph->fAdvanceX = SkFixedMul(fMatrix22.xx, advance); 1124 glyph->fAdvanceX = SkFixedMul(fMatrix22.xx, advance);
1125 glyph->fAdvanceY = - SkFixedMul(fMatrix22.yx, advance); 1125 glyph->fAdvanceY = - SkFixedMul(fMatrix22.yx, advance);
1126 return; 1126 return;
1127 } 1127 }
1128 } 1128 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1210
1211 glyph->fRsbDelta = 0; 1211 glyph->fRsbDelta = 0;
1212 glyph->fLsbDelta = 0; 1212 glyph->fLsbDelta = 0;
1213 1213
1214 FT_Error err; 1214 FT_Error err;
1215 1215
1216 if (this->setupSize()) { 1216 if (this->setupSize()) {
1217 goto ERROR; 1217 goto ERROR;
1218 } 1218 }
1219 1219
1220 err = FT_Load_Glyph( fFace, glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFl ags ); 1220 err = FT_Load_Glyph( fFace, glyph->getGlyphID(), fLoadGlyphFlags );
1221 if (err != 0) { 1221 if (err != 0) {
1222 #if 0 1222 #if 0
1223 SkDEBUGF(("SkScalerContext_FreeType::generateMetrics(%x): FT_Load_Glyph( glyph:%d flags:%x) returned 0x%x\n", 1223 SkDEBUGF(("SkScalerContext_FreeType::generateMetrics(%x): FT_Load_Glyph( glyph:%d flags:%x) returned 0x%x\n",
1224 fFaceRec->fFontID, glyph->getGlyphID(fBaseGlyphCount), fLoad GlyphFlags, err)); 1224 fFaceRec->fFontID, glyph->getGlyphID(), fLoadGlyphFlags, err ));
1225 #endif 1225 #endif
1226 ERROR: 1226 ERROR:
1227 glyph->zeroMetrics(); 1227 glyph->zeroMetrics();
1228 return; 1228 return;
1229 } 1229 }
1230 emboldenIfNeeded(fFace, fFace->glyph); 1230 emboldenIfNeeded(fFace, fFace->glyph);
1231 1231
1232 switch ( fFace->glyph->format ) { 1232 switch ( fFace->glyph->format ) {
1233 case FT_GLYPH_FORMAT_OUTLINE: 1233 case FT_GLYPH_FORMAT_OUTLINE:
1234 if (0 == fFace->glyph->outline.n_contours) { 1234 if (0 == fFace->glyph->outline.n_contours) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 } 1298 }
1299 1299
1300 if (fFace->glyph->format == FT_GLYPH_FORMAT_BITMAP && fScaleY && fFace->size ->metrics.y_ppem) { 1300 if (fFace->glyph->format == FT_GLYPH_FORMAT_BITMAP && fScaleY && fFace->size ->metrics.y_ppem) {
1301 // NOTE: both dimensions are scaled by y_ppem. this is WAI. 1301 // NOTE: both dimensions are scaled by y_ppem. this is WAI.
1302 scaleGlyphMetrics(*glyph, SkScalarDiv(SkFixedToScalar(fScaleY), 1302 scaleGlyphMetrics(*glyph, SkScalarDiv(SkFixedToScalar(fScaleY),
1303 SkIntToScalar(fFace->size->metrics .y_ppem))); 1303 SkIntToScalar(fFace->size->metrics .y_ppem)));
1304 } 1304 }
1305 1305
1306 #ifdef ENABLE_GLYPH_SPEW 1306 #ifdef ENABLE_GLYPH_SPEW
1307 SkDEBUGF(("FT_Set_Char_Size(this:%p sx:%x sy:%x ", this, fScaleX, fScaleY)); 1307 SkDEBUGF(("FT_Set_Char_Size(this:%p sx:%x sy:%x ", this, fScaleX, fScaleY));
1308 SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->getGlyphID(fBaseGlyp hCount), fLoadGlyphFlags, glyph->fWidth)); 1308 SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->getGlyphID(), fLoadG lyphFlags, glyph->fWidth));
1309 #endif 1309 #endif
1310 } 1310 }
1311 1311
1312 1312
1313 void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { 1313 void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) {
1314 SkAutoMutexAcquire ac(gFTMutex); 1314 SkAutoMutexAcquire ac(gFTMutex);
1315 1315
1316 FT_Error err; 1316 FT_Error err;
1317 1317
1318 if (this->setupSize()) { 1318 if (this->setupSize()) {
1319 goto ERROR; 1319 goto ERROR;
1320 } 1320 }
1321 1321
1322 err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), fLoadGlyphFla gs); 1322 err = FT_Load_Glyph( fFace, glyph.getGlyphID(), fLoadGlyphFlags);
1323 if (err != 0) { 1323 if (err != 0) {
1324 SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph: %d width:%d height:%d rb:%d flags:%d) returned 0x%x\n", 1324 SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph: %d width:%d height:%d rb:%d flags:%d) returned 0x%x\n",
1325 glyph.getGlyphID(fBaseGlyphCount), glyph.fWidth, glyph.fHeig ht, glyph.rowBytes(), fLoadGlyphFlags, err)); 1325 glyph.getGlyphID(), glyph.fWidth, glyph.fHeight, glyph.rowBy tes(), fLoadGlyphFlags, err));
1326 ERROR: 1326 ERROR:
1327 memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight); 1327 memset(glyph.fImage, 0, glyph.rowBytes() * glyph.fHeight);
1328 return; 1328 return;
1329 } 1329 }
1330 1330
1331 emboldenIfNeeded(fFace, fFace->glyph); 1331 emboldenIfNeeded(fFace, fFace->glyph);
1332 generateGlyphImage(fFace, glyph); 1332 generateGlyphImage(fFace, glyph);
1333 } 1333 }
1334 1334
1335 1335
1336 void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, 1336 void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph,
1337 SkPath* path) { 1337 SkPath* path) {
1338 SkAutoMutexAcquire ac(gFTMutex); 1338 SkAutoMutexAcquire ac(gFTMutex);
1339 1339
1340 SkASSERT(&glyph && path); 1340 SkASSERT(&glyph && path);
1341 1341
1342 if (this->setupSize()) { 1342 if (this->setupSize()) {
1343 path->reset(); 1343 path->reset();
1344 return; 1344 return;
1345 } 1345 }
1346 1346
1347 uint32_t flags = fLoadGlyphFlags; 1347 uint32_t flags = fLoadGlyphFlags;
1348 flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline 1348 flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline
1349 flags &= ~FT_LOAD_RENDER; // don't scan convert (we just want the outline) 1349 flags &= ~FT_LOAD_RENDER; // don't scan convert (we just want the outline)
1350 1350
1351 FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), flag s); 1351 FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(), flags);
1352 1352
1353 if (err != 0) { 1353 if (err != 0) {
1354 SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:% d flags:%d) returned 0x%x\n", 1354 SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:% d flags:%d) returned 0x%x\n",
1355 glyph.getGlyphID(fBaseGlyphCount), flags, err)); 1355 glyph.getGlyphID(), flags, err));
1356 path->reset(); 1356 path->reset();
1357 return; 1357 return;
1358 } 1358 }
1359 emboldenIfNeeded(fFace, fFace->glyph); 1359 emboldenIfNeeded(fFace, fFace->glyph);
1360 1360
1361 generateGlyphPath(fFace, path); 1361 generateGlyphPath(fFace, path);
1362 1362
1363 // The path's origin from FreeType is always the horizontal layout origin. 1363 // The path's origin from FreeType is always the horizontal layout origin.
1364 // Offset the path so that it is relative to the vertical origin if needed. 1364 // Offset the path so that it is relative to the vertical origin if needed.
1365 if (fRec.fFlags & SkScalerContext::kVertical_Flag) { 1365 if (fRec.fFlags & SkScalerContext::kVertical_Flag) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 *style = (SkTypeface::Style) tempStyle; 1720 *style = (SkTypeface::Style) tempStyle;
1721 } 1721 }
1722 if (isFixedPitch) { 1722 if (isFixedPitch) {
1723 *isFixedPitch = FT_IS_FIXED_WIDTH(face); 1723 *isFixedPitch = FT_IS_FIXED_WIDTH(face);
1724 } 1724 }
1725 1725
1726 FT_Done_Face(face); 1726 FT_Done_Face(face);
1727 FT_Done_FreeType(library); 1727 FT_Done_FreeType(library);
1728 return true; 1728 return true;
1729 } 1729 }
OLDNEW
« no previous file with comments | « src/ports/SkFontConfigInterface_android.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698