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

Side by Side Diff: src/svg/SkSVGDevice.cpp

Issue 940283002: [SVGDevice] Text whitespace unittest (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: more win warnings Created 5 years, 10 months 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
« no previous file with comments | « include/xml/SkDOM.h ('k') | src/xml/SkDOM.cpp » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 "SkSVGDevice.h" 8 #include "SkSVGDevice.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 void SkSVGDevice::AutoElement::addPathAttributes(const SkPath& path) { 452 void SkSVGDevice::AutoElement::addPathAttributes(const SkPath& path) {
453 SkString pathData; 453 SkString pathData;
454 SkParsePath::ToSVGString(path, &pathData); 454 SkParsePath::ToSVGString(path, &pathData);
455 this->addAttribute("d", pathData); 455 this->addAttribute("d", pathData);
456 } 456 }
457 457
458 void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) { 458 void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
459 this->addAttribute("font-size", paint.getTextSize()); 459 this->addAttribute("font-size", paint.getTextSize());
460 460
461 SkTypeface::Style style = paint.getTypeface()->style();
462 if (style & SkTypeface::kItalic) {
463 this->addAttribute("font-style", "italic");
464 }
465 if (style & SkTypeface::kBold) {
466 this->addAttribute("font-weight", "bold");
467 }
468
469 if (const char* textAlign = svg_text_align(paint.getTextAlign())) { 461 if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
470 this->addAttribute("text-anchor", textAlign); 462 this->addAttribute("text-anchor", textAlign);
471 } 463 }
472 464
473 SkString familyName; 465 SkString familyName;
474 SkTHashSet<SkString, hash_family_string> familySet; 466 SkTHashSet<SkString, hash_family_string> familySet;
475 SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ? 467 SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ?
476 SkRef(paint.getTypeface()) : SkTypeface::RefDefault(style)); 468 SkRef(paint.getTypeface()) : SkTypeface::RefDefault());
469
470 SkASSERT(tface);
471 SkTypeface::Style style = tface->style();
472 if (style & SkTypeface::kItalic) {
473 this->addAttribute("font-style", "italic");
474 }
475 if (style & SkTypeface::kBold) {
476 this->addAttribute("font-weight", "bold");
477 }
478
477 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamil yNameIterator()); 479 SkAutoTUnref<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamil yNameIterator());
478 SkTypeface::LocalizedString familyString; 480 SkTypeface::LocalizedString familyString;
479 while (familyNameIter->next(&familyString)) { 481 while (familyNameIter->next(&familyString)) {
480 if (familySet.contains(familyString.fString)) { 482 if (familySet.contains(familyString.fString)) {
481 continue; 483 continue;
482 } 484 }
483 familySet.add(familyString.fString); 485 familySet.add(familyString.fString);
484 familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString. fString.c_str()); 486 familyName.appendf((familyName.isEmpty() ? "%s" : ", %s"), familyString. fString.c_str());
485 } 487 }
486 488
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 const SkPaint& paint) { 662 const SkPaint& paint) {
661 // todo 663 // todo
662 SkDebugf("unsupported operation: drawVertices()\n"); 664 SkDebugf("unsupported operation: drawVertices()\n");
663 } 665 }
664 666
665 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, 667 void SkSVGDevice::drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
666 const SkPaint&) { 668 const SkPaint&) {
667 // todo 669 // todo
668 SkDebugf("unsupported operation: drawDevice()\n"); 670 SkDebugf("unsupported operation: drawDevice()\n");
669 } 671 }
OLDNEW
« no previous file with comments | « include/xml/SkDOM.h ('k') | src/xml/SkDOM.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698