Index: src/pdf/SkPDFFont.cpp |
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp |
index 30c11d97926eb974bcf9571adfbdcbedf74dc0d7..1641a8916c32c9757741658b379cfa105499ae73 100644 |
--- a/src/pdf/SkPDFFont.cpp |
+++ b/src/pdf/SkPDFFont.cpp |
@@ -749,24 +749,6 @@ SkAdvancedTypefaceMetrics::FontType SkPDFFont::getType() { |
return fFontType; |
} |
-bool SkPDFFont::canEmbed() const { |
- if (!fFontInfo.get()) { |
- SkASSERT(fFontType == SkAdvancedTypefaceMetrics::kOther_Font); |
- return true; |
- } |
- return (fFontInfo->fFlags & |
- SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag) == 0; |
-} |
- |
-bool SkPDFFont::canSubset() const { |
- if (!fFontInfo.get()) { |
- SkASSERT(fFontType == SkAdvancedTypefaceMetrics::kOther_Font); |
- return true; |
- } |
- return (fFontInfo->fFlags & |
- SkAdvancedTypefaceMetrics::kNotSubsettable_FontFlag) == 0; |
-} |
- |
bool SkPDFFont::hasGlyph(uint16_t id) { |
return (id >= fFirstGlyphID && id <= fLastGlyphID) || id == 0; |
} |
@@ -815,7 +797,7 @@ SkPDFFont* SkPDFFont::GetFontResource(SkTypeface* typeface, uint16_t glyphID) { |
// This only is to catch callers who pass invalid glyph ids. |
// If glyph id is invalid, then we will create duplicate entries |
- // for TrueType fonts. |
+ // for True Type fonts. |
SkAdvancedTypefaceMetrics::FontType fontType = |
fontMetrics.get() ? fontMetrics.get()->fType : |
SkAdvancedTypefaceMetrics::kOther_Font; |
@@ -895,8 +877,9 @@ SkPDFFont::SkPDFFont(SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, |
fLastGlyphID(info ? info->fLastGlyphID : 0), |
fFontInfo(SkSafeRef(info)), |
fDescriptor(SkSafeRef(relatedFontDescriptor)) { |
- if (info == NULL || |
- info->fFlags & SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag) { |
+ if (info == NULL) { |
+ fFontType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; |
+ } else if (info->fMultiMaster) { |
fFontType = SkAdvancedTypefaceMetrics::kOther_Font; |
} else { |
fFontType = info->fType; |
@@ -908,10 +891,9 @@ SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, |
SkTypeface* typeface, uint16_t glyphID, |
SkPDFDict* relatedFontDescriptor) { |
SkAdvancedTypefaceMetrics::FontType type = |
- info ? info->fType : SkAdvancedTypefaceMetrics::kOther_Font; |
+ info ? info->fType : SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; |
- if (info && |
- (info->fFlags & SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag)) { |
+ if (info && info->fMultiMaster) { |
NOT_IMPLEMENTED(true, true); |
return new SkPDFType3Font(info, |
typeface, |
@@ -930,7 +912,8 @@ SkPDFFont* SkPDFFont::Create(SkAdvancedTypefaceMetrics* info, |
} |
SkASSERT(type == SkAdvancedTypefaceMetrics::kCFF_Font || |
- type == SkAdvancedTypefaceMetrics::kOther_Font); |
+ type == SkAdvancedTypefaceMetrics::kOther_Font || |
+ type == SkAdvancedTypefaceMetrics::kNotEmbeddable_Font); |
return new SkPDFType3Font(info, typeface, glyphID); |
} |
@@ -1057,17 +1040,11 @@ SkPDFType0Font::SkPDFType0Font(SkAdvancedTypefaceMetrics* info, |
SkTypeface* typeface) |
: SkPDFFont(info, typeface, NULL) { |
SkDEBUGCODE(fPopulated = false); |
- if (!canSubset()) { |
- populate(NULL); |
- } |
} |
SkPDFType0Font::~SkPDFType0Font() {} |
SkPDFFont* SkPDFType0Font::getFontSubset(const SkPDFGlyphSet* subset) { |
- if (!canSubset()) { |
- return NULL; |
- } |
SkPDFType0Font* newSubset = new SkPDFType0Font(fontInfo(), typeface()); |
newSubset->populate(subset); |
return newSubset; |
@@ -1116,34 +1093,19 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, |
SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor")); |
setFontDescriptor(descriptor.get()); |
addResource(descriptor.get()); |
- insert("FontDescriptor", new SkPDFObjRef(descriptor.get()))->unref(); |
- if (!addCommonFontDescriptorEntries(defaultWidth)) { |
- return false; |
- } |
- if (!canEmbed()) { |
- return true; |
- } |
switch (getType()) { |
case SkAdvancedTypefaceMetrics::kTrueType_Font: { |
- SkAutoTUnref<SkPDFStream> fontStream; |
- int fontSize = 0; |
- if (canSubset()) { |
- SkPDFStream* rawStream = NULL; |
- fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(), |
+ SkASSERT(subset); |
+ // Font subsetting |
+ SkPDFStream* rawStream = NULL; |
+ int fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(), |
typeface(), |
*subset, |
&rawStream); |
- fontStream.reset(rawStream); |
- } else { |
- int ttcIndex; |
- SkAutoTUnref<SkStream> fontData( |
- typeface()->openStream(&ttcIndex)); |
- fontStream.reset(new SkPDFStream(fontData.get())); |
- fontSize = fontData->getLength(); |
- } |
SkASSERT(fontSize); |
- SkASSERT(fontStream.get()); |
+ SkASSERT(rawStream); |
+ SkAutoTUnref<SkPDFStream> fontStream(rawStream); |
addResource(fontStream.get()); |
fontStream->insertInt("Length1", fontSize); |
@@ -1171,7 +1133,9 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, |
default: |
SkASSERT(false); |
} |
- return true; |
+ |
+ insert("FontDescriptor", new SkPDFObjRef(descriptor.get()))->unref(); |
+ return addCommonFontDescriptorEntries(defaultWidth); |
} |
bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { |
@@ -1287,15 +1251,12 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) { |
if (fontData == NULL) { |
return false; |
} |
- if (canEmbed()) { |
- SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData)); |
- addResource(fontStream.get()); |
- fontStream->insertInt("Length1", header); |
- fontStream->insertInt("Length2", data); |
- fontStream->insertInt("Length3", trailer); |
- descriptor->insert("FontFile", |
- new SkPDFObjRef(fontStream.get()))->unref(); |
- } |
+ SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData)); |
+ addResource(fontStream.get()); |
+ fontStream->insertInt("Length1", header); |
+ fontStream->insertInt("Length2", data); |
+ fontStream->insertInt("Length3", trailer); |
+ descriptor->insert("FontFile", new SkPDFObjRef(fontStream.get()))->unref(); |
addResource(descriptor.get()); |
insert("FontDescriptor", new SkPDFObjRef(descriptor.get()))->unref(); |