Chromium Code Reviews| 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 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1490 my->fXMax = xmax; | 1490 my->fXMax = xmax; |
| 1491 my->fXHeight = x_height; | 1491 my->fXHeight = x_height; |
| 1492 my->fCapHeight = cap_height; | 1492 my->fCapHeight = cap_height; |
| 1493 my->fUnderlineThickness = underlineThickness; | 1493 my->fUnderlineThickness = underlineThickness; |
| 1494 my->fUnderlinePosition = underlinePosition; | 1494 my->fUnderlinePosition = underlinePosition; |
| 1495 } | 1495 } |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph ) | 1498 void SkScalerContext_FreeType::emboldenIfNeeded(FT_Face face, FT_GlyphSlot glyph ) |
| 1499 { | 1499 { |
| 1500 if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) { | 1500 // check to see if the embolden bit is set |
| 1501 switch ( glyph->format ) { | 1501 if (0 == (fRec.fFlags & SkScalerContext::kEmbolden_Flag)) { |
|
bungeman-skia
2014/04/01 18:13:01
nit: you could also use SkToBool(...) here.
| |
| 1502 case FT_GLYPH_FORMAT_OUTLINE: | 1502 return; |
| 1503 FT_Pos strength; | 1503 } |
| 1504 strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_s cale) / 24; | 1504 |
| 1505 FT_Outline_Embolden(&glyph->outline, strength); | 1505 #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) |
| 1506 break; | 1506 // Android doesn't want to embolden a font that is already bold. |
| 1507 case FT_GLYPH_FORMAT_BITMAP: | 1507 if ((fFace->style_flags & FT_STYLE_FLAG_BOLD)) { |
| 1508 FT_GlyphSlot_Own_Bitmap(glyph); | 1508 return; |
| 1509 FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmbold enStrength, 0); | 1509 } |
| 1510 break; | 1510 #endif |
| 1511 default: | 1511 |
| 1512 SkDEBUGFAIL("unknown glyph format"); | 1512 switch (glyph->format) { |
| 1513 } | 1513 case FT_GLYPH_FORMAT_OUTLINE: |
| 1514 FT_Pos strength; | |
| 1515 strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale ) / 24; | |
| 1516 FT_Outline_Embolden(&glyph->outline, strength); | |
| 1517 break; | |
| 1518 case FT_GLYPH_FORMAT_BITMAP: | |
| 1519 FT_GlyphSlot_Own_Bitmap(glyph); | |
| 1520 FT_Bitmap_Embolden(glyph->library, &glyph->bitmap, kBitmapEmboldenSt rength, 0); | |
| 1521 break; | |
| 1522 default: | |
| 1523 SkDEBUGFAIL("unknown glyph format"); | |
| 1514 } | 1524 } |
| 1515 } | 1525 } |
| 1516 | 1526 |
| 1517 /////////////////////////////////////////////////////////////////////////////// | 1527 /////////////////////////////////////////////////////////////////////////////// |
| 1518 | 1528 |
| 1519 #include "SkUtils.h" | 1529 #include "SkUtils.h" |
| 1520 | 1530 |
| 1521 static SkUnichar next_utf8(const void** chars) { | 1531 static SkUnichar next_utf8(const void** chars) { |
| 1522 return SkUTF8_NextUnichar((const char**)chars); | 1532 return SkUTF8_NextUnichar((const char**)chars); |
| 1523 } | 1533 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1710 *style = (SkTypeface::Style) tempStyle; | 1720 *style = (SkTypeface::Style) tempStyle; |
| 1711 } | 1721 } |
| 1712 if (isFixedPitch) { | 1722 if (isFixedPitch) { |
| 1713 *isFixedPitch = FT_IS_FIXED_WIDTH(face); | 1723 *isFixedPitch = FT_IS_FIXED_WIDTH(face); |
| 1714 } | 1724 } |
| 1715 | 1725 |
| 1716 FT_Done_Face(face); | 1726 FT_Done_Face(face); |
| 1717 FT_Done_FreeType(library); | 1727 FT_Done_FreeType(library); |
| 1718 return true; | 1728 return true; |
| 1719 } | 1729 } |
| OLD | NEW |