| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006-2012 The Android Open Source Project | 2 * Copyright 2006-2012 The Android Open Source Project |
| 3 * Copyright 2012 Mozilla Foundation | 3 * Copyright 2012 Mozilla Foundation |
| 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
ph& glyph) { | 337 void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face, const SkGly
ph& glyph) { |
| 338 const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Fla
g); | 338 const bool doBGR = SkToBool(fRec.fFlags & SkScalerContext::kLCD_BGROrder_Fla
g); |
| 339 const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Fl
ag); | 339 const bool doVert = SkToBool(fRec.fFlags & SkScalerContext::kLCD_Vertical_Fl
ag); |
| 340 | 340 |
| 341 switch ( face->glyph->format ) { | 341 switch ( face->glyph->format ) { |
| 342 case FT_GLYPH_FORMAT_OUTLINE: { | 342 case FT_GLYPH_FORMAT_OUTLINE: { |
| 343 FT_Outline* outline = &face->glyph->outline; | 343 FT_Outline* outline = &face->glyph->outline; |
| 344 FT_BBox bbox; | 344 FT_BBox bbox; |
| 345 FT_Bitmap target; | 345 FT_Bitmap target; |
| 346 | 346 |
| 347 if (fRec.fFlags & SkScalerContext::kEmbolden_Flag && | |
| 348 !(face->style_flags & FT_STYLE_FLAG_BOLD)) { | |
| 349 emboldenOutline(face, outline); | |
| 350 } | |
| 351 | |
| 352 int dx = 0, dy = 0; | 347 int dx = 0, dy = 0; |
| 353 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { | 348 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { |
| 354 dx = SkFixedToFDot6(glyph.getSubXFixed()); | 349 dx = SkFixedToFDot6(glyph.getSubXFixed()); |
| 355 dy = SkFixedToFDot6(glyph.getSubYFixed()); | 350 dy = SkFixedToFDot6(glyph.getSubYFixed()); |
| 356 // negate dy since freetype-y-goes-up and skia-y-goes-down | 351 // negate dy since freetype-y-goes-up and skia-y-goes-down |
| 357 dy = -dy; | 352 dy = -dy; |
| 358 } | 353 } |
| 359 FT_Outline_Get_CBox(outline, &bbox); | 354 FT_Outline_Get_CBox(outline, &bbox); |
| 360 /* | 355 /* |
| 361 what we really want to do for subpixel is | 356 what we really want to do for subpixel is |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 SkPath* path = (SkPath*)ctx; | 535 SkPath* path = (SkPath*)ctx; |
| 541 path->cubicTo(SkFDot6ToScalar(pt0->x), -SkFDot6ToScalar(pt0->y), | 536 path->cubicTo(SkFDot6ToScalar(pt0->x), -SkFDot6ToScalar(pt0->y), |
| 542 SkFDot6ToScalar(pt1->x), -SkFDot6ToScalar(pt1->y), | 537 SkFDot6ToScalar(pt1->x), -SkFDot6ToScalar(pt1->y), |
| 543 SkFDot6ToScalar(pt2->x), -SkFDot6ToScalar(pt2->y)); | 538 SkFDot6ToScalar(pt2->x), -SkFDot6ToScalar(pt2->y)); |
| 544 return 0; | 539 return 0; |
| 545 } | 540 } |
| 546 | 541 |
| 547 void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face, | 542 void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face, |
| 548 SkPath* path) | 543 SkPath* path) |
| 549 { | 544 { |
| 550 if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) { | |
| 551 emboldenOutline(face, &face->glyph->outline); | |
| 552 } | |
| 553 | |
| 554 FT_Outline_Funcs funcs; | 545 FT_Outline_Funcs funcs; |
| 555 | 546 |
| 556 funcs.move_to = move_proc; | 547 funcs.move_to = move_proc; |
| 557 funcs.line_to = line_proc; | 548 funcs.line_to = line_proc; |
| 558 funcs.conic_to = quad_proc; | 549 funcs.conic_to = quad_proc; |
| 559 funcs.cubic_to = cubic_proc; | 550 funcs.cubic_to = cubic_proc; |
| 560 funcs.shift = 0; | 551 funcs.shift = 0; |
| 561 funcs.delta = 0; | 552 funcs.delta = 0; |
| 562 | 553 |
| 563 FT_Error err = FT_Outline_Decompose(&face->glyph->outline, &funcs, path); | 554 FT_Error err = FT_Outline_Decompose(&face->glyph->outline, &funcs, path); |
| 564 | 555 |
| 565 if (err != 0) { | 556 if (err != 0) { |
| 566 path->reset(); | 557 path->reset(); |
| 567 return; | 558 return; |
| 568 } | 559 } |
| 569 | 560 |
| 570 path->close(); | 561 path->close(); |
| 571 } | 562 } |
| 572 | |
| 573 void SkScalerContext_FreeType_Base::emboldenOutline(FT_Face face, FT_Outline* ou
tline) | |
| 574 { | |
| 575 FT_Pos strength; | |
| 576 strength = FT_MulFix(face->units_per_EM, face->size->metrics.y_scale) | |
| 577 / 24; | |
| 578 FT_Outline_Embolden(outline, strength); | |
| 579 } | |
| OLD | NEW |