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 "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 Loading... |
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 Loading... |
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 } |
OLD | NEW |