Remove typdefs for pointer types in fx_system.h.
[pdfium.git] / core / src / fpdfapi / fpdf_font / font_int.h
1 // Copyright 2014 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 #ifndef CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
7 #define CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_
8
9 typedef void* FXFT_Library;
10 class CPDF_CMapManager 
11 {
12 public:
13     CPDF_CMapManager();
14     ~CPDF_CMapManager();
15     void*                               GetPackage(FX_BOOL bPrompt);
16     CPDF_CMap*                          GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt);
17     CPDF_CID2UnicodeMap*        GetCID2UnicodeMap(int charset, FX_BOOL bPrompt);
18     void                                        ReloadAll();
19 private:
20     CPDF_CMap*                          LoadPredefinedCMap(const CFX_ByteString& name,  FX_BOOL bPrompt);
21     CPDF_CID2UnicodeMap*        LoadCID2UnicodeMap(int charset, FX_BOOL bPrompt);
22     void                                        DropAll(FX_BOOL bReload);
23     FX_BOOL                                     m_bPrompted;
24     CFX_MapByteStringToPtr      m_CMaps;
25     CPDF_CID2UnicodeMap*        m_CID2UnicodeMaps[6];
26 };
27 class CPDF_FontGlobals 
28 {
29 public:
30     CPDF_FontGlobals();
31     ~CPDF_FontGlobals();
32     void                                ClearAll();
33     void                                Clear(void* key);
34     CPDF_Font*                  Find(void* key, int index);
35     void                                Set(void* key, int index, CPDF_Font* pFont);
36     CPDF_CMapManager    m_CMapManager;
37     struct {
38         const struct FXCMAP_CMap*       m_pMapList;
39         int                             m_Count;
40     } m_EmbeddedCharsets[NUMBER_OF_CIDSETS];
41     struct {
42         const FX_WORD*  m_pMap;
43         int                             m_Count;
44     } m_EmbeddedToUnicodes[NUMBER_OF_CIDSETS];
45 private:
46     CFX_MapPtrToPtr             m_pStockMap;
47     uint8_t*                    m_pContrastRamps;
48 };
49 struct _CMap_CodeRange {
50     int                 m_CharSize;
51     uint8_t             m_Lower[4];
52     uint8_t             m_Upper[4];
53 };
54 class CPDF_CMapParser 
55 {
56 public:
57     CPDF_CMapParser();
58     ~CPDF_CMapParser() {}
59     FX_BOOL     Initialize(CPDF_CMap*);
60     void        ParseWord(FX_BSTR str);
61     CFX_BinaryBuf       m_AddMaps;
62 private:
63     CPDF_CMap*  m_pCMap;
64     int                         m_Status;
65     int                         m_CodeSeq;
66     FX_DWORD            m_CodePoints[4];
67     CFX_ArrayTemplate<_CMap_CodeRange>  m_CodeRanges;
68     CFX_ByteString      m_Registry, m_Ordering, m_Supplement;
69     CFX_ByteString      m_LastWord;
70 };
71 #define CIDCODING_UNKNOWN       0
72 #define CIDCODING_GB            1
73 #define CIDCODING_BIG5          2
74 #define CIDCODING_JIS           3
75 #define CIDCODING_KOREA         4
76 #define CIDCODING_UCS2          5
77 #define CIDCODING_CID           6
78 #define CIDCODING_UTF16         7
79 class CPDF_CMap 
80 {
81 public:
82     CPDF_CMap();
83     FX_BOOL                                     LoadPredefined(CPDF_CMapManager* pMgr, const FX_CHAR* name, FX_BOOL bPromptCJK);
84     FX_BOOL                                     LoadEmbedded(const uint8_t* pData, FX_DWORD dwSize);
85     void                                        Release();
86     FX_BOOL                                     IsLoaded() const
87     {
88         return m_bLoaded;
89     }
90     int                                         GetCharset()
91     {
92         return m_Charset;
93     }
94     FX_BOOL                                     IsVertWriting() const
95     {
96         return m_bVertical;
97     }
98     FX_WORD                                     CIDFromCharCode(FX_DWORD charcode) const;
99     FX_DWORD                            CharCodeFromCID(FX_WORD CID) const;
100     int                                         GetCharSize(FX_DWORD charcode) const;
101     FX_DWORD                            GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const;
102     int                                         CountChar(const FX_CHAR* pString, int size) const;
103     int                                         AppendChar(FX_CHAR* str, FX_DWORD charcode) const;
104     typedef enum {OneByte, TwoBytes, MixedTwoBytes, MixedFourBytes} CodingScheme;
105 protected:
106     ~CPDF_CMap();
107     friend class                        CPDF_CMapParser;
108     friend class                        CPDF_CMapManager;
109     friend class                        CPDF_CIDFont;
110 protected:
111     CFX_ByteString                      m_PredefinedCMap;
112     FX_BOOL                                     m_bVertical;
113     int                                         m_Charset, m_Coding;
114     CodingScheme                        m_CodingScheme;
115     int                                         m_nCodeRanges;
116     uint8_t*                            m_pLeadingBytes;
117     FX_WORD*                            m_pMapping;
118     uint8_t*                            m_pAddMapping;
119     FX_BOOL                                     m_bLoaded;
120     const FXCMAP_CMap*          m_pEmbedMap;
121     CPDF_CMap*                          m_pUseMap;
122 };
123 class CPDF_PredefinedCMap
124 {
125 public:
126     const FX_CHAR*      m_pName;
127     int                 m_Charset;
128     int                 m_Coding;
129     CPDF_CMap::CodingScheme     m_CodingScheme;
130     FX_DWORD    m_LeadingSegCount;
131     uint8_t             m_LeadingSegs[4];
132 };
133 typedef struct _FileHeader {
134     uint8_t             btTag[4];
135     uint8_t             btVersion;
136     uint8_t             btFormat;
137     uint8_t             btReserved1[2];
138     FX_DWORD    dwStartIndex;
139     FX_DWORD    dwEndIndex;
140     FX_DWORD    dwDataSize;
141     FX_DWORD    dwDataOffset;
142     FX_DWORD    dwRecordSize;
143 } FXMP_FILEHEADER;
144 class CPDF_CID2UnicodeMap 
145 {
146 public:
147     CPDF_CID2UnicodeMap();
148     ~CPDF_CID2UnicodeMap();
149     FX_BOOL             Initialize();
150     FX_BOOL             IsLoaded();
151     void                Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPromptCJK);
152     FX_WCHAR    UnicodeFromCID(FX_WORD CID);
153 protected:
154     int                 m_Charset;
155     const FX_WORD*      m_pEmbeddedMap;
156     FX_DWORD    m_EmbeddedCount;
157 };
158 class CPDF_ToUnicodeMap 
159 {
160 public:
161     void                                        Load(CPDF_Stream* pStream);
162     CFX_WideString                      Lookup(FX_DWORD charcode);
163     FX_DWORD                            ReverseLookup(FX_WCHAR unicode);
164 protected:
165     CFX_CMapDWordToDWord        m_Map;
166     CPDF_CID2UnicodeMap*        m_pBaseMap;
167     CFX_WideTextBuf                     m_MultiCharBuf;
168 };
169 class CPDF_FontCharMap : public CFX_CharMap
170 {
171 public:
172     CPDF_FontCharMap(CPDF_Font* pFont);
173     CPDF_Font*          m_pFont;
174 };
175
176 #endif  // CORE_SRC_FPDFAPI_FPDF_FONT_FONT_INT_H_