aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/svg
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-02-20 13:54:40 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-20 13:54:40 -0800
commit7a048690d3cb6b3c1bdef594c3bd4b66f6b400c1 (patch)
tree2bd30bcc04e8db8db2de40e33a2a4435c7bc4072 /src/svg
parentc1b71d6c30041f01675dd54a77adc9c177afdf44 (diff)
[SVGDevice] Text whitespace unittest
Plumb SkDOM as needed to make it suitable for an SkXMLWriter backend. Also fix a potential null typeface issue in SkSVGDevice::AutoElement::addTextAttributes(). R=reed@google.com,mtklein@google.com Review URL: https://codereview.chromium.org/940283002
Diffstat (limited to 'src/svg')
-rw-r--r--src/svg/SkSVGDevice.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index da52facad0..a56a631446 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -523,14 +523,6 @@ void SkSVGDevice::AutoElement::addPathAttributes(const SkPath& path) {
void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
this->addAttribute("font-size", paint.getTextSize());
- SkTypeface::Style style = paint.getTypeface()->style();
- if (style & SkTypeface::kItalic) {
- this->addAttribute("font-style", "italic");
- }
- if (style & SkTypeface::kBold) {
- this->addAttribute("font-weight", "bold");
- }
-
if (const char* textAlign = svg_text_align(paint.getTextAlign())) {
this->addAttribute("text-anchor", textAlign);
}
@@ -538,7 +530,17 @@ void SkSVGDevice::AutoElement::addTextAttributes(const SkPaint& paint) {
SkString familyName;
SkTHashSet<SkString, hash_family_string> familySet;
SkAutoTUnref<const SkTypeface> tface(paint.getTypeface() ?
- SkRef(paint.getTypeface()) : SkTypeface::RefDefault(style));
+ SkRef(paint.getTypeface()) : SkTypeface::RefDefault());
+
+ SkASSERT(tface);
+ SkTypeface::Style style = tface->style();
+ if (style & SkTypeface::kItalic) {
+ this->addAttribute("font-style", "italic");
+ }
+ if (style & SkTypeface::kBold) {
+ this->addAttribute("font-weight", "bold");
+ }
+
SkAutoTUnref<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamilyNameIterator());
SkTypeface::LocalizedString familyString;
while (familyNameIter->next(&familyString)) {