OLD | NEW |
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 <map> | 10 #include <map> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 #define CHARSET_FLAG_SYMBOL 2 | 67 #define CHARSET_FLAG_SYMBOL 2 |
68 #define CHARSET_FLAG_SHIFTJIS 4 | 68 #define CHARSET_FLAG_SHIFTJIS 4 |
69 #define CHARSET_FLAG_BIG5 8 | 69 #define CHARSET_FLAG_BIG5 8 |
70 #define CHARSET_FLAG_GB 16 | 70 #define CHARSET_FLAG_GB 16 |
71 #define CHARSET_FLAG_KOREAN 32 | 71 #define CHARSET_FLAG_KOREAN 32 |
72 | 72 |
73 #define GET_TT_SHORT(w) (uint16_t)(((w)[0] << 8) | (w)[1]) | 73 #define GET_TT_SHORT(w) (uint16_t)(((w)[0] << 8) | (w)[1]) |
74 #define GET_TT_LONG(w) \ | 74 #define GET_TT_LONG(w) \ |
75 (uint32_t)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) | 75 (uint32_t)(((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3]) |
76 | 76 |
| 77 // Sets the given transform on the font, and resets it to the identity when it |
| 78 // goes out of scope. |
| 79 class ScopedFontTransform { |
| 80 public: |
| 81 ScopedFontTransform(FT_Face face, FXFT_Matrix* matrix); |
| 82 ~ScopedFontTransform(); |
| 83 |
| 84 private: |
| 85 FT_Face m_Face; |
| 86 }; |
| 87 |
77 class CFX_Font { | 88 class CFX_Font { |
78 public: | 89 public: |
79 CFX_Font(); | 90 CFX_Font(); |
80 ~CFX_Font(); | 91 ~CFX_Font(); |
81 | 92 |
82 void LoadSubst(const CFX_ByteString& face_name, | 93 void LoadSubst(const CFX_ByteString& face_name, |
83 FX_BOOL bTrueType, | 94 FX_BOOL bTrueType, |
84 uint32_t flags, | 95 uint32_t flags, |
85 int weight, | 96 int weight, |
86 int italic_angle, | 97 int italic_angle, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 uint8_t* GetSubData() const { return m_pGsubData; } | 136 uint8_t* GetSubData() const { return m_pGsubData; } |
126 void SetSubData(uint8_t* data) { m_pGsubData = data; } | 137 void SetSubData(uint8_t* data) { m_pGsubData = data; } |
127 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 138 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
128 void* GetPlatformFont() const { return m_pPlatformFont; } | 139 void* GetPlatformFont() const { return m_pPlatformFont; } |
129 void SetPlatformFont(void* font) { m_pPlatformFont = font; } | 140 void SetPlatformFont(void* font) { m_pPlatformFont = font; } |
130 #endif | 141 #endif |
131 uint8_t* GetFontData() const { return m_pFontData; } | 142 uint8_t* GetFontData() const { return m_pFontData; } |
132 uint32_t GetSize() const { return m_dwSize; } | 143 uint32_t GetSize() const { return m_dwSize; } |
133 void AdjustMMParams(int glyph_index, int width, int weight); | 144 void AdjustMMParams(int glyph_index, int width, int weight); |
134 | 145 |
| 146 static const size_t kAngleSkewArraySize = 30; |
| 147 static const char s_AngleSkew[kAngleSkewArraySize]; |
| 148 static const size_t kWeightPowArraySize = 100; |
| 149 static const uint8_t s_WeightPow[kWeightPowArraySize]; |
| 150 static const uint8_t s_WeightPow_11[kWeightPowArraySize]; |
| 151 static const uint8_t s_WeightPow_SHIFTJIS[kWeightPowArraySize]; |
| 152 |
135 #ifdef PDF_ENABLE_XFA | 153 #ifdef PDF_ENABLE_XFA |
136 protected: | 154 protected: |
137 CFX_BinaryBuf m_OtfFontData; | 155 CFX_BinaryBuf m_OtfFontData; |
138 FX_BOOL m_bLogic; | 156 FX_BOOL m_bLogic; |
139 void* m_pOwnedStream; | 157 void* m_pOwnedStream; |
140 #endif // PDF_ENABLE_XFA | 158 #endif // PDF_ENABLE_XFA |
141 | 159 |
142 private: | 160 private: |
143 void ReleasePlatformResource(); | 161 void ReleasePlatformResource(); |
144 void DeleteFace(); | 162 void DeleteFace(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 uint32_t m_nCount; | 254 uint32_t m_nCount; |
237 }; | 255 }; |
238 | 256 |
239 class CFX_GlyphBitmap { | 257 class CFX_GlyphBitmap { |
240 public: | 258 public: |
241 int m_Top; | 259 int m_Top; |
242 int m_Left; | 260 int m_Left; |
243 CFX_DIBitmap m_Bitmap; | 261 CFX_DIBitmap m_Bitmap; |
244 }; | 262 }; |
245 | 263 |
246 class CFX_FaceCache { | |
247 public: | |
248 explicit CFX_FaceCache(FXFT_Face face); | |
249 ~CFX_FaceCache(); | |
250 const CFX_GlyphBitmap* LoadGlyphBitmap(CFX_Font* pFont, | |
251 uint32_t glyph_index, | |
252 FX_BOOL bFontStyle, | |
253 const CFX_Matrix* pMatrix, | |
254 int dest_width, | |
255 int anti_alias, | |
256 int& text_flags); | |
257 const CFX_PathData* LoadGlyphPath(CFX_Font* pFont, | |
258 uint32_t glyph_index, | |
259 int dest_width); | |
260 | |
261 #ifdef _SKIA_SUPPORT_ | |
262 CFX_TypeFace* GetDeviceCache(CFX_Font* pFont); | |
263 #endif | |
264 | |
265 private: | |
266 CFX_GlyphBitmap* RenderGlyph(CFX_Font* pFont, | |
267 uint32_t glyph_index, | |
268 FX_BOOL bFontStyle, | |
269 const CFX_Matrix* pMatrix, | |
270 int dest_width, | |
271 int anti_alias); | |
272 CFX_GlyphBitmap* RenderGlyph_Nativetext(CFX_Font* pFont, | |
273 uint32_t glyph_index, | |
274 const CFX_Matrix* pMatrix, | |
275 int dest_width, | |
276 int anti_alias); | |
277 CFX_GlyphBitmap* LookUpGlyphBitmap(CFX_Font* pFont, | |
278 const CFX_Matrix* pMatrix, | |
279 const CFX_ByteString& FaceGlyphsKey, | |
280 uint32_t glyph_index, | |
281 FX_BOOL bFontStyle, | |
282 int dest_width, | |
283 int anti_alias); | |
284 void InitPlatform(); | |
285 void DestroyPlatform(); | |
286 | |
287 FXFT_Face const m_Face; | |
288 std::map<CFX_ByteString, CFX_SizeGlyphCache*> m_SizeMap; | |
289 std::map<uint32_t, CFX_PathData*> m_PathMap; | |
290 CFX_DIBitmap* m_pBitmap; | |
291 #ifdef _SKIA_SUPPORT_ | |
292 CFX_TypeFace* m_pTypeface; | |
293 #endif | |
294 }; | |
295 | |
296 struct FXTEXT_GLYPHPOS { | 264 struct FXTEXT_GLYPHPOS { |
297 const CFX_GlyphBitmap* m_pGlyph; | 265 const CFX_GlyphBitmap* m_pGlyph; |
298 int m_OriginX; | 266 int m_OriginX; |
299 int m_OriginY; | 267 int m_OriginY; |
300 FX_FLOAT m_fOriginX; | 268 FX_FLOAT m_fOriginX; |
301 FX_FLOAT m_fOriginY; | 269 FX_FLOAT m_fOriginY; |
302 }; | 270 }; |
303 | 271 |
304 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, | 272 FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, |
305 int anti_alias, | 273 int anti_alias, |
306 FX_FLOAT retinaScaleX = 1.0f, | 274 FX_FLOAT retinaScaleX = 1.0f, |
307 FX_FLOAT retinaScaleY = 1.0f); | 275 FX_FLOAT retinaScaleY = 1.0f); |
308 | 276 |
309 CFX_ByteString GetNameFromTT(const uint8_t* name_table, | 277 CFX_ByteString GetNameFromTT(const uint8_t* name_table, |
310 uint32_t name_table_size, | 278 uint32_t name_table_size, |
311 uint32_t name); | 279 uint32_t name); |
312 | 280 |
313 int PDF_GetStandardFontName(CFX_ByteString* name); | 281 int PDF_GetStandardFontName(CFX_ByteString* name); |
314 | 282 |
315 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_ | 283 #endif // CORE_FXGE_INCLUDE_FX_FONT_H_ |
OLD | NEW |