OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfapi/fpdf_font/include/cpdf_font.h" | 7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h" | 12 #include "core/fpdfapi/fpdf_font/cpdf_truetypefont.h" |
13 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" | 13 #include "core/fpdfapi/fpdf_font/cpdf_type1font.h" |
14 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 14 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
15 #include "core/fpdfapi/fpdf_font/font_int.h" | 15 #include "core/fpdfapi/fpdf_font/font_int.h" |
16 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" | 16 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" |
17 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" | 17 #include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h" |
18 #include "core/fpdfapi/fpdf_page/pageint.h" | 18 #include "core/fpdfapi/fpdf_page/pageint.h" |
19 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 19 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
20 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 20 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
21 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 21 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
22 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 22 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
23 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" | 23 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h" |
24 #include "core/fpdfapi/include/cpdf_modulemgr.h" | 24 #include "core/fpdfapi/include/cpdf_modulemgr.h" |
| 25 #include "core/fxcrt/include/fx_memory.h" |
25 #include "core/fxge/include/fx_freetype.h" | 26 #include "core/fxge/include/fx_freetype.h" |
| 27 #include "third_party/base/stl_util.h" |
26 | 28 |
27 namespace { | 29 namespace { |
28 | 30 |
29 const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, | 31 const uint8_t kChineseFontNames[][5] = {{0xCB, 0xCE, 0xCC, 0xE5, 0x00}, |
30 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, | 32 {0xBF, 0xAC, 0xCC, 0xE5, 0x00}, |
31 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, | 33 {0xBA, 0xDA, 0xCC, 0xE5, 0x00}, |
32 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, | 34 {0xB7, 0xC2, 0xCB, 0xCE, 0x00}, |
33 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; | 35 {0xD0, 0xC2, 0xCB, 0xCE, 0x00}}; |
34 | 36 |
35 void GetPredefinedEncoding(const CFX_ByteString& value, int* basemap) { | 37 void GetPredefinedEncoding(const CFX_ByteString& value, int* basemap) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 446 } |
445 | 447 |
446 if (!charnames.empty() && !charnames[charcode].IsEmpty()) | 448 if (!charnames.empty() && !charnames[charcode].IsEmpty()) |
447 return charnames[charcode].c_str(); | 449 return charnames[charcode].c_str(); |
448 | 450 |
449 const FX_CHAR* name = nullptr; | 451 const FX_CHAR* name = nullptr; |
450 if (iBaseEncoding) | 452 if (iBaseEncoding) |
451 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); | 453 name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode); |
452 return name && name[0] ? name : nullptr; | 454 return name && name[0] ? name : nullptr; |
453 } | 455 } |
| 456 |
| 457 uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode) { |
| 458 if (m_FontFallbacks.empty()) { |
| 459 m_FontFallbacks.push_back(WrapUnique(new CFX_Font())); |
| 460 m_FontFallbacks[0]->LoadSubst("Arial", IsTrueTypeFont(), m_Flags, |
| 461 m_StemV * 5, m_ItalicAngle, 0, |
| 462 IsVertWriting()); |
| 463 } |
| 464 return 0; |
| 465 } |
| 466 |
| 467 int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) { |
| 468 if (fallbackFont < 0 || |
| 469 fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) { |
| 470 return -1; |
| 471 } |
| 472 int glyph = |
| 473 FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode); |
| 474 if (glyph == 0 || glyph == 0xffff) |
| 475 return -1; |
| 476 return glyph; |
| 477 } |
OLD | NEW |