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

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

Issue 1800523005: Move core/src/ up to core/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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/fxge/ge/fx_ge_device.cpp ('k') | core/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 "core/fxge/ge/fx_text_int.h"
7 #include "core/include/fxge/fx_freetype.h" 8 #include "core/include/fxge/fx_freetype.h"
8 #include "core/include/fxge/fx_ge.h" 9 #include "core/include/fxge/fx_ge.h"
9 #include "core/src/fxge/ge/fx_text_int.h"
10 10
11 #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em) 11 #define EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
12 12
13 #ifdef PDF_ENABLE_XFA 13 #ifdef PDF_ENABLE_XFA
14 extern void _FPDFAPI_GetInternalFontData(int id1, 14 extern void _FPDFAPI_GetInternalFontData(int id1,
15 const uint8_t*& data, 15 const uint8_t*& data,
16 FX_DWORD& size); 16 FX_DWORD& size);
17 #endif // PDF_ENABLE_XFA 17 #endif // PDF_ENABLE_XFA
18 18
19 namespace { 19 namespace {
20 20
21 #ifdef PDF_ENABLE_XFA 21 #ifdef PDF_ENABLE_XFA
22 const FX_DWORD g_EncodingID[] = { 22 const FX_DWORD g_EncodingID[] = {
23 FXFM_ENCODING_MS_SYMBOL, 23 FXFM_ENCODING_MS_SYMBOL, FXFM_ENCODING_UNICODE,
24 FXFM_ENCODING_UNICODE, 24 FXFM_ENCODING_MS_SJIS, FXFM_ENCODING_MS_GB2312,
25 FXFM_ENCODING_MS_SJIS, 25 FXFM_ENCODING_MS_BIG5, FXFM_ENCODING_MS_WANSUNG,
26 FXFM_ENCODING_MS_GB2312, 26 FXFM_ENCODING_MS_JOHAB, FXFM_ENCODING_ADOBE_STANDARD,
27 FXFM_ENCODING_MS_BIG5, 27 FXFM_ENCODING_ADOBE_EXPERT, FXFM_ENCODING_ADOBE_CUSTOM,
28 FXFM_ENCODING_MS_WANSUNG, 28 FXFM_ENCODING_ADOBE_LATIN_1, FXFM_ENCODING_OLD_LATIN_2,
29 FXFM_ENCODING_MS_JOHAB, 29 FXFM_ENCODING_APPLE_ROMAN,
30 FXFM_ENCODING_ADOBE_STANDARD,
31 FXFM_ENCODING_ADOBE_EXPERT,
32 FXFM_ENCODING_ADOBE_CUSTOM,
33 FXFM_ENCODING_ADOBE_LATIN_1,
34 FXFM_ENCODING_OLD_LATIN_2,
35 FXFM_ENCODING_APPLE_ROMAN,
36 }; 30 };
37 31
38 CFX_UnicodeEncodingEx* _FXFM_CreateFontEncoding(CFX_Font* pFont, 32 CFX_UnicodeEncodingEx* _FXFM_CreateFontEncoding(CFX_Font* pFont,
39 FX_DWORD nEncodingID) { 33 FX_DWORD nEncodingID) {
40 if (FXFT_Select_Charmap(pFont->GetFace(), nEncodingID)) 34 if (FXFT_Select_Charmap(pFont->GetFace(), nEncodingID))
41 return nullptr; 35 return nullptr;
42 return new CFX_UnicodeEncodingEx(pFont, nEncodingID); 36 return new CFX_UnicodeEncodingEx(pFont, nEncodingID);
43 } 37 }
44 #endif // PDF_ENABLE_XFA 38 #endif // PDF_ENABLE_XFA
45 39
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } 443 }
450 444
451 int CFX_Font::GetULthickness() const { 445 int CFX_Font::GetULthickness() const {
452 if (!m_Face) 446 if (!m_Face)
453 return 0; 447 return 0;
454 448
455 return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 449 return EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
456 FXFT_Get_Face_UnderLineThickness(m_Face)); 450 FXFT_Get_Face_UnderLineThickness(m_Face));
457 } 451 }
458 452
459 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) { 453 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) {}
460 }
461 454
462 CFX_UnicodeEncoding::~CFX_UnicodeEncoding() { 455 CFX_UnicodeEncoding::~CFX_UnicodeEncoding() {}
463 }
464 456
465 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) { 457 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) {
466 FXFT_Face face = m_pFont->GetFace(); 458 FXFT_Face face = m_pFont->GetFace();
467 if (!face) 459 if (!face)
468 return charcode; 460 return charcode;
469 461
470 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) 462 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0)
471 return FXFT_Get_Char_Index(face, charcode); 463 return FXFT_Get_Char_Index(face, charcode);
472 464
473 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) { 465 if (m_pFont->GetSubstFont() && m_pFont->GetSubstFont()->m_Charset == 2) {
474 FX_DWORD index = 0; 466 FX_DWORD index = 0;
475 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) 467 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0)
476 index = FXFT_Get_Char_Index(face, charcode); 468 index = FXFT_Get_Char_Index(face, charcode);
477 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) 469 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN))
478 return FXFT_Get_Char_Index(face, charcode); 470 return FXFT_Get_Char_Index(face, charcode);
479 } 471 }
480 return charcode; 472 return charcode;
481 } 473 }
482 474
483 #ifdef PDF_ENABLE_XFA 475 #ifdef PDF_ENABLE_XFA
484 CFX_UnicodeEncodingEx::CFX_UnicodeEncodingEx(CFX_Font* pFont, 476 CFX_UnicodeEncodingEx::CFX_UnicodeEncodingEx(CFX_Font* pFont,
485 FX_DWORD EncodingID) 477 FX_DWORD EncodingID)
486 : CFX_UnicodeEncoding(pFont), m_nEncodingID(EncodingID) { 478 : CFX_UnicodeEncoding(pFont), m_nEncodingID(EncodingID) {}
487 }
488 479
489 CFX_UnicodeEncodingEx::~CFX_UnicodeEncodingEx() { 480 CFX_UnicodeEncodingEx::~CFX_UnicodeEncodingEx() {}
490 }
491 481
492 FX_DWORD CFX_UnicodeEncodingEx::GlyphFromCharCode(FX_DWORD charcode) { 482 FX_DWORD CFX_UnicodeEncodingEx::GlyphFromCharCode(FX_DWORD charcode) {
493 FXFT_Face face = m_pFont->GetFace(); 483 FXFT_Face face = m_pFont->GetFace();
494 FT_UInt nIndex = FXFT_Get_Char_Index(face, charcode); 484 FT_UInt nIndex = FXFT_Get_Char_Index(face, charcode);
495 if (nIndex > 0) { 485 if (nIndex > 0) {
496 return nIndex; 486 return nIndex;
497 } 487 }
498 int nmaps = FXFT_Get_Face_CharmapCount(face); 488 int nmaps = FXFT_Get_Face_CharmapCount(face);
499 int m = 0; 489 int m = 0;
500 while (m < nmaps) { 490 while (m < nmaps) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) { 536 for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) {
547 CFX_UnicodeEncodingEx* pFontEncoding = 537 CFX_UnicodeEncodingEx* pFontEncoding =
548 _FXFM_CreateFontEncoding(pFont, g_EncodingID[i]); 538 _FXFM_CreateFontEncoding(pFont, g_EncodingID[i]);
549 if (pFontEncoding) { 539 if (pFontEncoding) {
550 return pFontEncoding; 540 return pFontEncoding;
551 } 541 }
552 } 542 }
553 return NULL; 543 return NULL;
554 } 544 }
555 #endif // PDF_ENABLE_XFA 545 #endif // PDF_ENABLE_XFA
OLDNEW
« no previous file with comments | « core/fxge/ge/fx_ge_device.cpp ('k') | core/fxge/ge/fx_ge_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698