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

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

Issue 1528763003: Merge to XFA: Get rid of most instance of 'foo == NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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
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 "core/include/fxge/fx_freetype.h" 7 #include "core/include/fxge/fx_freetype.h"
8 #include "core/include/fxge/fx_ge.h" 8 #include "core/include/fxge/fx_ge.h"
9 #include "text_int.h" 9 #include "text_int.h"
10 10
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD; 366 return FXFT_Is_Face_Bold(m_Face) == FXFT_STYLE_FLAG_BOLD;
367 } 367 }
368 368
369 FX_BOOL CFX_Font::IsFixedWidth() const { 369 FX_BOOL CFX_Font::IsFixedWidth() const {
370 if (!m_Face) 370 if (!m_Face)
371 return FALSE; 371 return FALSE;
372 return FXFT_Is_Face_fixedwidth(m_Face); 372 return FXFT_Is_Face_fixedwidth(m_Face);
373 } 373 }
374 374
375 CFX_WideString CFX_Font::GetPsName() const { 375 CFX_WideString CFX_Font::GetPsName() const {
376 if (m_Face == NULL) { 376 if (!m_Face) {
377 return CFX_WideString(); 377 return CFX_WideString();
378 } 378 }
379 CFX_WideString psName = 379 CFX_WideString psName =
380 CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face)); 380 CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face));
381 if (psName.IsEmpty()) { 381 if (psName.IsEmpty()) {
382 psName = CFX_WideString::FromLocal("Untitled"); 382 psName = CFX_WideString::FromLocal("Untitled");
383 } 383 }
384 return psName; 384 return psName;
385 } 385 }
386 CFX_ByteString CFX_Font::GetFamilyName() const { 386 CFX_ByteString CFX_Font::GetFamilyName() const {
387 if (m_Face == NULL && m_pSubstFont == NULL) { 387 if (!m_Face && !m_pSubstFont) {
388 return CFX_ByteString(); 388 return CFX_ByteString();
389 } 389 }
390 if (m_Face) { 390 if (m_Face) {
391 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); 391 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
392 } 392 }
393 return m_pSubstFont->m_Family; 393 return m_pSubstFont->m_Family;
394 } 394 }
395 CFX_ByteString CFX_Font::GetFaceName() const { 395 CFX_ByteString CFX_Font::GetFaceName() const {
396 if (m_Face == NULL && m_pSubstFont == NULL) { 396 if (!m_Face && !m_pSubstFont) {
397 return CFX_ByteString(); 397 return CFX_ByteString();
398 } 398 }
399 if (m_Face) { 399 if (m_Face) {
400 CFX_ByteString facename; 400 CFX_ByteString facename;
401 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); 401 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face));
402 facename = GetFamilyName(); 402 facename = GetFamilyName();
403 if (facename.IsEmpty()) { 403 if (facename.IsEmpty()) {
404 facename = "Untitled"; 404 facename = "Untitled";
405 } 405 }
406 if (!style.IsEmpty() && style != "Regular") { 406 if (!style.IsEmpty() && style != "Regular") {
407 facename += " " + style; 407 facename += " " + style;
408 } 408 }
409 return facename; 409 return facename;
410 } 410 }
411 return m_pSubstFont->m_Family; 411 return m_pSubstFont->m_Family;
412 } 412 }
413 FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) { 413 FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) {
414 if (m_Face == NULL) { 414 if (!m_Face) {
415 return FALSE; 415 return FALSE;
416 } 416 }
417 int em = FXFT_Get_Face_UnitsPerEM(m_Face); 417 int em = FXFT_Get_Face_UnitsPerEM(m_Face);
418 if (em == 0) { 418 if (em == 0) {
419 bbox.left = FXFT_Get_Face_xMin(m_Face); 419 bbox.left = FXFT_Get_Face_xMin(m_Face);
420 bbox.bottom = FXFT_Get_Face_yMax(m_Face); 420 bbox.bottom = FXFT_Get_Face_yMax(m_Face);
421 bbox.top = FXFT_Get_Face_yMin(m_Face); 421 bbox.top = FXFT_Get_Face_yMin(m_Face);
422 bbox.right = FXFT_Get_Face_xMax(m_Face); 422 bbox.right = FXFT_Get_Face_xMax(m_Face);
423 } else { 423 } else {
424 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em; 424 bbox.left = FXFT_Get_Face_xMin(m_Face) * 1000 / em;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) { 551 for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) {
552 CFX_UnicodeEncodingEx* pFontEncoding = 552 CFX_UnicodeEncodingEx* pFontEncoding =
553 _FXFM_CreateFontEncoding(pFont, g_EncodingID[i]); 553 _FXFM_CreateFontEncoding(pFont, g_EncodingID[i]);
554 if (pFontEncoding) { 554 if (pFontEncoding) {
555 return pFontEncoding; 555 return pFontEncoding;
556 } 556 }
557 } 557 }
558 return NULL; 558 return NULL;
559 } 559 }
560 #endif // PDF_ENABLE_XFA 560 #endif // PDF_ENABLE_XFA
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698