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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 #include "../../../include/fxge/fx_freetype.h" | 10 #include "../../../include/fxge/fx_freetype.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 pFontDesc->m_RefCount++; | 131 pFontDesc->m_RefCount++; |
132 return pFontDesc->m_SingleFace.m_pFace; | 132 return pFontDesc->m_SingleFace.m_pFace; |
133 } | 133 } |
134 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, | 134 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, |
135 int weight, | 135 int weight, |
136 FX_BOOL bItalic, | 136 FX_BOOL bItalic, |
137 uint8_t* pData, | 137 uint8_t* pData, |
138 FX_DWORD size, | 138 FX_DWORD size, |
139 int face_index) { | 139 int face_index) { |
140 CTTFontDesc* pFontDesc = new CTTFontDesc; | 140 CTTFontDesc* pFontDesc = new CTTFontDesc; |
141 if (!pFontDesc) { | |
142 return NULL; | |
143 } | |
144 pFontDesc->m_Type = 1; | 141 pFontDesc->m_Type = 1; |
145 pFontDesc->m_SingleFace.m_pFace = NULL; | 142 pFontDesc->m_SingleFace.m_pFace = NULL; |
146 pFontDesc->m_SingleFace.m_bBold = weight; | 143 pFontDesc->m_SingleFace.m_bBold = weight; |
147 pFontDesc->m_SingleFace.m_bItalic = bItalic; | 144 pFontDesc->m_SingleFace.m_bItalic = bItalic; |
148 pFontDesc->m_pFontData = pData; | 145 pFontDesc->m_pFontData = pData; |
149 pFontDesc->m_RefCount = 1; | 146 pFontDesc->m_RefCount = 1; |
150 FXFT_Library library; | 147 FXFT_Library library; |
151 if (m_FTLibrary == NULL) { | 148 if (m_FTLibrary == NULL) { |
152 FXFT_Init_FreeType(&m_FTLibrary); | 149 FXFT_Init_FreeType(&m_FTLibrary); |
153 } | 150 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); | 326 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); |
330 } | 327 } |
331 return pFontDesc->m_TTCFace.m_pFaces[face_index]; | 328 return pFontDesc->m_TTCFace.m_pFaces[face_index]; |
332 } | 329 } |
333 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, | 330 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, |
334 FX_DWORD checksum, | 331 FX_DWORD checksum, |
335 uint8_t* pData, | 332 uint8_t* pData, |
336 FX_DWORD size, | 333 FX_DWORD size, |
337 int font_offset) { | 334 int font_offset) { |
338 CTTFontDesc* pFontDesc = new CTTFontDesc; | 335 CTTFontDesc* pFontDesc = new CTTFontDesc; |
339 if (!pFontDesc) { | |
340 return NULL; | |
341 } | |
342 pFontDesc->m_Type = 2; | 336 pFontDesc->m_Type = 2; |
343 pFontDesc->m_pFontData = pData; | 337 pFontDesc->m_pFontData = pData; |
344 for (int i = 0; i < 16; i++) { | 338 for (int i = 0; i < 16; i++) { |
345 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; | 339 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; |
346 } | 340 } |
347 pFontDesc->m_RefCount++; | 341 pFontDesc->m_RefCount++; |
348 m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; | 342 m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; |
349 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); | 343 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); |
350 pFontDesc->m_TTCFace.m_pFaces[face_index] = | 344 pFontDesc->m_TTCFace.m_pFaces[face_index] = |
351 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); | 345 GetFixedFace(pFontDesc->m_pFontData, ttc_size, face_index); |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 if (hFont == NULL) { | 1662 if (hFont == NULL) { |
1669 return FALSE; | 1663 return FALSE; |
1670 } | 1664 } |
1671 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; | 1665 CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont; |
1672 name = pFont->m_FaceName; | 1666 name = pFont->m_FaceName; |
1673 return TRUE; | 1667 return TRUE; |
1674 } | 1668 } |
1675 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { | 1669 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) { |
1676 return FALSE; | 1670 return FALSE; |
1677 } | 1671 } |
OLD | NEW |