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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (!rec->fFace->charmap) { | 354 if (!rec->fFace->charmap) { |
355 FT_Select_Charmap(rec->fFace, FT_ENCODING_MS_SYMBOL); | 355 FT_Select_Charmap(rec->fFace, FT_ENCODING_MS_SYMBOL); |
356 } | 356 } |
357 | 357 |
358 rec->fNext = gFaceRecHead; | 358 rec->fNext = gFaceRecHead; |
359 gFaceRecHead = rec; | 359 gFaceRecHead = rec; |
360 return rec->fFace; | 360 return rec->fFace; |
361 } | 361 } |
362 | 362 |
363 // Caller must lock gFTMutex before calling this function. | 363 // Caller must lock gFTMutex before calling this function. |
364 static void unref_ft_face(FT_Face face) { | 364 extern void unref_ft_face(FT_Face face); |
| 365 void unref_ft_face(FT_Face face) { |
365 gFTMutex.assertHeld(); | 366 gFTMutex.assertHeld(); |
366 | 367 |
367 SkFaceRec* rec = gFaceRecHead; | 368 SkFaceRec* rec = gFaceRecHead; |
368 SkFaceRec* prev = nullptr; | 369 SkFaceRec* prev = nullptr; |
369 while (rec) { | 370 while (rec) { |
370 SkFaceRec* next = rec->fNext; | 371 SkFaceRec* next = rec->fNext; |
371 if (rec->fFace == face) { | 372 if (rec->fFace == face) { |
372 if (--rec->fRefCnt == 0) { | 373 if (--rec->fRefCnt == 0) { |
373 if (prev) { | 374 if (prev) { |
374 prev->fNext = next; | 375 prev->fNext = next; |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 } | 1278 } |
1278 | 1279 |
1279 void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics
) { | 1280 void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics
) { |
1280 if (nullptr == metrics) { | 1281 if (nullptr == metrics) { |
1281 return; | 1282 return; |
1282 } | 1283 } |
1283 | 1284 |
1284 SkAutoMutexAcquire ac(gFTMutex); | 1285 SkAutoMutexAcquire ac(gFTMutex); |
1285 | 1286 |
1286 if (this->setupSize()) { | 1287 if (this->setupSize()) { |
1287 ERROR: | |
1288 sk_bzero(metrics, sizeof(*metrics)); | 1288 sk_bzero(metrics, sizeof(*metrics)); |
1289 return; | 1289 return; |
1290 } | 1290 } |
1291 | 1291 |
1292 FT_Face face = fFace; | 1292 FT_Face face = fFace; |
1293 SkScalar scaleX = fScale.x(); | 1293 SkScalar scaleX = fScale.x(); |
1294 SkScalar scaleY = fScale.y(); | 1294 SkScalar scaleY = fScale.y(); |
1295 SkScalar mxy = fMatrix22Scalar.getSkewX() * scaleY; | 1295 SkScalar mxy = fMatrix22Scalar.getSkewX() * scaleY; |
1296 SkScalar myy = fMatrix22Scalar.getScaleY() * scaleY; | 1296 SkScalar myy = fMatrix22Scalar.getScaleY() * scaleY; |
1297 | 1297 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 xmin = 0.0f; | 1369 xmin = 0.0f; |
1370 xmax = SkIntToScalar(face->available_sizes[fStrikeIndex].width) / xppem; | 1370 xmax = SkIntToScalar(face->available_sizes[fStrikeIndex].width) / xppem; |
1371 ymin = descent + leading; | 1371 ymin = descent + leading; |
1372 ymax = ascent - descent; | 1372 ymax = ascent - descent; |
1373 underlineThickness = 0; | 1373 underlineThickness = 0; |
1374 underlinePosition = 0; | 1374 underlinePosition = 0; |
1375 | 1375 |
1376 metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlineThinknessIsValid_Fla
g; | 1376 metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlineThinknessIsValid_Fla
g; |
1377 metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag
; | 1377 metrics->fFlags &= ~SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag
; |
1378 } else { | 1378 } else { |
1379 goto ERROR; | 1379 sk_bzero(metrics, sizeof(*metrics)); |
| 1380 return; |
1380 } | 1381 } |
1381 | 1382 |
1382 // synthesize elements that were not provided by the os/2 table or format-sp
ecific metrics | 1383 // synthesize elements that were not provided by the os/2 table or format-sp
ecific metrics |
1383 if (!x_height) { | 1384 if (!x_height) { |
1384 x_height = -ascent; | 1385 x_height = -ascent; |
1385 } | 1386 } |
1386 if (!avgCharWidth) { | 1387 if (!avgCharWidth) { |
1387 avgCharWidth = xmax - xmin; | 1388 avgCharWidth = xmax - xmin; |
1388 } | 1389 } |
1389 if (!cap_height) { | 1390 if (!cap_height) { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", | 1807 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n", |
1807 name.c_str(), | 1808 name.c_str(), |
1808 (skTag >> 24) & 0xFF, | 1809 (skTag >> 24) & 0xFF, |
1809 (skTag >> 16) & 0xFF, | 1810 (skTag >> 16) & 0xFF, |
1810 (skTag >> 8) & 0xFF, | 1811 (skTag >> 8) & 0xFF, |
1811 (skTag) & 0xFF)); | 1812 (skTag) & 0xFF)); |
1812 } | 1813 } |
1813 } | 1814 } |
1814 ) | 1815 ) |
1815 } | 1816 } |
OLD | NEW |