• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The PDFium Authors
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 "core/fxcrt/bytestring.h"
11 #include "core/fxcrt/retain_ptr.h"
12 #include "core/fxcrt/string_pool_template.h"
13 #include "core/fxcrt/weak_ptr.h"
14 
15 enum class FontEncoding {
16   kBuiltin = 0,
17   kWinAnsi = 1,
18   kMacRoman = 2,
19   kMacExpert = 3,
20   kStandard = 4,
21   kAdobeSymbol = 5,
22   kZapfDingbats = 6,
23   kPdfDoc = 7,
24   kMsSymbol = 8,
25 };
26 
27 uint32_t CharCodeFromUnicodeForFreetypeEncoding(int encoding, wchar_t unicode);
28 wchar_t UnicodeFromAppleRomanCharCode(uint8_t charcode);
29 
30 const uint16_t* UnicodesForPredefinedCharSet(FontEncoding encoding);
31 const char* CharNameFromPredefinedCharSet(FontEncoding encoding,
32                                           uint8_t charcode);
33 
34 class CPDF_Object;
35 
36 class CPDF_FontEncoding {
37  public:
38   static constexpr size_t kEncodingTableSize = 256;
39 
40   explicit CPDF_FontEncoding(FontEncoding predefined_encoding);
41 
42   bool IsIdentical(const CPDF_FontEncoding* pAnother) const;
43 
UnicodeFromCharCode(uint8_t charcode)44   wchar_t UnicodeFromCharCode(uint8_t charcode) const {
45     return m_Unicodes[charcode];
46   }
47   int CharCodeFromUnicode(wchar_t unicode) const;
48 
SetUnicode(uint8_t charcode,wchar_t unicode)49   void SetUnicode(uint8_t charcode, wchar_t unicode) {
50     m_Unicodes[charcode] = unicode;
51   }
52 
53   RetainPtr<CPDF_Object> Realize(WeakPtr<ByteStringPool> pPool) const;
54 
55  private:
56   wchar_t m_Unicodes[kEncodingTableSize] = {};
57 };
58 
59 #endif  // CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
60