| 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 "SkData.h" | 8 #include "SkData.h" |
| 9 #include "SkGlyphCache.h" | 9 #include "SkGlyphCache.h" |
| 10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 SkAdvancedTypefaceMetrics::FontType type = this->getType(); | 361 SkAdvancedTypefaceMetrics::FontType type = this->getType(); |
| 362 SkTypeface* face = this->typeface(); | 362 SkTypeface* face = this->typeface(); |
| 363 SkASSERT(face); | 363 SkASSERT(face); |
| 364 | 364 |
| 365 auto descriptor = sk_make_sp<SkPDFDict>("FontDescriptor"); | 365 auto descriptor = sk_make_sp<SkPDFDict>("FontDescriptor"); |
| 366 add_common_font_descriptor_entries(descriptor.get(), metrics, 0); | 366 add_common_font_descriptor_entries(descriptor.get(), metrics, 0); |
| 367 | 367 |
| 368 int ttcIndex; | 368 int ttcIndex; |
| 369 std::unique_ptr<SkStreamAsset> fontAsset(face->openStream(&ttcIndex)); | 369 std::unique_ptr<SkStreamAsset> fontAsset(face->openStream(&ttcIndex)); |
| 370 size_t fontSize = fontAsset ? fontAsset->getLength() : 0; | 370 size_t fontSize = fontAsset ? fontAsset->getLength() : 0; |
| 371 SkASSERT(fontAsset); | 371 if (0 == fontSize) { |
| 372 SkASSERT(fontSize > 0); | 372 SkDebugf("Error: (SkTypeface)(%p)::openStream() returned " |
| 373 if (fontSize > 0) { | 373 "empty stream (%p) when identified as kType1CID_Font " |
| 374 "or kTrueType_Font.\n", face, fontAsset.get()); |
| 375 } else { |
| 374 switch (type) { | 376 switch (type) { |
| 375 case SkAdvancedTypefaceMetrics::kTrueType_Font: { | 377 case SkAdvancedTypefaceMetrics::kTrueType_Font: { |
| 376 #ifdef SK_PDF_USE_SFNTLY | 378 #ifdef SK_PDF_USE_SFNTLY |
| 377 if (!SkToBool(metrics.fFlags & | 379 if (!SkToBool(metrics.fFlags & |
| 378 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFla
g)) { | 380 SkAdvancedTypefaceMetrics::kNotSubsettable_FontFla
g)) { |
| 379 sk_sp<SkPDFStream> subsetStream = get_subset_font_stream( | 381 sk_sp<SkPDFStream> subsetStream = get_subset_font_stream( |
| 380 std::move(fontAsset), this->glyphUsage(), | 382 std::move(fontAsset), this->glyphUsage(), |
| 381 metrics.fFontName.c_str(), ttcIndex); | 383 metrics.fFontName.c_str(), ttcIndex); |
| 382 if (subsetStream) { | 384 if (subsetStream) { |
| 383 descriptor->insertObjRef("FontFile2", std::move(subsetSt
ream)); | 385 descriptor->insertObjRef("FontFile2", std::move(subsetSt
ream)); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 724 |
| 723 bool SkPDFFont::CanEmbedTypeface(SkTypeface* typeface, SkPDFCanon* canon) { | 725 bool SkPDFFont::CanEmbedTypeface(SkTypeface* typeface, SkPDFCanon* canon) { |
| 724 const SkAdvancedTypefaceMetrics* metrics = SkPDFFont::GetMetrics(typeface, c
anon); | 726 const SkAdvancedTypefaceMetrics* metrics = SkPDFFont::GetMetrics(typeface, c
anon); |
| 725 return metrics && can_embed(*metrics); | 727 return metrics && can_embed(*metrics); |
| 726 } | 728 } |
| 727 | 729 |
| 728 void SkPDFFont::drop() { | 730 void SkPDFFont::drop() { |
| 729 fTypeface = nullptr; | 731 fTypeface = nullptr; |
| 730 this->SkPDFDict::drop(); | 732 this->SkPDFDict::drop(); |
| 731 } | 733 } |
| OLD | NEW |