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

Side by Side Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1081443004: Remove checks in fxge/ge now that FX_NEW can't return 0. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix Typo. Created 5 years, 8 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/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('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 #include "../../../include/fxge/fx_ge.h" 7 #include "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxge/fx_freetype.h" 8 #include "../../../include/fxge/fx_freetype.h"
9 #include "text_int.h" 9 #include "text_int.h"
10 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1]) 10 #define GET_TT_SHORT(w) (FX_WORD)(((w)[0] << 8) | (w)[1])
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 m_RefCount --; 55 m_RefCount --;
56 if (m_RefCount) { 56 if (m_RefCount) {
57 return FALSE; 57 return FALSE;
58 } 58 }
59 delete this; 59 delete this;
60 return TRUE; 60 return TRUE;
61 } 61 }
62 CFX_FontMgr::CFX_FontMgr() 62 CFX_FontMgr::CFX_FontMgr()
63 { 63 {
64 m_pBuiltinMapper = FX_NEW CFX_FontMapper; 64 m_pBuiltinMapper = new CFX_FontMapper;
65 if (!m_pBuiltinMapper) {
66 return;
67 }
68 m_pBuiltinMapper->m_pFontMgr = this; 65 m_pBuiltinMapper->m_pFontMgr = this;
69 m_pExtMapper = NULL; 66 m_pExtMapper = NULL;
70 m_FTLibrary = NULL; 67 m_FTLibrary = NULL;
71 FXSYS_memset32(m_ExternalFonts, 0, sizeof m_ExternalFonts); 68 FXSYS_memset32(m_ExternalFonts, 0, sizeof m_ExternalFonts);
72 } 69 }
73 CFX_FontMgr::~CFX_FontMgr() 70 CFX_FontMgr::~CFX_FontMgr()
74 { 71 {
75 if (m_pBuiltinMapper) { 72 if (m_pBuiltinMapper) {
76 delete m_pBuiltinMapper; 73 delete m_pBuiltinMapper;
77 } 74 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if(pFontDesc) { 126 if(pFontDesc) {
130 pFontData = pFontDesc->m_pFontData; 127 pFontData = pFontDesc->m_pFontData;
131 pFontDesc->m_RefCount ++; 128 pFontDesc->m_RefCount ++;
132 return pFontDesc->m_SingleFace.m_pFace; 129 return pFontDesc->m_SingleFace.m_pFace;
133 } 130 }
134 return NULL; 131 return NULL;
135 } 132 }
136 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, 133 FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name,
137 int weight, FX_BOOL bItalic, FX_LPBYTE pDat a, FX_DWORD size, int face_index) 134 int weight, FX_BOOL bItalic, FX_LPBYTE pDat a, FX_DWORD size, int face_index)
138 { 135 {
139 CTTFontDesc* pFontDesc = FX_NEW CTTFontDesc; 136 CTTFontDesc* pFontDesc = new CTTFontDesc;
140 if (!pFontDesc) {
141 return NULL;
142 }
143 pFontDesc->m_Type = 1; 137 pFontDesc->m_Type = 1;
144 pFontDesc->m_SingleFace.m_pFace = NULL; 138 pFontDesc->m_SingleFace.m_pFace = NULL;
145 pFontDesc->m_SingleFace.m_bBold = weight; 139 pFontDesc->m_SingleFace.m_bBold = weight;
146 pFontDesc->m_SingleFace.m_bItalic = bItalic; 140 pFontDesc->m_SingleFace.m_bItalic = bItalic;
147 pFontDesc->m_pFontData = pData; 141 pFontDesc->m_pFontData = pData;
148 pFontDesc->m_RefCount = 1; 142 pFontDesc->m_RefCount = 1;
149 FXFT_Library library; 143 FXFT_Library library;
150 if (m_FTLibrary == NULL) { 144 if (m_FTLibrary == NULL) {
151 FXFT_Init_FreeType(&m_FTLibrary); 145 FXFT_Init_FreeType(&m_FTLibrary);
152 } 146 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 if (pFontDesc->m_TTCFace.m_pFaces[face_index] == NULL) { 324 if (pFontDesc->m_TTCFace.m_pFaces[face_index] == NULL) {
331 pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pF ontData, ttc_size, face_index); 325 pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pF ontData, ttc_size, face_index);
332 } 326 }
333 return pFontDesc->m_TTCFace.m_pFaces[face_index]; 327 return pFontDesc->m_TTCFace.m_pFaces[face_index];
334 } 328 }
335 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, FX_DWORD checksum, 329 FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, FX_DWORD checksum,
336 FX_LPBYTE pData, FX_DWORD size, int font _offset) 330 FX_LPBYTE pData, FX_DWORD size, int font _offset)
337 { 331 {
338 CFX_ByteString key; 332 CFX_ByteString key;
339 key.Format("%d:%d", ttc_size, checksum); 333 key.Format("%d:%d", ttc_size, checksum);
340 CTTFontDesc* pFontDesc = FX_NEW CTTFontDesc; 334 CTTFontDesc* pFontDesc = new CTTFontDesc;
341 if (!pFontDesc) {
342 return NULL;
343 }
344 pFontDesc->m_Type = 2; 335 pFontDesc->m_Type = 2;
345 pFontDesc->m_pFontData = pData; 336 pFontDesc->m_pFontData = pData;
346 for (int i = 0; i < 16; i ++) { 337 for (int i = 0; i < 16; i ++) {
347 pFontDesc->m_TTCFace.m_pFaces[i] = NULL; 338 pFontDesc->m_TTCFace.m_pFaces[i] = NULL;
348 } 339 }
349 pFontDesc->m_RefCount ++; 340 pFontDesc->m_RefCount ++;
350 key.Format("%d:%d", ttc_size, checksum); 341 key.Format("%d:%d", ttc_size, checksum);
351 m_FaceMap.SetAt(key, pFontDesc); 342 m_FaceMap.SetAt(key, pFontDesc);
352 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset); 343 int face_index = GetTTCIndex(pFontDesc->m_pFontData, ttc_size, font_offset);
353 pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pFontD ata, ttc_size, face_index); 344 pFontDesc->m_TTCFace.m_pFaces[face_index] = GetFixedFace(pFontDesc->m_pFontD ata, ttc_size, face_index);
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 CFX_ByteString names = _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616 d65); 1400 CFX_ByteString names = _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x6e616 d65);
1410 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1); 1401 CFX_ByteString facename = _FPDF_GetNameFromTT(names, 1);
1411 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2); 1402 CFX_ByteString style = _FPDF_GetNameFromTT(names, 2);
1412 if (style != "Regular") { 1403 if (style != "Regular") {
1413 facename += " " + style; 1404 facename += " " + style;
1414 } 1405 }
1415 FX_LPVOID p; 1406 FX_LPVOID p;
1416 if (m_FontList.Lookup(facename, p)) { 1407 if (m_FontList.Lookup(facename, p)) {
1417 return; 1408 return;
1418 } 1409 }
1419 CFontFaceInfo* pInfo = FX_NEW CFontFaceInfo; 1410 CFontFaceInfo* pInfo = new CFontFaceInfo;
1420 if (!pInfo) {
1421 return;
1422 }
1423 pInfo->m_FilePath = path; 1411 pInfo->m_FilePath = path;
1424 pInfo->m_FaceName = facename; 1412 pInfo->m_FaceName = facename;
1425 pInfo->m_FontTables = tables; 1413 pInfo->m_FontTables = tables;
1426 pInfo->m_FontOffset = offset; 1414 pInfo->m_FontOffset = offset;
1427 pInfo->m_FileSize = filesize; 1415 pInfo->m_FileSize = filesize;
1428 pInfo->m_Charsets = 0; 1416 pInfo->m_Charsets = 0;
1429 CFX_ByteString os2 = _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f3 2); 1417 CFX_ByteString os2 = _FPDF_LoadTableFromTT(pFile, tables, nTables, 0x4f532f3 2);
1430 if (os2.GetLength() >= 86) { 1418 if (os2.GetLength() >= 86) {
1431 FX_LPCBYTE p = (FX_LPCBYTE)os2 + 78; 1419 FX_LPCBYTE p = (FX_LPCBYTE)os2 + 78;
1432 FX_DWORD codepages = GET_TT_LONG(p); 1420 FX_DWORD codepages = GET_TT_LONG(p);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 return FALSE; 1514 return FALSE;
1527 } 1515 }
1528 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont; 1516 CFontFaceInfo* pFont = (CFontFaceInfo*)hFont;
1529 name = pFont->m_FaceName; 1517 name = pFont->m_FaceName;
1530 return TRUE; 1518 return TRUE;
1531 } 1519 }
1532 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset) 1520 FX_BOOL CFX_FolderFontInfo::GetFontCharset(void* hFont, int& charset)
1533 { 1521 {
1534 return FALSE; 1522 return FALSE;
1535 } 1523 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698