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

Side by Side Diff: fpdfsdk/src/fpdf_sysfontinfo.cpp

Issue 1520063002: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@bstr_isnull
Patch Set: rebase Created 5 years 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 | « fpdfsdk/src/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fpdf_transformpage.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 "public/fpdf_sysfontinfo.h" 7 #include "public/fpdf_sysfontinfo.h"
8 8
9 #include "fpdfsdk/include/fsdk_define.h" 9 #include "fpdfsdk/include/fsdk_define.h"
10 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" 10 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 FX_DWORD GetFontData(void* hFont, 48 FX_DWORD GetFontData(void* hFont,
49 FX_DWORD table, 49 FX_DWORD table,
50 uint8_t* buffer, 50 uint8_t* buffer,
51 FX_DWORD size) override { 51 FX_DWORD size) override {
52 if (m_pInfo->GetFontData) 52 if (m_pInfo->GetFontData)
53 return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size); 53 return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size);
54 return 0; 54 return 0;
55 } 55 }
56 56
57 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override { 57 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override {
58 if (m_pInfo->GetFaceName == NULL) 58 if (!m_pInfo->GetFaceName)
59 return FALSE; 59 return FALSE;
60 FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0); 60 FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0);
61 if (size == 0) 61 if (size == 0)
62 return FALSE; 62 return FALSE;
63 char* buffer = FX_Alloc(char, size); 63 char* buffer = FX_Alloc(char, size);
64 size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size); 64 size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size);
65 name = CFX_ByteString(buffer, size); 65 name = CFX_ByteString(buffer, size);
66 FX_Free(buffer); 66 FX_Free(buffer);
67 return TRUE; 67 return TRUE;
68 } 68 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return 0; 163 return 0;
164 return charset; 164 return charset;
165 } 165 }
166 166
167 static void DefaultDeleteFont(struct _FPDF_SYSFONTINFO* pThis, void* hFont) { 167 static void DefaultDeleteFont(struct _FPDF_SYSFONTINFO* pThis, void* hFont) {
168 ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->DeleteFont(hFont); 168 ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->DeleteFont(hFont);
169 } 169 }
170 170
171 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo() { 171 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo() {
172 IFX_SystemFontInfo* pFontInfo = IFX_SystemFontInfo::CreateDefault(nullptr); 172 IFX_SystemFontInfo* pFontInfo = IFX_SystemFontInfo::CreateDefault(nullptr);
173 if (pFontInfo == NULL) 173 if (!pFontInfo)
174 return NULL; 174 return NULL;
175 175
176 FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt = 176 FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt =
177 FX_Alloc(FPDF_SYSFONTINFO_DEFAULT, 1); 177 FX_Alloc(FPDF_SYSFONTINFO_DEFAULT, 1);
178 pFontInfoExt->DeleteFont = DefaultDeleteFont; 178 pFontInfoExt->DeleteFont = DefaultDeleteFont;
179 pFontInfoExt->EnumFonts = DefaultEnumFonts; 179 pFontInfoExt->EnumFonts = DefaultEnumFonts;
180 pFontInfoExt->GetFaceName = DefaultGetFaceName; 180 pFontInfoExt->GetFaceName = DefaultGetFaceName;
181 pFontInfoExt->GetFont = DefaultGetFont; 181 pFontInfoExt->GetFont = DefaultGetFont;
182 pFontInfoExt->GetFontCharset = DefaultGetFontCharset; 182 pFontInfoExt->GetFontCharset = DefaultGetFontCharset;
183 pFontInfoExt->GetFontData = DefaultGetFontData; 183 pFontInfoExt->GetFontData = DefaultGetFontData;
184 pFontInfoExt->MapFont = DefaultMapFont; 184 pFontInfoExt->MapFont = DefaultMapFont;
185 pFontInfoExt->Release = DefaultRelease; 185 pFontInfoExt->Release = DefaultRelease;
186 pFontInfoExt->version = 1; 186 pFontInfoExt->version = 1;
187 pFontInfoExt->m_pFontInfo = pFontInfo; 187 pFontInfoExt->m_pFontInfo = pFontInfo;
188 return pFontInfoExt; 188 return pFontInfoExt;
189 } 189 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdf_dataavail.cpp ('k') | fpdfsdk/src/fpdf_transformpage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698