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

Side by Side Diff: core/fxge/include/fx_font.h

Issue 2350763002: Revert of Pdfium: Fix fonts leaking on ClosePage. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « core/fxge/include/cfx_renderdevice.h ('k') | core/fxge/include/ifx_renderdevicedriver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FXGE_INCLUDE_FX_FONT_H_ 7 #ifndef CORE_FXGE_INCLUDE_FX_FONT_H_
8 #define CORE_FXGE_INCLUDE_FX_FONT_H_ 8 #define CORE_FXGE_INCLUDE_FX_FONT_H_
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fxcrt/include/fx_system.h" 13 #include "core/fxcrt/include/fx_system.h"
14 #include "core/fxge/include/cfx_substfont.h" 14 #include "core/fxge/include/cfx_substfont.h"
15 #include "core/fxge/include/fx_dib.h" 15 #include "core/fxge/include/fx_dib.h"
16 #include "core/fxge/include/fx_freetype.h" 16 #include "core/fxge/include/fx_freetype.h"
17 17
18 typedef struct FT_FaceRec_* FXFT_Face; 18 typedef struct FT_FaceRec_* FXFT_Face;
19 typedef void* FXFT_Library; 19 typedef void* FXFT_Library;
20 20
21 class CFX_FaceCache; 21 class CFX_FaceCache;
22 class CFX_GlyphBitmap; 22 class CFX_FontCache;
23 class CFX_PathData; 23 class CFX_PathData;
24 class CFX_SizeGlyphCache; 24 class CFX_SizeGlyphCache;
25 25
26 #ifdef _SKIA_SUPPORT_ 26 #ifdef _SKIA_SUPPORT_
27 class SkTypeface; 27 class SkTypeface;
28 28
29 using CFX_TypeFace = SkTypeface; 29 using CFX_TypeFace = SkTypeface;
30 #endif 30 #endif
31 31
32 #define FXFONT_FIXED_PITCH 0x01 32 #define FXFONT_FIXED_PITCH 0x01
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size); 99 FX_BOOL LoadEmbedded(const uint8_t* data, uint32_t size);
100 FXFT_Face GetFace() const { return m_Face; } 100 FXFT_Face GetFace() const { return m_Face; }
101 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); } 101 CFX_SubstFont* GetSubstFont() const { return m_pSubstFont.get(); }
102 102
103 #ifdef PDF_ENABLE_XFA 103 #ifdef PDF_ENABLE_XFA
104 FX_BOOL LoadFile(IFX_FileRead* pFile, 104 FX_BOOL LoadFile(IFX_FileRead* pFile,
105 int nFaceIndex = 0, 105 int nFaceIndex = 0,
106 int* pFaceCount = nullptr); 106 int* pFaceCount = nullptr);
107 107
108 FX_BOOL LoadClone(const CFX_Font* pFont); 108 FX_BOOL LoadClone(const CFX_Font* pFont);
109 void SetFace(FXFT_Face face); 109 void SetFace(FXFT_Face face) { m_Face = face; }
110 void SetSubstFont(std::unique_ptr<CFX_SubstFont> subst) { 110 void SetSubstFont(std::unique_ptr<CFX_SubstFont> subst) {
111 m_pSubstFont = std::move(subst); 111 m_pSubstFont = std::move(subst);
112 } 112 }
113 #endif // PDF_ENABLE_XFA 113 #endif // PDF_ENABLE_XFA
114 114
115 const CFX_GlyphBitmap* LoadGlyphBitmap(uint32_t glyph_index, 115 CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width = 0);
116 FX_BOOL bFontStyle,
117 const CFX_Matrix* pMatrix,
118 int dest_width,
119 int anti_alias,
120 int& text_flags) const;
121 const CFX_PathData* LoadGlyphPath(uint32_t glyph_index, int dest_width) const;
122
123 #ifdef _SKIA_SUPPORT_
124 CFX_TypeFace* GetDeviceCache() const;
125 #endif
126
127 int GetGlyphWidth(uint32_t glyph_index); 116 int GetGlyphWidth(uint32_t glyph_index);
128 int GetAscent() const; 117 int GetAscent() const;
129 int GetDescent() const; 118 int GetDescent() const;
130 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox); 119 FX_BOOL GetGlyphBBox(uint32_t glyph_index, FX_RECT& bbox);
131 bool IsItalic() const; 120 bool IsItalic() const;
132 bool IsBold() const; 121 bool IsBold() const;
133 bool IsFixedWidth() const; 122 bool IsFixedWidth() const;
134 FX_BOOL IsVertical() const { return m_bVertical; } 123 FX_BOOL IsVertical() const { return m_bVertical; }
135 CFX_ByteString GetPsName() const; 124 CFX_ByteString GetPsName() const;
136 CFX_ByteString GetFamilyName() const; 125 CFX_ByteString GetFamilyName() const;
137 CFX_ByteString GetFaceName() const; 126 CFX_ByteString GetFaceName() const;
138 FX_BOOL IsTTFont() const; 127 FX_BOOL IsTTFont() const;
139 FX_BOOL GetBBox(FX_RECT& bbox); 128 FX_BOOL GetBBox(FX_RECT& bbox);
140 int GetHeight() const; 129 int GetHeight() const;
141 int GetULPos() const; 130 int GetULPos() const;
142 int GetULthickness() const; 131 int GetULthickness() const;
143 int GetMaxAdvanceWidth() const; 132 int GetMaxAdvanceWidth() const;
144 FX_BOOL IsEmbedded() const { return m_bEmbedded; } 133 FX_BOOL IsEmbedded() const { return m_bEmbedded; }
145 uint8_t* GetSubData() const { return m_pGsubData; } 134 uint8_t* GetSubData() const { return m_pGsubData; }
146 void SetSubData(uint8_t* data) { m_pGsubData = data; } 135 void SetSubData(uint8_t* data) { m_pGsubData = data; }
147 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 136 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
148 void* GetPlatformFont() const { return m_pPlatformFont; } 137 void* GetPlatformFont() const { return m_pPlatformFont; }
149 void SetPlatformFont(void* font) { m_pPlatformFont = font; } 138 void SetPlatformFont(void* font) { m_pPlatformFont = font; }
150 #endif 139 #endif
151 uint8_t* GetFontData() const { return m_pFontData; } 140 uint8_t* GetFontData() const { return m_pFontData; }
152 uint32_t GetSize() const { return m_dwSize; } 141 uint32_t GetSize() const { return m_dwSize; }
153 void AdjustMMParams(int glyph_index, int width, int weight) const; 142 void AdjustMMParams(int glyph_index, int width, int weight);
154 143
155 static const size_t kAngleSkewArraySize = 30; 144 static const size_t kAngleSkewArraySize = 30;
156 static const char s_AngleSkew[kAngleSkewArraySize]; 145 static const char s_AngleSkew[kAngleSkewArraySize];
157 static const size_t kWeightPowArraySize = 100; 146 static const size_t kWeightPowArraySize = 100;
158 static const uint8_t s_WeightPow[kWeightPowArraySize]; 147 static const uint8_t s_WeightPow[kWeightPowArraySize];
159 static const uint8_t s_WeightPow_11[kWeightPowArraySize]; 148 static const uint8_t s_WeightPow_11[kWeightPowArraySize];
160 static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize]; 149 static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize];
161 150
162 #ifdef PDF_ENABLE_XFA 151 #ifdef PDF_ENABLE_XFA
163 protected: 152 protected:
164 CFX_BinaryBuf m_OtfFontData; 153 CFX_BinaryBuf m_OtfFontData;
165 bool m_bShallowCopy; 154 bool m_bShallowCopy;
166 FXFT_StreamRec* m_pOwnedStream; 155 FXFT_StreamRec* m_pOwnedStream;
167 #endif // PDF_ENABLE_XFA 156 #endif // PDF_ENABLE_XFA
168 157
169 private: 158 private:
170 friend class CFX_FaceCache;
171 CFX_PathData* LoadGlyphPathImpl(uint32_t glyph_index,
172 int dest_width = 0) const;
173
174 private:
175 CFX_FaceCache* GetFaceCache() const;
176
177 void ReleasePlatformResource(); 159 void ReleasePlatformResource();
178 void DeleteFace(); 160 void DeleteFace();
179 161
180 void ClearFaceCache();
181
182 FXFT_Face m_Face; 162 FXFT_Face m_Face;
183 mutable CFX_FaceCache* m_FaceCache; // not owned.
184 std::unique_ptr<CFX_SubstFont> m_pSubstFont; 163 std::unique_ptr<CFX_SubstFont> m_pSubstFont;
185 std::vector<uint8_t> m_pFontDataAllocation; 164 std::vector<uint8_t> m_pFontDataAllocation;
186 uint8_t* m_pFontData; 165 uint8_t* m_pFontData;
187 uint8_t* m_pGsubData; 166 uint8_t* m_pGsubData;
188 uint32_t m_dwSize; 167 uint32_t m_dwSize;
189 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 168 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
190 void* m_pPlatformFont; 169 void* m_pPlatformFont;
191 #endif 170 #endif
192 FX_BOOL m_bEmbedded; 171 FX_BOOL m_bEmbedded;
193 FX_BOOL m_bVertical; 172 FX_BOOL m_bVertical;
194 }; 173 };
195 174
196 class CFX_FontFaceInfo { 175 class CFX_FontFaceInfo {
197 public: 176 public:
198 CFX_FontFaceInfo(CFX_ByteString filePath, 177 CFX_FontFaceInfo(CFX_ByteString filePath,
199 CFX_ByteString faceName, 178 CFX_ByteString faceName,
200 CFX_ByteString fontTables, 179 CFX_ByteString fontTables,
201 uint32_t fontOffset, 180 uint32_t fontOffset,
202 uint32_t fileSize); 181 uint32_t fileSize);
203 182
204 const CFX_ByteString m_FilePath; 183 const CFX_ByteString m_FilePath;
205 const CFX_ByteString m_FaceName; 184 const CFX_ByteString m_FaceName;
206 const CFX_ByteString m_FontTables; 185 const CFX_ByteString m_FontTables;
207 const uint32_t m_FontOffset; 186 const uint32_t m_FontOffset;
208 const uint32_t m_FileSize; 187 const uint32_t m_FileSize;
209 uint32_t m_Styles; 188 uint32_t m_Styles;
210 uint32_t m_Charsets; 189 uint32_t m_Charsets;
211 }; 190 };
212 191
192 class CFX_CountedFaceCache {
193 public:
194 CFX_FaceCache* m_Obj;
195 uint32_t m_nCount;
196 };
197
213 class CFX_GlyphBitmap { 198 class CFX_GlyphBitmap {
214 public: 199 public:
215 int m_Top; 200 int m_Top;
216 int m_Left; 201 int m_Left;
217 CFX_DIBitmap m_Bitmap; 202 CFX_DIBitmap m_Bitmap;
218 }; 203 };
219 204
220 struct FXTEXT_GLYPHPOS { 205 struct FXTEXT_GLYPHPOS {
221 const CFX_GlyphBitmap* m_pGlyph; 206 const CFX_GlyphBitmap* m_pGlyph;
222 int m_OriginX; 207 int m_OriginX;
223 int m_OriginY; 208 int m_OriginY;
224 FX_FLOAT m_fOriginX; 209 FX_FLOAT m_fOriginX;
225 FX_FLOAT m_fOriginY; 210 FX_FLOAT m_fOriginY;
226 }; 211 };
227 212
228 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, 213 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs,
229 int anti_alias, 214 int anti_alias,
230 FX_FLOAT retinaScaleX = 1.0f, 215 FX_FLOAT retinaScaleX = 1.0f,
231 FX_FLOAT retinaScaleY = 1.0f); 216 FX_FLOAT retinaScaleY = 1.0f);
232 217
233 CFX_ByteString GetNameFromTT(const uint8_t* name_table, 218 CFX_ByteString GetNameFromTT(const uint8_t* name_table,
234 uint32_t name_table_size, 219 uint32_t name_table_size,
235 uint32_t name); 220 uint32_t name);
236 221
237 int PDF_GetStandardFontName(CFX_ByteString* name); 222 int PDF_GetStandardFontName(CFX_ByteString* name);
238 223
239 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_ 224 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_
OLDNEW
« no previous file with comments | « core/fxge/include/cfx_renderdevice.h ('k') | core/fxge/include/ifx_renderdevicedriver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698