• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
8 #define CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "core/fxcrt/string_pool_template.h"
14 #include "core/fxcrt/weak_ptr.h"
15 
16 #define PDFFONT_ENCODING_BUILTIN 0
17 #define PDFFONT_ENCODING_WINANSI 1
18 #define PDFFONT_ENCODING_MACROMAN 2
19 #define PDFFONT_ENCODING_MACEXPERT 3
20 #define PDFFONT_ENCODING_STANDARD 4
21 #define PDFFONT_ENCODING_ADOBE_SYMBOL 5
22 #define PDFFONT_ENCODING_ZAPFDINGBATS 6
23 #define PDFFONT_ENCODING_PDFDOC 7
24 #define PDFFONT_ENCODING_MS_SYMBOL 8
25 
26 uint32_t FT_CharCodeFromUnicode(int encoding, wchar_t unicode);
27 wchar_t FT_UnicodeFromCharCode(int encoding, uint32_t charcode);
28 
29 wchar_t PDF_UnicodeFromAdobeName(const char* name);
30 ByteString PDF_AdobeNameFromUnicode(wchar_t unicode);
31 
32 const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding);
33 const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode);
34 
35 class CPDF_Object;
36 
37 class CPDF_FontEncoding {
38  public:
39   CPDF_FontEncoding();
40   explicit CPDF_FontEncoding(int PredefinedEncoding);
41 
42   void LoadEncoding(CPDF_Object* pEncoding);
43 
44   bool IsIdentical(CPDF_FontEncoding* pAnother) const;
45 
UnicodeFromCharCode(uint8_t charcode)46   wchar_t UnicodeFromCharCode(uint8_t charcode) const {
47     return m_Unicodes[charcode];
48   }
49   int CharCodeFromUnicode(wchar_t unicode) const;
50 
SetUnicode(uint8_t charcode,wchar_t unicode)51   void SetUnicode(uint8_t charcode, wchar_t unicode) {
52     m_Unicodes[charcode] = unicode;
53   }
54 
55   std::unique_ptr<CPDF_Object> Realize(WeakPtr<ByteStringPool> pPool);
56 
57  public:
58   wchar_t m_Unicodes[256];
59 };
60 
61 #endif  // CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
62