| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 <ctype.h> | 8 #include <ctype.h> |
| 9 | 9 |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 fontSize = subsetFontSize; | 633 fontSize = subsetFontSize; |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 if (subsetFontStream) { | 636 if (subsetFontStream) { |
| 637 *fontStream = subsetFontStream; | 637 *fontStream = subsetFontStream; |
| 638 return fontSize; | 638 return fontSize; |
| 639 } | 639 } |
| 640 fontData->rewind(); | 640 fontData->rewind(); |
| 641 | 641 |
| 642 // Fail over: just embed the whole font. | 642 // Fail over: just embed the whole font. |
| 643 *fontStream = new SkPDFStream(fontData.get()); | 643 *fontStream = new SkPDFStream(std::move(fontData)); |
| 644 return fontSize; | 644 return fontSize; |
| 645 } | 645 } |
| 646 #endif | 646 #endif |
| 647 | 647 |
| 648 /////////////////////////////////////////////////////////////////////////////// | 648 /////////////////////////////////////////////////////////////////////////////// |
| 649 // class SkPDFGlyphSet | 649 // class SkPDFGlyphSet |
| 650 /////////////////////////////////////////////////////////////////////////////// | 650 /////////////////////////////////////////////////////////////////////////////// |
| 651 | 651 |
| 652 SkPDFGlyphSet::SkPDFGlyphSet() : fBitSet(SK_MaxU16 + 1) { | 652 SkPDFGlyphSet::SkPDFGlyphSet() : fBitSet(SK_MaxU16 + 1) { |
| 653 } | 653 } |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 | 1349 |
| 1350 SkDynamicMemoryWStream content; | 1350 SkDynamicMemoryWStream content; |
| 1351 setGlyphWidthAndBoundingBox(SkFloatToScalar(glyph.fAdvanceX), glyphBBox, | 1351 setGlyphWidthAndBoundingBox(SkFloatToScalar(glyph.fAdvanceX), glyphBBox, |
| 1352 &content); | 1352 &content); |
| 1353 const SkPath* path = cache->findPath(glyph); | 1353 const SkPath* path = cache->findPath(glyph); |
| 1354 if (path) { | 1354 if (path) { |
| 1355 SkPDFUtils::EmitPath(*path, paint.getStyle(), &content); | 1355 SkPDFUtils::EmitPath(*path, paint.getStyle(), &content); |
| 1356 SkPDFUtils::PaintPath(paint.getStyle(), path->getFillType(), | 1356 SkPDFUtils::PaintPath(paint.getStyle(), path->getFillType(), |
| 1357 &content); | 1357 &content); |
| 1358 } | 1358 } |
| 1359 std::unique_ptr<SkMemoryStream> glyphStream(new SkMemoryStream()); | |
| 1360 glyphStream->setData(content.copyToData())->unref(); | |
| 1361 | |
| 1362 charProcs->insertObjRef( | 1359 charProcs->insertObjRef( |
| 1363 characterName, sk_make_sp<SkPDFStream>(glyphStream.get())); | 1360 characterName, sk_make_sp<SkPDFStream>( |
| 1361 std::unique_ptr<SkStreamAsset>(content.detachAsStream())
)); |
| 1364 } | 1362 } |
| 1365 | 1363 |
| 1366 encoding->insertObject("Differences", std::move(encDiffs)); | 1364 encoding->insertObject("Differences", std::move(encDiffs)); |
| 1367 | 1365 |
| 1368 this->insertObject("CharProcs", std::move(charProcs)); | 1366 this->insertObject("CharProcs", std::move(charProcs)); |
| 1369 this->insertObject("Encoding", std::move(encoding)); | 1367 this->insertObject("Encoding", std::move(encoding)); |
| 1370 | 1368 |
| 1371 this->insertObject("FontBBox", makeFontBBox(bbox, 1000)); | 1369 this->insertObject("FontBBox", makeFontBBox(bbox, 1000)); |
| 1372 this->insertInt("FirstChar", 1); | 1370 this->insertInt("FirstChar", 1); |
| 1373 this->insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); | 1371 this->insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 } | 1415 } |
| 1418 return *canon->fCanEmbedTypeface.set(id, canEmbed); | 1416 return *canon->fCanEmbedTypeface.set(id, canEmbed); |
| 1419 } | 1417 } |
| 1420 | 1418 |
| 1421 void SkPDFFont::drop() { | 1419 void SkPDFFont::drop() { |
| 1422 fTypeface = nullptr; | 1420 fTypeface = nullptr; |
| 1423 fFontInfo = nullptr; | 1421 fFontInfo = nullptr; |
| 1424 fDescriptor = nullptr; | 1422 fDescriptor = nullptr; |
| 1425 this->SkPDFDict::drop(); | 1423 this->SkPDFDict::drop(); |
| 1426 } | 1424 } |
| OLD | NEW |