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 #include "core/fxge/include/fx_font.h" | 7 #include "core/fxge/include/fx_font.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fxge/ge/fx_text_int.h" | 10 #include "core/fxge/ge/fx_text_int.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 22, 24, 26, 28, 30, 32, 33, 35, 37, 39, 41, 43, 45, 48, 48, 48, 48, | 213 22, 24, 26, 28, 30, 32, 33, 35, 37, 39, 41, 43, 45, 48, 48, 48, 48, |
214 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, | 214 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, |
215 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, | 215 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 56, 56, 56, |
216 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, | 216 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, |
217 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, | 217 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, |
218 }; | 218 }; |
219 | 219 |
220 CFX_Font::CFX_Font() | 220 CFX_Font::CFX_Font() |
221 : | 221 : |
222 #ifdef PDF_ENABLE_XFA | 222 #ifdef PDF_ENABLE_XFA |
223 m_bLogic(FALSE), | 223 m_bShallowCopy(false), |
224 m_pOwnedStream(nullptr), | 224 m_pOwnedStream(nullptr), |
225 #endif // PDF_ENABLE_XFA | 225 #endif // PDF_ENABLE_XFA |
226 m_Face(nullptr), | 226 m_Face(nullptr), |
227 m_pFontData(nullptr), | 227 m_pFontData(nullptr), |
228 m_pGsubData(nullptr), | 228 m_pGsubData(nullptr), |
229 m_dwSize(0), | 229 m_dwSize(0), |
230 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 230 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
231 m_pPlatformFont(nullptr), | 231 m_pPlatformFont(nullptr), |
232 #endif | 232 #endif |
233 m_bEmbedded(FALSE), | 233 m_bEmbedded(FALSE), |
234 m_bVertical(FALSE) { | 234 m_bVertical(FALSE) { |
235 } | 235 } |
236 | 236 |
237 #ifdef PDF_ENABLE_XFA | 237 #ifdef PDF_ENABLE_XFA |
238 FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) { | 238 FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) { |
239 if (!pFont) | 239 if (!pFont) |
240 return FALSE; | 240 return FALSE; |
241 | 241 |
242 m_bLogic = TRUE; | 242 m_bShallowCopy = true; |
243 if (pFont->m_pSubstFont) { | 243 if (pFont->m_pSubstFont) { |
244 m_pSubstFont.reset(new CFX_SubstFont); | 244 m_pSubstFont.reset(new CFX_SubstFont); |
245 m_pSubstFont->m_Charset = pFont->m_pSubstFont->m_Charset; | 245 m_pSubstFont->m_Charset = pFont->m_pSubstFont->m_Charset; |
246 m_pSubstFont->m_SubstFlags = pFont->m_pSubstFont->m_SubstFlags; | 246 m_pSubstFont->m_SubstFlags = pFont->m_pSubstFont->m_SubstFlags; |
247 m_pSubstFont->m_Weight = pFont->m_pSubstFont->m_Weight; | 247 m_pSubstFont->m_Weight = pFont->m_pSubstFont->m_Weight; |
248 m_pSubstFont->m_Family = pFont->m_pSubstFont->m_Family; | 248 m_pSubstFont->m_Family = pFont->m_pSubstFont->m_Family; |
249 m_pSubstFont->m_ItalicAngle = pFont->m_pSubstFont->m_ItalicAngle; | 249 m_pSubstFont->m_ItalicAngle = pFont->m_pSubstFont->m_ItalicAngle; |
250 } | 250 } |
251 if (pFont->m_OtfFontData.GetSize()) { | 251 if (pFont->m_OtfFontData.GetSize()) { |
252 m_OtfFontData.AttachData(pFont->m_OtfFontData.GetBuffer(), | 252 m_OtfFontData.AttachData(pFont->m_OtfFontData.GetBuffer(), |
253 pFont->m_OtfFontData.GetSize()); | 253 pFont->m_OtfFontData.GetSize()); |
254 } | 254 } |
255 m_Face = pFont->m_Face; | 255 m_Face = pFont->m_Face; |
256 m_bEmbedded = pFont->m_bEmbedded; | 256 m_bEmbedded = pFont->m_bEmbedded; |
257 m_bVertical = pFont->m_bVertical; | 257 m_bVertical = pFont->m_bVertical; |
258 m_dwSize = pFont->m_dwSize; | 258 m_dwSize = pFont->m_dwSize; |
259 m_pFontData = pFont->m_pFontData; | 259 m_pFontData = pFont->m_pFontData; |
260 m_pGsubData = pFont->m_pGsubData; | 260 m_pGsubData = pFont->m_pGsubData; |
261 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 261 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
262 m_pPlatformFont = pFont->m_pPlatformFont; | 262 m_pPlatformFont = pFont->m_pPlatformFont; |
263 #endif | 263 #endif |
264 m_pOwnedStream = pFont->m_pOwnedStream; | 264 m_pOwnedStream = pFont->m_pOwnedStream; |
265 return TRUE; | 265 return TRUE; |
266 } | 266 } |
267 #endif // PDF_ENABLE_XFA | 267 #endif // PDF_ENABLE_XFA |
268 | 268 |
269 CFX_Font::~CFX_Font() { | 269 CFX_Font::~CFX_Font() { |
270 #ifdef PDF_ENABLE_XFA | 270 #ifdef PDF_ENABLE_XFA |
271 if (m_bLogic) { | 271 if (m_bShallowCopy) { |
272 m_OtfFontData.DetachBuffer(); | 272 m_OtfFontData.DetachBuffer(); |
273 return; | 273 return; |
274 } | 274 } |
275 #endif // PDF_ENABLE_XFA | 275 #endif // PDF_ENABLE_XFA |
276 if (m_Face) { | 276 if (m_Face) { |
277 #ifndef PDF_ENABLE_XFA | 277 #ifndef PDF_ENABLE_XFA |
278 if (FXFT_Get_Face_External_Stream(m_Face)) { | 278 if (FXFT_Get_Face_External_Stream(m_Face)) { |
279 FXFT_Clear_Face_External_Stream(m_Face); | 279 FXFT_Clear_Face_External_Stream(m_Face); |
280 } | 280 } |
281 #endif // PDF_ENABLE_XFA | 281 #endif // PDF_ENABLE_XFA |
282 if (m_bEmbedded) | 282 if (m_bEmbedded) |
283 DeleteFace(); | 283 DeleteFace(); |
284 else | 284 else |
285 CFX_GEModule::Get()->GetFontMgr()->ReleaseFace(m_Face); | 285 CFX_GEModule::Get()->GetFontMgr()->ReleaseFace(m_Face); |
286 } | 286 } |
287 #ifdef PDF_ENABLE_XFA | 287 #ifdef PDF_ENABLE_XFA |
288 FX_Free(m_pOwnedStream); | 288 delete m_pOwnedStream; |
289 #endif // PDF_ENABLE_XFA | 289 #endif // PDF_ENABLE_XFA |
290 FX_Free(m_pGsubData); | 290 FX_Free(m_pGsubData); |
291 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && !defined _SKIA_SUPPORT_ | 291 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ && !defined _SKIA_SUPPORT_ |
292 ReleasePlatformResource(); | 292 ReleasePlatformResource(); |
293 #endif | 293 #endif |
294 } | 294 } |
295 | 295 |
296 void CFX_Font::DeleteFace() { | 296 void CFX_Font::DeleteFace() { |
297 FXFT_Done_Face(m_Face); | 297 FXFT_Done_Face(m_Face); |
298 m_Face = nullptr; | 298 m_Face = nullptr; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 params.m_pPoints = pPath->GetPoints(); | 658 params.m_pPoints = pPath->GetPoints(); |
659 params.m_CurX = params.m_CurY = 0; | 659 params.m_CurX = params.m_CurY = 0; |
660 params.m_CoordUnit = 64 * 64.0; | 660 params.m_CoordUnit = 64 * 64.0; |
661 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); | 661 FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); |
662 Outline_CheckEmptyContour(¶ms); | 662 Outline_CheckEmptyContour(¶ms); |
663 pPath->TrimPoints(params.m_PointCount); | 663 pPath->TrimPoints(params.m_PointCount); |
664 if (params.m_PointCount) | 664 if (params.m_PointCount) |
665 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; | 665 pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE; |
666 return pPath; | 666 return pPath; |
667 } | 667 } |
OLD | NEW |