• 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 const uint16_t* PDF_UnicodesForPredefinedCharSet(int encoding);
30 const char* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode);
31 
32 class CPDF_Object;
33 
34 class CPDF_FontEncoding {
35  public:
36   static constexpr size_t kEncodingTableSize = 256;
37 
38   explicit CPDF_FontEncoding(int PredefinedEncoding);
39 
40   bool IsIdentical(const CPDF_FontEncoding* pAnother) const;
41 
UnicodeFromCharCode(uint8_t charcode)42   wchar_t UnicodeFromCharCode(uint8_t charcode) const {
43     return m_Unicodes[charcode];
44   }
45   int CharCodeFromUnicode(wchar_t unicode) const;
46 
SetUnicode(uint8_t charcode,wchar_t unicode)47   void SetUnicode(uint8_t charcode, wchar_t unicode) {
48     m_Unicodes[charcode] = unicode;
49   }
50 
51   RetainPtr<CPDF_Object> Realize(WeakPtr<ByteStringPool> pPool) const;
52 
53  private:
54   wchar_t m_Unicodes[kEncodingTableSize];
55 };
56 
57 #endif  // CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
58