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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 * | 740 * |
741 * Resources are canonicalized and uniqueified by pointer so there has to be | 741 * Resources are canonicalized and uniqueified by pointer so there has to be |
742 * some additional state indicating which subset of the font is used. It | 742 * some additional state indicating which subset of the font is used. It |
743 * must be maintained at the page granularity and then combined at the document | 743 * must be maintained at the page granularity and then combined at the document |
744 * granularity. a) change SkPDFFont to fill in its state on demand, kind of | 744 * granularity. a) change SkPDFFont to fill in its state on demand, kind of |
745 * like SkPDFGraphicState. b) maintain a per font glyph usage class in each | 745 * like SkPDFGraphicState. b) maintain a per font glyph usage class in each |
746 * page/pdf device. c) in the document, retrieve the per font glyph usage | 746 * page/pdf device. c) in the document, retrieve the per font glyph usage |
747 * from each page and combine it and ask for a resource with that subset. | 747 * from each page and combine it and ask for a resource with that subset. |
748 */ | 748 */ |
749 | 749 |
750 SkPDFFont::~SkPDFFont() { fCanon->removeFont(this); } | 750 SkPDFFont::~SkPDFFont() {} |
751 | 751 |
752 SkTypeface* SkPDFFont::typeface() { | 752 SkTypeface* SkPDFFont::typeface() { |
753 return fTypeface.get(); | 753 return fTypeface.get(); |
754 } | 754 } |
755 | 755 |
756 SkAdvancedTypefaceMetrics::FontType SkPDFFont::getType() { | 756 SkAdvancedTypefaceMetrics::FontType SkPDFFont::getType() { |
757 return fFontType; | 757 return fFontType; |
758 } | 758 } |
759 | 759 |
760 bool SkPDFFont::canEmbed() const { | 760 bool SkPDFFont::canEmbed() const { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( | 847 info = SkTBitOr<SkAdvancedTypefaceMetrics::PerGlyphInfo>( |
848 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); | 848 info, SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo); |
849 fontMetrics.reset( | 849 fontMetrics.reset( |
850 typeface->getAdvancedTypefaceMetrics(info, NULL, 0)); | 850 typeface->getAdvancedTypefaceMetrics(info, NULL, 0)); |
851 } | 851 } |
852 #endif | 852 #endif |
853 } | 853 } |
854 | 854 |
855 SkPDFFont* font = SkPDFFont::Create(canon, fontMetrics.get(), typeface, | 855 SkPDFFont* font = SkPDFFont::Create(canon, fontMetrics.get(), typeface, |
856 glyphID, relatedFontDescriptor); | 856 glyphID, relatedFontDescriptor); |
857 canon->addFont(font, fontID, font->fFirstGlyphID); | 857 canon->addFont(SkRef(font), fontID, font->fFirstGlyphID); |
858 return font; | 858 return font; |
859 } | 859 } |
860 | 860 |
861 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { | 861 SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { |
862 return NULL; // Default: no support. | 862 return NULL; // Default: no support. |
863 } | 863 } |
864 | 864 |
865 SkPDFFont::SkPDFFont(SkPDFCanon* canon, | 865 SkPDFFont::SkPDFFont(SkPDFCanon* canon, |
866 const SkAdvancedTypefaceMetrics* info, | 866 const SkAdvancedTypefaceMetrics* info, |
867 SkTypeface* typeface, | 867 SkTypeface* typeface, |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 } | 1424 } |
1425 if (existingFont != NULL) { | 1425 if (existingFont != NULL) { |
1426 return (existingFont->fFirstGlyphID <= searchGlyphID && | 1426 return (existingFont->fFirstGlyphID <= searchGlyphID && |
1427 searchGlyphID <= existingFont->fLastGlyphID) | 1427 searchGlyphID <= existingFont->fLastGlyphID) |
1428 ? SkPDFFont::kExact_Match | 1428 ? SkPDFFont::kExact_Match |
1429 : SkPDFFont::kRelated_Match; | 1429 : SkPDFFont::kRelated_Match; |
1430 } | 1430 } |
1431 return (existingGlyphID == searchGlyphID) ? SkPDFFont::kExact_Match | 1431 return (existingGlyphID == searchGlyphID) ? SkPDFFont::kExact_Match |
1432 : SkPDFFont::kRelated_Match; | 1432 : SkPDFFont::kRelated_Match; |
1433 } | 1433 } |
OLD | NEW |