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

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

Issue 119943002: Revert of refactor emboldenGlyph (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | no next file » | 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 * 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
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
347 int dx = 0, dy = 0; 352 int dx = 0, dy = 0;
348 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) { 353 if (fRec.fFlags & SkScalerContext::kSubpixelPositioning_Flag) {
349 dx = SkFixedToFDot6(glyph.getSubXFixed()); 354 dx = SkFixedToFDot6(glyph.getSubXFixed());
350 dy = SkFixedToFDot6(glyph.getSubYFixed()); 355 dy = SkFixedToFDot6(glyph.getSubYFixed());
351 // negate dy since freetype-y-goes-up and skia-y-goes-down 356 // negate dy since freetype-y-goes-up and skia-y-goes-down
352 dy = -dy; 357 dy = -dy;
353 } 358 }
354 FT_Outline_Get_CBox(outline, &bbox); 359 FT_Outline_Get_CBox(outline, &bbox);
355 /* 360 /*
356 what we really want to do for subpixel is 361 what we really want to do for subpixel is
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 SkPath* path = (SkPath*)ctx; 540 SkPath* path = (SkPath*)ctx;
536 path->cubicTo(SkFDot6ToScalar(pt0->x), -SkFDot6ToScalar(pt0->y), 541 path->cubicTo(SkFDot6ToScalar(pt0->x), -SkFDot6ToScalar(pt0->y),
537 SkFDot6ToScalar(pt1->x), -SkFDot6ToScalar(pt1->y), 542 SkFDot6ToScalar(pt1->x), -SkFDot6ToScalar(pt1->y),
538 SkFDot6ToScalar(pt2->x), -SkFDot6ToScalar(pt2->y)); 543 SkFDot6ToScalar(pt2->x), -SkFDot6ToScalar(pt2->y));
539 return 0; 544 return 0;
540 } 545 }
541 546
542 void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face, 547 void SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face,
543 SkPath* path) 548 SkPath* path)
544 { 549 {
550 if (fRec.fFlags & SkScalerContext::kEmbolden_Flag) {
551 emboldenOutline(face, &face->glyph->outline);
552 }
553
545 FT_Outline_Funcs funcs; 554 FT_Outline_Funcs funcs;
546 555
547 funcs.move_to = move_proc; 556 funcs.move_to = move_proc;
548 funcs.line_to = line_proc; 557 funcs.line_to = line_proc;
549 funcs.conic_to = quad_proc; 558 funcs.conic_to = quad_proc;
550 funcs.cubic_to = cubic_proc; 559 funcs.cubic_to = cubic_proc;
551 funcs.shift = 0; 560 funcs.shift = 0;
552 funcs.delta = 0; 561 funcs.delta = 0;
553 562
554 FT_Error err = FT_Outline_Decompose(&face->glyph->outline, &funcs, path); 563 FT_Error err = FT_Outline_Decompose(&face->glyph->outline, &funcs, path);
555 564
556 if (err != 0) { 565 if (err != 0) {
557 path->reset(); 566 path->reset();
558 return; 567 return;
559 } 568 }
560 569
561 path->close(); 570 path->close();
562 } 571 }
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 }
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType_common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698