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

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

Issue 1239313005: Merge to XFA - else after returns. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix issues. Created 5 years, 5 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_device.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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 return psName; 339 return psName;
340 } 340 }
341 CFX_ByteString CFX_Font::GetFamilyName() const 341 CFX_ByteString CFX_Font::GetFamilyName() const
342 { 342 {
343 if (m_Face == NULL && m_pSubstFont == NULL) { 343 if (m_Face == NULL && m_pSubstFont == NULL) {
344 return CFX_ByteString(); 344 return CFX_ByteString();
345 } 345 }
346 if (m_Face) { 346 if (m_Face) {
347 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); 347 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
348 } else {
349 return m_pSubstFont->m_Family;
350 } 348 }
349 return m_pSubstFont->m_Family;
351 } 350 }
352 CFX_ByteString CFX_Font::GetFaceName() const 351 CFX_ByteString CFX_Font::GetFaceName() const
353 { 352 {
354 if (m_Face == NULL && m_pSubstFont == NULL) { 353 if (m_Face == NULL && m_pSubstFont == NULL) {
355 return CFX_ByteString(); 354 return CFX_ByteString();
356 } 355 }
357 if (m_Face) { 356 if (m_Face) {
358 CFX_ByteString facename; 357 CFX_ByteString facename;
359 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); 358 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face));
360 facename = GetFamilyName(); 359 facename = GetFamilyName();
361 if (facename.IsEmpty()) { 360 if (facename.IsEmpty()) {
362 facename = "Untitled"; 361 facename = "Untitled";
363 } 362 }
364 if (!style.IsEmpty() && style != "Regular") { 363 if (!style.IsEmpty() && style != "Regular") {
365 facename += " " + style; 364 facename += " " + style;
366 } 365 }
367 return facename; 366 return facename;
368 } else {
369 return m_pSubstFont->m_Family;
370 } 367 }
368 return m_pSubstFont->m_Family;
371 } 369 }
372 FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) 370 FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox)
373 { 371 {
374 if (m_Face == NULL) { 372 if (m_Face == NULL) {
375 return FALSE; 373 return FALSE;
376 } 374 }
377 int em = FXFT_Get_Face_UnitsPerEM(m_Face); 375 int em = FXFT_Get_Face_UnitsPerEM(m_Face);
378 if (em == 0) { 376 if (em == 0) {
379 bbox.left = FXFT_Get_Face_xMin(m_Face); 377 bbox.left = FXFT_Get_Face_xMin(m_Face);
380 bbox.bottom = FXFT_Get_Face_yMax(m_Face); 378 bbox.bottom = FXFT_Get_Face_yMax(m_Face);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 index = FXFT_Get_Char_Index(face, charcode); 437 index = FXFT_Get_Char_Index(face, charcode);
440 } 438 }
441 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) { 439 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) {
442 return FXFT_Get_Char_Index(face, charcode); 440 return FXFT_Get_Char_Index(face, charcode);
443 } 441 }
444 } 442 }
445 return charcode; 443 return charcode;
446 } 444 }
447 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encodin g) 445 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encodin g)
448 { 446 {
449 FXFT_Face face = m_pFont->GetFace(); 447 FXFT_Face face = m_pFont->GetFace();
450 if (!face) { 448 if (!face) {
451 return charcode; 449 return charcode;
452 } 450 }
453 if (encoding == ENCODING_UNICODE) { 451 if (encoding == ENCODING_UNICODE) {
454 return» GlyphFromCharCode(charcode); 452 return GlyphFromCharCode(charcode);
455 } else { 453 }
456 int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); 454 int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face);
457 int i = 0; 455 int i = 0;
458 while (i < nmaps) { 456 while (i < nmaps) {
459 int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face )[i++]); 457 int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i+ +]);
460 if (encoding != FXFT_ENCODING_UNICODE) { 458 if (encoding != FXFT_ENCODING_UNICODE) {
461 FXFT_Select_Charmap(face, encoding); 459 FXFT_Select_Charmap(face, encoding);
462 break; 460 break;
463 }
464 } 461 }
465 } 462 }
466 return FXFT_Get_Char_Index(face, charcode); 463 return FXFT_Get_Char_Index(face, charcode);
467 } 464 }
468 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) 465 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont)
469 { 466 {
470 CFX_UnicodeEncoding* pEncoding = NULL; 467 CFX_UnicodeEncoding* pEncoding = NULL;
471 pEncoding = FX_NEW CFX_UnicodeEncoding(pFont); 468 pEncoding = FX_NEW CFX_UnicodeEncoding(pFont);
472 return pEncoding; 469 return pEncoding;
473 } 470 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 626 }
630 static int s_count = sizeof(gs_EncodingID) / sizeof(FX_DWORD); 627 static int s_count = sizeof(gs_EncodingID) / sizeof(FX_DWORD);
631 for (int i = 0; i < s_count; i++) { 628 for (int i = 0; i < s_count; i++) {
632 IFX_FontEncodingEx* pFontEncoding = _FXFM_CreateFontEncoding(pFont, gs_E ncodingID[i]); 629 IFX_FontEncodingEx* pFontEncoding = _FXFM_CreateFontEncoding(pFont, gs_E ncodingID[i]);
633 if (pFontEncoding) { 630 if (pFontEncoding) {
634 return pFontEncoding; 631 return pFontEncoding;
635 } 632 }
636 } 633 }
637 return NULL; 634 return NULL;
638 } 635 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_device.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