OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |