Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include <ctype.h> | 10 #include <ctype.h> |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "SkScalar.h" | 24 #include "SkScalar.h" |
| 25 #include "SkStream.h" | 25 #include "SkStream.h" |
| 26 #include "SkTypeface.h" | 26 #include "SkTypeface.h" |
| 27 #include "SkTypes.h" | 27 #include "SkTypes.h" |
| 28 #include "SkUtils.h" | 28 #include "SkUtils.h" |
| 29 | 29 |
| 30 #if defined (SK_SFNTLY_SUBSETTER) | 30 #if defined (SK_SFNTLY_SUBSETTER) |
| 31 #include SK_SFNTLY_SUBSETTER | 31 #include SK_SFNTLY_SUBSETTER |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 class SkAutoDefaultTypeface { | |
| 35 public: | |
| 36 SkAutoDefaultTypeface() : fFace(SkTypeface::RefDefault()) { | |
| 37 fCallUnref = true; | |
| 38 } | |
| 39 | |
| 40 SkAutoDefaultTypeface(SkTypeface* face) : fFace(face) { | |
| 41 if (face) { | |
| 42 fFace = SkTypeface::RefDefault(); | |
| 43 fCallUnref = true; | |
| 44 } else { | |
| 45 fCallUnref = false; | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 ~SkAutoDefaultTypeface() { | |
| 50 if (fCallUnref) { | |
| 51 fFace->unref(); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 SkTypeface* get() const { return fFace; } | |
| 56 SkTypeface* operator->() { return fFace; } | |
| 57 operator SkTypeface*() { return fFace; } | |
| 58 | |
| 59 private: | |
| 60 SkTypeface* fFace; | |
| 61 bool fCallUnref; | |
| 62 }; | |
| 63 | |
| 34 namespace { | 64 namespace { |
| 35 | 65 |
| 36 /////////////////////////////////////////////////////////////////////////////// | 66 /////////////////////////////////////////////////////////////////////////////// |
| 37 // File-Local Functions | 67 // File-Local Functions |
| 38 /////////////////////////////////////////////////////////////////////////////// | 68 /////////////////////////////////////////////////////////////////////////////// |
| 39 | 69 |
| 40 bool parsePFBSection(const uint8_t** src, size_t* len, int sectionType, | 70 bool parsePFBSection(const uint8_t** src, size_t* len, int sectionType, |
| 41 size_t* size) { | 71 size_t* size) { |
| 42 // PFB sections have a two or six bytes header. 0x80 and a one byte | 72 // PFB sections have a two or six bytes header. 0x80 and a one byte |
| 43 // section type followed by a four byte section length. Type one is | 73 // section type followed by a four byte section length. Type one is |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 } | 564 } |
| 535 | 565 |
| 536 #if defined (SK_SFNTLY_SUBSETTER) | 566 #if defined (SK_SFNTLY_SUBSETTER) |
| 537 static void sk_delete_array(const void* ptr, size_t, void*) { | 567 static void sk_delete_array(const void* ptr, size_t, void*) { |
| 538 // Use C-style cast to cast away const and cast type simultaneously. | 568 // Use C-style cast to cast away const and cast type simultaneously. |
| 539 delete[] (unsigned char*)ptr; | 569 delete[] (unsigned char*)ptr; |
| 540 } | 570 } |
| 541 #endif | 571 #endif |
| 542 | 572 |
| 543 static int get_subset_font_stream(const char* fontName, | 573 static int get_subset_font_stream(const char* fontName, |
| 544 const SkTypeface* typeface, | 574 SkTypeface* typeface, |
| 545 const SkTDArray<uint32_t>& subset, | 575 const SkTDArray<uint32_t>& subset, |
| 546 SkPDFStream** fontStream) { | 576 SkPDFStream** fontStream) { |
| 547 SkAutoTUnref<SkStream> fontData( | 577 int ttcIndex; |
| 548 SkFontHost::OpenStream(SkTypeface::UniqueID(typeface))); | 578 SkAutoTUnref<SkStream> fontData(typeface->openStream(&ttcIndex)); |
| 549 | 579 |
| 550 int fontSize = fontData->getLength(); | 580 int fontSize = fontData->getLength(); |
| 551 | 581 |
| 552 #if defined (SK_SFNTLY_SUBSETTER) | 582 #if defined (SK_SFNTLY_SUBSETTER) |
| 553 // Read font into buffer. | 583 // Read font into buffer. |
| 554 SkPDFStream* subsetFontStream = NULL; | 584 SkPDFStream* subsetFontStream = NULL; |
| 555 SkTDArray<unsigned char> originalFont; | 585 SkTDArray<unsigned char> originalFont; |
| 556 originalFont.setCount(fontSize); | 586 originalFont.setCount(fontSize); |
| 557 if (fontData->read(originalFont.begin(), fontSize) == (size_t)fontSize) { | 587 if (fontData->read(originalFont.begin(), fontSize) == (size_t)fontSize) { |
| 558 unsigned char* subsetFont = NULL; | 588 unsigned char* subsetFont = NULL; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 SkAutoMutexAcquire lock(CanonicalFontsMutex()); | 732 SkAutoMutexAcquire lock(CanonicalFontsMutex()); |
| 703 int index = -1; | 733 int index = -1; |
| 704 for (int i = 0 ; i < CanonicalFonts().count() ; i++) { | 734 for (int i = 0 ; i < CanonicalFonts().count() ; i++) { |
| 705 if (CanonicalFonts()[i].fFont == this) { | 735 if (CanonicalFonts()[i].fFont == this) { |
| 706 index = i; | 736 index = i; |
| 707 } | 737 } |
| 708 } | 738 } |
| 709 | 739 |
| 710 SkDEBUGCODE(int indexFound;) | 740 SkDEBUGCODE(int indexFound;) |
| 711 SkASSERT(index == -1 || | 741 SkASSERT(index == -1 || |
| 712 (Find(SkTypeface::UniqueID(fTypeface.get()), | 742 (Find(fTypeface->uniqueID(), |
| 713 fFirstGlyphID, | 743 fFirstGlyphID, |
| 714 &indexFound) && | 744 &indexFound) && |
| 715 index == indexFound)); | 745 index == indexFound)); |
| 716 if (index >= 0) { | 746 if (index >= 0) { |
| 717 CanonicalFonts().removeShuffle(index); | 747 CanonicalFonts().removeShuffle(index); |
| 718 } | 748 } |
| 719 fResources.unrefAll(); | 749 fResources.unrefAll(); |
| 720 } | 750 } |
| 721 | 751 |
| 722 void SkPDFFont::getResources(SkTDArray<SkPDFObject*>* resourceList) { | 752 void SkPDFFont::getResources(SkTDArray<SkPDFObject*>* resourceList) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 751 } | 781 } |
| 752 glyphIDs[i] -= (fFirstGlyphID - 1); | 782 glyphIDs[i] -= (fFirstGlyphID - 1); |
| 753 } | 783 } |
| 754 | 784 |
| 755 return numGlyphs; | 785 return numGlyphs; |
| 756 } | 786 } |
| 757 | 787 |
| 758 // static | 788 // static |
| 759 SkPDFFont* SkPDFFont::GetFontResource(SkTypeface* typeface, uint16_t glyphID) { | 789 SkPDFFont* SkPDFFont::GetFontResource(SkTypeface* typeface, uint16_t glyphID) { |
| 760 SkAutoMutexAcquire lock(CanonicalFontsMutex()); | 790 SkAutoMutexAcquire lock(CanonicalFontsMutex()); |
| 761 const uint32_t fontID = SkTypeface::UniqueID(typeface); | 791 |
| 792 SkAutoDefaultTypeface autoFace(typeface); | |
|
bungeman-skia
2013/03/12 21:07:23
Is this less verbose and achieve the same ends?
S
| |
| 793 typeface = autoFace.get(); | |
| 794 | |
| 762 int relatedFontIndex; | 795 int relatedFontIndex; |
| 763 if (Find(fontID, glyphID, &relatedFontIndex)) { | 796 if (Find(typeface->uniqueID(), glyphID, &relatedFontIndex)) { |
| 764 CanonicalFonts()[relatedFontIndex].fFont->ref(); | 797 CanonicalFonts()[relatedFontIndex].fFont->ref(); |
| 765 return CanonicalFonts()[relatedFontIndex].fFont; | 798 return CanonicalFonts()[relatedFontIndex].fFont; |
| 766 } | 799 } |
| 767 | 800 |
| 768 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics; | 801 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics; |
| 769 SkPDFDict* relatedFontDescriptor = NULL; | 802 SkPDFDict* relatedFontDescriptor = NULL; |
| 770 if (relatedFontIndex >= 0) { | 803 if (relatedFontIndex >= 0) { |
| 771 SkPDFFont* relatedFont = CanonicalFonts()[relatedFontIndex].fFont; | 804 SkPDFFont* relatedFont = CanonicalFonts()[relatedFontIndex].fFont; |
| 772 fontMetrics.reset(relatedFont->fontInfo()); | 805 fontMetrics.reset(relatedFont->fontInfo()); |
| 773 SkSafeRef(fontMetrics.get()); | 806 SkSafeRef(fontMetrics.get()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 788 } else { | 821 } else { |
| 789 SkAdvancedTypefaceMetrics::PerGlyphInfo info; | 822 SkAdvancedTypefaceMetrics::PerGlyphInfo info; |
| 790 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo; | 823 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo; |
| 791 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( | 824 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( |
| 792 info, SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo); | 825 info, SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo); |
| 793 #if !defined (SK_SFNTLY_SUBSETTER) | 826 #if !defined (SK_SFNTLY_SUBSETTER) |
| 794 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( | 827 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( |
| 795 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); | 828 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); |
| 796 #endif | 829 #endif |
| 797 fontMetrics.reset( | 830 fontMetrics.reset( |
| 798 SkFontHost::GetAdvancedTypefaceMetrics(fontID, info, NULL, 0)); | 831 typeface->getAdvancedTypefaceMetrics(info, NULL, 0)); |
| 799 #if defined (SK_SFNTLY_SUBSETTER) | 832 #if defined (SK_SFNTLY_SUBSETTER) |
| 800 if (fontMetrics.get() && | 833 if (fontMetrics.get() && |
| 801 fontMetrics->fType != SkAdvancedTypefaceMetrics::kTrueType_Font) { | 834 fontMetrics->fType != SkAdvancedTypefaceMetrics::kTrueType_Font) { |
| 802 // Font does not support subsetting, get new info with advance. | 835 // Font does not support subsetting, get new info with advance. |
| 803 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( | 836 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( |
| 804 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); | 837 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); |
| 805 fontMetrics.reset( | 838 fontMetrics.reset( |
| 806 SkFontHost::GetAdvancedTypefaceMetrics(fontID, info, NULL, 0)); | 839 typeface->getAdvancedTypefaceMetrics(info, NULL, 0)); |
| 807 } | 840 } |
| 808 #endif | 841 #endif |
| 809 } | 842 } |
| 810 | 843 |
| 811 SkPDFFont* font = Create(fontMetrics.get(), typeface, glyphID, | 844 SkPDFFont* font = Create(fontMetrics.get(), typeface, glyphID, |
| 812 relatedFontDescriptor); | 845 relatedFontDescriptor); |
| 813 FontRec newEntry(font, fontID, font->fFirstGlyphID); | 846 FontRec newEntry(font, typeface->uniqueID(), font->fFirstGlyphID); |
| 814 CanonicalFonts().push(newEntry); | 847 CanonicalFonts().push(newEntry); |
| 815 return font; // Return the reference new SkPDFFont() created. | 848 return font; // Return the reference new SkPDFFont() created. |
| 816 } | 849 } |
| 817 | 850 |
| 818 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { | 851 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { |
| 819 return NULL; // Default: no support. | 852 return NULL; // Default: no support. |
| 820 } | 853 } |
| 821 | 854 |
| 822 // static | 855 // static |
| 823 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() { | 856 SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 843 return true; | 876 return true; |
| 844 } | 877 } |
| 845 search.fGlyphID = 0; | 878 search.fGlyphID = 0; |
| 846 *index = CanonicalFonts().find(search); | 879 *index = CanonicalFonts().find(search); |
| 847 return false; | 880 return false; |
| 848 } | 881 } |
| 849 | 882 |
| 850 SkPDFFont::SkPDFFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, | 883 SkPDFFont::SkPDFFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, |
| 851 SkPDFDict* relatedFontDescriptor) | 884 SkPDFDict* relatedFontDescriptor) |
| 852 : SkPDFDict("Font"), | 885 : SkPDFDict("Font"), |
| 853 fTypeface(typeface), | 886 fTypeface(typeface), |
|
bungeman-skia
2013/03/12 21:07:23
Because fTypeface is an SkAutoTUnref<SkTypeface> t
reed1
2013/03/13 21:18:17
Done.
| |
| 854 fFirstGlyphID(1), | 887 fFirstGlyphID(1), |
| 855 fLastGlyphID(info ? info->fLastGlyphID : 0), | 888 fLastGlyphID(info ? info->fLastGlyphID : 0), |
| 856 fFontInfo(info), | 889 fFontInfo(info), |
|
bungeman-skia
2013/03/12 21:07:23
For the same reason this should have been
fFontIn
| |
| 857 fDescriptor(relatedFontDescriptor) { | 890 fDescriptor(relatedFontDescriptor) { |
| 858 SkSafeRef(typeface); | |
| 859 SkSafeRef(info); | 891 SkSafeRef(info); |
| 860 if (info == NULL) { | 892 if (info == NULL) { |
| 861 fFontType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | 893 fFontType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; |
| 862 } else if (info->fMultiMaster) { | 894 } else if (info->fMultiMaster) { |
| 863 fFontType = SkAdvancedTypefaceMetrics::kOther_Font; | 895 fFontType = SkAdvancedTypefaceMetrics::kOther_Font; |
| 864 } else { | 896 } else { |
| 865 fFontType = info->fType; | 897 fFontType = info->fType; |
| 866 } | 898 } |
| 899 | |
| 900 // we want fTypeface to always ref a valid typeface, so if the caller | |
| 901 // gave us null, we ref the default. | |
| 902 if (typeface) { | |
| 903 typeface->ref(); | |
| 904 } else { | |
| 905 fTypeface.reset(SkTypeface::RefDefault()); | |
| 906 } | |
| 867 } | 907 } |
| 868 | 908 |
| 869 // static | 909 // static |
| 870 SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, | 910 SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, |
| 871 SkTypeface* typeface, uint16_t glyphID, | 911 SkTypeface* typeface, uint16_t glyphID, |
| 872 SkPDFDict* relatedFontDescriptor) { | 912 SkPDFDict* relatedFontDescriptor) { |
| 873 SkAdvancedTypefaceMetrics::FontType type = | 913 SkAdvancedTypefaceMetrics::FontType type = |
| 874 info ? info->fType : SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | 914 info ? info->fType : SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; |
| 875 | 915 |
| 876 if (info && info->fMultiMaster) { | 916 if (info && info->fMultiMaster) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 SkAutoTUnref<SkPDFStream> fontStream(rawStream); | 1127 SkAutoTUnref<SkPDFStream> fontStream(rawStream); |
| 1088 addResource(fontStream.get()); | 1128 addResource(fontStream.get()); |
| 1089 | 1129 |
| 1090 fontStream->insertInt("Length1", fontSize); | 1130 fontStream->insertInt("Length1", fontSize); |
| 1091 descriptor->insert("FontFile2", | 1131 descriptor->insert("FontFile2", |
| 1092 new SkPDFObjRef(fontStream.get()))->unref(); | 1132 new SkPDFObjRef(fontStream.get()))->unref(); |
| 1093 break; | 1133 break; |
| 1094 } | 1134 } |
| 1095 case SkAdvancedTypefaceMetrics::kCFF_Font: | 1135 case SkAdvancedTypefaceMetrics::kCFF_Font: |
| 1096 case SkAdvancedTypefaceMetrics::kType1CID_Font: { | 1136 case SkAdvancedTypefaceMetrics::kType1CID_Font: { |
| 1097 SkAutoTUnref<SkStream> fontData( | 1137 int ttcIndex; |
| 1098 SkFontHost::OpenStream(SkTypeface::UniqueID(typeface()))); | 1138 SkAutoTUnref<SkStream> fontData(typeface()->openStream(&ttcIndex)); |
| 1099 SkAutoTUnref<SkPDFStream> fontStream( | 1139 SkAutoTUnref<SkPDFStream> fontStream( |
| 1100 new SkPDFStream(fontData.get())); | 1140 new SkPDFStream(fontData.get())); |
| 1101 addResource(fontStream.get()); | 1141 addResource(fontStream.get()); |
| 1102 | 1142 |
| 1103 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) { | 1143 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) { |
| 1104 fontStream->insertName("Subtype", "Type1C"); | 1144 fontStream->insertName("Subtype", "Type1C"); |
| 1105 } else { | 1145 } else { |
| 1106 fontStream->insertName("Subtype", "CIDFontType0c"); | 1146 fontStream->insertName("Subtype", "CIDFontType0c"); |
| 1107 } | 1147 } |
| 1108 descriptor->insert("FontFile3", | 1148 descriptor->insert("FontFile3", |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1127 subset->exportTo(&glyphIDs); | 1167 subset->exportTo(&glyphIDs); |
| 1128 } | 1168 } |
| 1129 | 1169 |
| 1130 SkAdvancedTypefaceMetrics::PerGlyphInfo info; | 1170 SkAdvancedTypefaceMetrics::PerGlyphInfo info; |
| 1131 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo; | 1171 info = SkAdvancedTypefaceMetrics::kGlyphNames_PerGlyphInfo; |
| 1132 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( | 1172 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( |
| 1133 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); | 1173 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); |
| 1134 uint32_t* glyphs = (glyphIDs.count() == 1) ? NULL : glyphIDs.begin(); | 1174 uint32_t* glyphs = (glyphIDs.count() == 1) ? NULL : glyphIDs.begin(); |
| 1135 uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0; | 1175 uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0; |
| 1136 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics( | 1176 SkAutoTUnref<SkAdvancedTypefaceMetrics> fontMetrics( |
| 1137 SkFontHost::GetAdvancedTypefaceMetrics( | 1177 typeface()->getAdvancedTypefaceMetrics(info, glyphs, glyphsCount)); |
| 1138 SkTypeface::UniqueID(typeface()), | |
| 1139 info, | |
| 1140 glyphs, | |
| 1141 glyphsCount)); | |
| 1142 setFontInfo(fontMetrics.get()); | 1178 setFontInfo(fontMetrics.get()); |
| 1143 addFontDescriptor(0, &glyphIDs); | 1179 addFontDescriptor(0, &glyphIDs); |
| 1144 } else { | 1180 } else { |
| 1145 // Other CID fonts | 1181 // Other CID fonts |
| 1146 addFontDescriptor(0, NULL); | 1182 addFontDescriptor(0, NULL); |
| 1147 } | 1183 } |
| 1148 | 1184 |
| 1149 insertName("BaseFont", fontInfo()->fFontName); | 1185 insertName("BaseFont", fontInfo()->fFontName); |
| 1150 | 1186 |
| 1151 if (getType() == SkAdvancedTypefaceMetrics::kType1CID_Font) { | 1187 if (getType() == SkAdvancedTypefaceMetrics::kType1CID_Font) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1220 insert("FontDescriptor", new SkPDFObjRef(descriptor))->unref(); | 1256 insert("FontDescriptor", new SkPDFObjRef(descriptor))->unref(); |
| 1221 return true; | 1257 return true; |
| 1222 } | 1258 } |
| 1223 | 1259 |
| 1224 SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor")); | 1260 SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor")); |
| 1225 setFontDescriptor(descriptor.get()); | 1261 setFontDescriptor(descriptor.get()); |
| 1226 | 1262 |
| 1227 size_t header SK_INIT_TO_AVOID_WARNING; | 1263 size_t header SK_INIT_TO_AVOID_WARNING; |
| 1228 size_t data SK_INIT_TO_AVOID_WARNING; | 1264 size_t data SK_INIT_TO_AVOID_WARNING; |
| 1229 size_t trailer SK_INIT_TO_AVOID_WARNING; | 1265 size_t trailer SK_INIT_TO_AVOID_WARNING; |
| 1230 SkAutoTUnref<SkStream> rawFontData( | 1266 int ttcIndex; |
| 1231 SkFontHost::OpenStream(SkTypeface::UniqueID(typeface()))); | 1267 SkAutoTUnref<SkStream> rawFontData(typeface()->openStream(&ttcIndex)); |
| 1232 SkStream* fontData = handleType1Stream(rawFontData.get(), &header, &data, | 1268 SkStream* fontData = handleType1Stream(rawFontData.get(), &header, &data, |
| 1233 &trailer); | 1269 &trailer); |
| 1234 if (fontData == NULL) { | 1270 if (fontData == NULL) { |
| 1235 return false; | 1271 return false; |
| 1236 } | 1272 } |
| 1237 SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData)); | 1273 SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData)); |
| 1238 addResource(fontStream.get()); | 1274 addResource(fontStream.get()); |
| 1239 fontStream->insertInt("Length1", header); | 1275 fontStream->insertInt("Length1", header); |
| 1240 fontStream->insertInt("Length2", data); | 1276 fontStream->insertInt("Length2", data); |
| 1241 fontStream->insertInt("Length3", trailer); | 1277 fontStream->insertInt("Length3", trailer); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1404 | 1440 |
| 1405 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); | 1441 insert("FontBBox", makeFontBBox(bbox, 1000))->unref(); |
| 1406 insertInt("FirstChar", firstGlyphID()); | 1442 insertInt("FirstChar", firstGlyphID()); |
| 1407 insertInt("LastChar", lastGlyphID()); | 1443 insertInt("LastChar", lastGlyphID()); |
| 1408 insert("Widths", widthArray.get()); | 1444 insert("Widths", widthArray.get()); |
| 1409 insertName("CIDToGIDMap", "Identity"); | 1445 insertName("CIDToGIDMap", "Identity"); |
| 1410 | 1446 |
| 1411 populateToUnicodeTable(NULL); | 1447 populateToUnicodeTable(NULL); |
| 1412 return true; | 1448 return true; |
| 1413 } | 1449 } |
| OLD | NEW |