Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/pdf/SkPDFFont.h

Issue 107863002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Mac Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef SkPDFFont_DEFINED 10 #ifndef SkPDFFont_DEFINED
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 /** Returns the font type represented in this font. For Type0 fonts, 93 /** Returns the font type represented in this font. For Type0 fonts,
94 * returns the type of the decendant font. 94 * returns the type of the decendant font.
95 */ 95 */
96 virtual SkAdvancedTypefaceMetrics::FontType getType(); 96 virtual SkAdvancedTypefaceMetrics::FontType getType();
97 97
98 /** Returns true if this font encoding supports glyph IDs above 255. 98 /** Returns true if this font encoding supports glyph IDs above 255.
99 */ 99 */
100 virtual bool multiByteGlyphs() const = 0; 100 virtual bool multiByteGlyphs() const = 0;
101 101
102 /** Returns true if the machine readable licensing bits allow embedding.
103 */
104 bool canEmbed() const;
105
106 /** Returns true if the machine readable licensing bits allow subsetting.
107 */
108 bool canSubset() const;
109
102 /** Return true if this font has an encoding for the passed glyph id. 110 /** Return true if this font has an encoding for the passed glyph id.
103 */ 111 */
104 bool hasGlyph(uint16_t glyphID); 112 bool hasGlyph(uint16_t glyphID);
105 113
106 /** Convert (in place) the input glyph IDs into the font encoding. If the 114 /** Convert (in place) the input glyph IDs into the font encoding. If the
107 * font has more glyphs than can be encoded (like a type 1 font with more 115 * font has more glyphs than can be encoded (like a type 1 font with more
108 * than 255 glyphs) this method only converts up to the first out of range 116 * than 255 glyphs) this method only converts up to the first out of range
109 * glyph ID. 117 * glyph ID.
110 * @param glyphIDs The input text as glyph IDs. 118 * @param glyphIDs The input text as glyph IDs.
111 * @param numGlyphs The number of input glyphs. 119 * @param numGlyphs The number of input glyphs.
112 * @return Returns the number of glyphs consumed. 120 * @return Returns the number of glyphs consumed.
113 */ 121 */
114 size_t glyphsToPDFFontEncoding(uint16_t* glyphIDs, size_t numGlyphs); 122 size_t glyphsToPDFFontEncoding(uint16_t* glyphIDs, size_t numGlyphs);
115 123
116 /** Get the font resource for the passed typeface and glyphID. The 124 /** Get the font resource for the passed typeface and glyphID. The
117 * reference count of the object is incremented and it is the caller's 125 * reference count of the object is incremented and it is the caller's
118 * responsibility to unreference it when done. This is needed to 126 * responsibility to unreference it when done. This is needed to
119 * accommodate the weak reference pattern used when the returned object 127 * accommodate the weak reference pattern used when the returned object
120 * is new and has no other references. 128 * is new and has no other references.
121 * @param typeface The typeface to find. 129 * @param typeface The typeface to find.
122 * @param glyphID Specify which section of a large font is of interest. 130 * @param glyphID Specify which section of a large font is of interest.
123 */ 131 */
124 static SkPDFFont* GetFontResource(SkTypeface* typeface, 132 static SkPDFFont* GetFontResource(SkTypeface* typeface, uint16_t glyphID);
125 uint16_t glyphID);
126 133
127 /** Subset the font based on usage set. Returns a SkPDFFont instance with 134 /** Subset the font based on usage set. Returns a SkPDFFont instance with
128 * subset. 135 * subset.
129 * @param usage Glyph subset requested. 136 * @param usage Glyph subset requested.
130 * @return NULL if font does not support subsetting, a new instance 137 * @return NULL if font does not support subsetting, a new instance
131 * of SkPDFFont otherwise. 138 * of SkPDFFont otherwise.
132 */ 139 */
133 virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); 140 virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage);
134 141
135 protected: 142 protected:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 bool operator==(const FontRec& b) const; 188 bool operator==(const FontRec& b) const;
182 FontRec(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); 189 FontRec(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID);
183 }; 190 };
184 191
185 SkAutoTUnref<SkTypeface> fTypeface; 192 SkAutoTUnref<SkTypeface> fTypeface;
186 193
187 // The glyph IDs accessible with this font. For Type1 (non CID) fonts, 194 // The glyph IDs accessible with this font. For Type1 (non CID) fonts,
188 // this will be a subset if the font has more than 255 glyphs. 195 // this will be a subset if the font has more than 255 glyphs.
189 uint16_t fFirstGlyphID; 196 uint16_t fFirstGlyphID;
190 uint16_t fLastGlyphID; 197 uint16_t fLastGlyphID;
191 // The font info is only kept around after construction for large
192 // Type1 (non CID) fonts that need multiple "fonts" to access all glyphs.
193 SkAutoTUnref<SkAdvancedTypefaceMetrics> fFontInfo; 198 SkAutoTUnref<SkAdvancedTypefaceMetrics> fFontInfo;
194 SkTDArray<SkPDFObject*> fResources; 199 SkTDArray<SkPDFObject*> fResources;
195 SkAutoTUnref<SkPDFDict> fDescriptor; 200 SkAutoTUnref<SkPDFDict> fDescriptor;
196 201
197 SkAdvancedTypefaceMetrics::FontType fFontType; 202 SkAdvancedTypefaceMetrics::FontType fFontType;
198 203
199 // This should be made a hash table if performance is a problem. 204 // This should be made a hash table if performance is a problem.
200 static SkTDArray<FontRec>& CanonicalFonts(); 205 static SkTDArray<FontRec>& CanonicalFonts();
201 static SkBaseMutex& CanonicalFontsMutex(); 206 static SkBaseMutex& CanonicalFontsMutex();
202 typedef SkPDFDict INHERITED; 207 typedef SkPDFDict INHERITED;
203 }; 208 };
204 209
205 #endif 210 #endif
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | src/pdf/SkPDFFont.cpp » ('j') | src/ports/SkFontHost_win.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698