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 "xfa/fgas/font/fgas_gefont.h" | 7 #include "xfa/fgas/font/fgas_gefont.h" |
8 | 8 |
9 #include "xfa/fgas/crt/fgas_codepage.h" | 9 #include "xfa/fgas/crt/fgas_codepage.h" |
10 #include "xfa/fgas/font/fgas_fontutils.h" | 10 #include "xfa/fgas/font/fgas_fontutils.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 212 } |
213 | 213 |
214 FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, | 214 FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, |
215 FX_BOOL bSaveStream) { | 215 FX_BOOL bSaveStream) { |
216 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) { | 216 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) { |
217 return FALSE; | 217 return FALSE; |
218 } | 218 } |
219 if (bSaveStream) { | 219 if (bSaveStream) { |
220 m_pStream = pFontStream; | 220 m_pStream = pFontStream; |
221 } | 221 } |
222 m_pFileRead = FX_CreateFileRead(pFontStream); | 222 m_pFileRead = FX_CreateFileRead(pFontStream, FALSE); |
223 m_pFont = new CFX_Font; | 223 m_pFont = new CFX_Font; |
224 FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead); | 224 FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead); |
225 if (bRet) { | 225 if (bRet) { |
226 bRet = InitFont(); | 226 bRet = InitFont(); |
227 } else { | 227 } else { |
228 m_pFileRead->Release(); | 228 m_pFileRead->Release(); |
229 m_pFileRead = nullptr; | 229 m_pFileRead = nullptr; |
230 } | 230 } |
231 return bRet; | 231 return bRet; |
232 } | 232 } |
(...skipping 10 matching lines...) Expand all Loading... |
243 | 243 |
244 FX_BOOL CFGAS_GEFont::InitFont() { | 244 FX_BOOL CFGAS_GEFont::InitFont() { |
245 if (!m_pFont) | 245 if (!m_pFont) |
246 return FALSE; | 246 return FALSE; |
247 if (!m_pFontEncoding) { | 247 if (!m_pFontEncoding) { |
248 m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont); | 248 m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont); |
249 if (!m_pFontEncoding) | 249 if (!m_pFontEncoding) |
250 return FALSE; | 250 return FALSE; |
251 } | 251 } |
252 if (!m_pCharWidthMap) | 252 if (!m_pCharWidthMap) |
253 m_pCharWidthMap = new CFX_WordDiscreteArray(1024); | 253 m_pCharWidthMap = new CFX_DiscreteArrayTemplate<uint16_t>(1024); |
254 if (!m_pRectArray) | 254 if (!m_pRectArray) |
255 m_pRectArray = new CFX_MassArrayTemplate<CFX_Rect>(16); | 255 m_pRectArray = new CFX_MassArrayTemplate<CFX_Rect>(16); |
256 if (!m_pBBoxMap) | 256 if (!m_pBBoxMap) |
257 m_pBBoxMap = new CFX_MapPtrToPtr(16); | 257 m_pBBoxMap = new CFX_MapPtrToPtr(16); |
258 | 258 |
259 return TRUE; | 259 return TRUE; |
260 } | 260 } |
261 | 261 |
262 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { | 262 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { |
263 if (GetFontStyles() == dwFontStyles) | 263 if (GetFontStyles() == dwFontStyles) |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 void CFGAS_GEFont::Reset() { | 466 void CFGAS_GEFont::Reset() { |
467 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) | 467 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) |
468 m_SubstFonts[i]->Reset(); | 468 m_SubstFonts[i]->Reset(); |
469 if (m_pCharWidthMap) { | 469 if (m_pCharWidthMap) { |
470 m_pCharWidthMap->RemoveAll(); | 470 m_pCharWidthMap->RemoveAll(); |
471 } | 471 } |
472 if (m_pBBoxMap) { | 472 if (m_pBBoxMap) { |
473 m_pBBoxMap->RemoveAll(); | 473 m_pBBoxMap->RemoveAll(); |
474 } | 474 } |
475 if (m_pRectArray) { | 475 if (m_pRectArray) { |
476 m_pRectArray->RemoveAll(); | 476 m_pRectArray->RemoveAll(FALSE); |
477 } | 477 } |
478 } | 478 } |
479 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 479 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
480 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; | 480 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; |
481 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 481 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
482 : m_SubstFonts[iGlyphIndex - 1]; | 482 : m_SubstFonts[iGlyphIndex - 1]; |
483 } | 483 } |
OLD | NEW |