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

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

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 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/dib/fx_dib_main.cpp ('k') | core/src/fxge/ge/fx_ge_fontmap.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 EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) 10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em)
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 return 0; 98 return 0;
99 } 99 }
100 void _FTStreamClose(FXFT_Stream stream) 100 void _FTStreamClose(FXFT_Stream stream)
101 { 101 {
102 } 102 }
103 }; 103 };
104 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX FT_Stream* stream) 104 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FX FT_Stream* stream)
105 { 105 {
106 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec) ); 106 FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec) );
107 if (!stream1) {
108 return FALSE;
109 }
107 stream1->base = NULL; 110 stream1->base = NULL;
108 stream1->size = (unsigned long)pFile->GetSize(); 111 stream1->size = (unsigned long)pFile->GetSize();
109 stream1->pos = 0; 112 stream1->pos = 0;
110 stream1->descriptor.pointer = pFile; 113 stream1->descriptor.pointer = pFile;
111 stream1->close = _FTStreamClose; 114 stream1->close = _FTStreamClose;
112 stream1->read = _FTStreamRead; 115 stream1->read = _FTStreamRead;
113 FXFT_Open_Args args; 116 FXFT_Open_Args args;
114 args.flags = FT_OPEN_STREAM; 117 args.flags = FT_OPEN_STREAM;
115 args.stream = stream1; 118 args.stream = stream1;
116 if (FXFT_Open_Face(library, &args, 0, Face)) { 119 if (FXFT_Open_Face(library, &args, 0, Face)) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 170 }
168 error = FXFT_Set_Pixel_Sizes(face, 64, 64); 171 error = FXFT_Set_Pixel_Sizes(face, 64, 64);
169 if (error) { 172 if (error) {
170 return NULL; 173 return NULL;
171 } 174 }
172 return face; 175 return face;
173 } 176 }
174 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size) 177 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size)
175 { 178 {
176 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size); 179 m_pFontDataAllocation = FX_Alloc(FX_BYTE, size);
180 if (!m_pFontDataAllocation) {
181 return FALSE;
182 }
177 FXSYS_memcpy32(m_pFontDataAllocation, data, size); 183 FXSYS_memcpy32(m_pFontDataAllocation, data, size);
178 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size); 184 m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size);
179 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation; 185 m_pFontData = (FX_LPBYTE)m_pFontDataAllocation;
180 m_bEmbedded = TRUE; 186 m_bEmbedded = TRUE;
181 m_dwSize = size; 187 m_dwSize = size;
182 return m_Face != NULL; 188 return m_Face != NULL;
183 } 189 }
184 FX_BOOL CFX_Font::IsTTFont() 190 FX_BOOL CFX_Font::IsTTFont()
185 { 191 {
186 if (m_Face == NULL) { 192 if (m_Face == NULL) {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 break; 434 break;
429 } 435 }
430 } 436 }
431 } 437 }
432 return FXFT_Get_Char_Index(face, charcode); 438 return FXFT_Get_Char_Index(face, charcode);
433 } 439 }
434 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) 440 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont)
435 { 441 {
436 return new CFX_UnicodeEncoding(pFont); 442 return new CFX_UnicodeEncoding(pFont);
437 } 443 }
OLDNEW
« no previous file with comments | « core/src/fxge/dib/fx_dib_main.cpp ('k') | core/src/fxge/ge/fx_ge_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698