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 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 metrics->fLeading = leading * scale; | 1396 metrics->fLeading = leading * scale; |
1397 metrics->fAvgCharWidth = avgCharWidth * scale; | 1397 metrics->fAvgCharWidth = avgCharWidth * scale; |
1398 metrics->fXMin = xmin * scale; | 1398 metrics->fXMin = xmin * scale; |
1399 metrics->fXMax = xmax * scale; | 1399 metrics->fXMax = xmax * scale; |
1400 metrics->fXHeight = x_height; | 1400 metrics->fXHeight = x_height; |
1401 metrics->fCapHeight = cap_height; | 1401 metrics->fCapHeight = cap_height; |
1402 metrics->fUnderlineThickness = underlineThickness * scale; | 1402 metrics->fUnderlineThickness = underlineThickness * scale; |
1403 metrics->fUnderlinePosition = underlinePosition * scale; | 1403 metrics->fUnderlinePosition = underlinePosition * scale; |
1404 } | 1404 } |
1405 | 1405 |
1406 /////////////////////////////////////////////////////////////////////////////// | |
1407 | |
1408 // hand-tuned value to reduce outline embolden strength | |
1409 #ifndef SK_OUTLINE_EMBOLDEN_DIVISOR | |
1410 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK | |
1411 #define SK_OUTLINE_EMBOLDEN_DIVISOR 34 | |
bungeman-skia
2015/01/09 16:07:38
It would be nice if Android specified this in thei
| |
1412 #else | |
1413 #define SK_OUTLINE_EMBOLDEN_DIVISOR 24 | |
1414 #endif | |
1415 #endif | |
1416 | |
1417 /////////////////////////////////////////////////////////////////////////////// | |
1418 | |
1406 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph ) | 1419 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph ) |
1407 { | 1420 { |
1408 // check to see if the embolden bit is set | 1421 // check to see if the embolden bit is set |
1409 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { | 1422 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { |
1410 return; | 1423 return; |
1411 } | 1424 } |
1412 | 1425 |
1413 switch (glyph->format) { | 1426 switch (glyph->format) { |
1414 case FT_GLYPH_FORMAT_OUTLINE: | 1427 case FT_GLYPH_FORMAT_OUTLINE: |
1415 FT_Pos strength; | 1428 FT_Pos strength; |
1416 strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale ) / 24; | 1429 strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale ) |
1430 / SK_OUTLINE_EMBOLDEN_DIVISOR; | |
1417 FT_Outline_Embolden(&glyph->outline, strength); | 1431 FT_Outline_Embolden(&glyph->outline, strength); |
1418 break; | 1432 break; |
1419 case FT_GLYPH_FORMAT_BITMAP: | 1433 case FT_GLYPH_FORMAT_BITMAP: |
1420 FT_GlyphSlot_Own_Bitmap(glyph); | 1434 FT_GlyphSlot_Own_Bitmap(glyph); |
1421 FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenSt rength, 0); | 1435 FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenSt rength, 0); |
1422 break; | 1436 break; |
1423 default: | 1437 default: |
1424 SkDEBUGFAIL("unknown glyph format"); | 1438 SkDEBUGFAIL("unknown glyph format"); |
1425 } | 1439 } |
1426 } | 1440 } |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1703 if (style) { | 1717 if (style) { |
1704 *style = SkFontStyle(weight, width, slant); | 1718 *style = SkFontStyle(weight, width, slant); |
1705 } | 1719 } |
1706 if (isFixedPitch) { | 1720 if (isFixedPitch) { |
1707 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1721 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
1708 } | 1722 } |
1709 | 1723 |
1710 FT_Done_Face(face); | 1724 FT_Done_Face(face); |
1711 return true; | 1725 return true; |
1712 } | 1726 } |
OLD | NEW |