Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: core/fpdfapi/fpdf_font/font_int.h

Issue 2392773003: Move core/fpdfapi/fpdf_font to core/fpdfapi/font (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_type3font.cpp ('k') | core/fpdfapi/fpdf_font/fpdf_font.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
7 #ifndef CORE_FPDFAPI_FPDF_FONT_FONT_INT_H_
8 #define CORE_FPDFAPI_FPDF_FONT_FONT_INT_H_
9
10 #include <map>
11 #include <memory>
12
13 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h"
14 #include "core/fxcrt/fx_basic.h"
15
16 class CPDF_CID2UnicodeMap;
17 class CPDF_CMap;
18 class CPDF_Font;
19 class CPDF_Stream;
20
21 using FXFT_Library = void*;
22
23 int TT2PDF(int m, FXFT_Face face);
24 bool FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id);
25 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering);
26
27 class CPDF_CMapManager {
28 public:
29 CPDF_CMapManager();
30 ~CPDF_CMapManager();
31
32 CPDF_CMap* GetPredefinedCMap(const CFX_ByteString& name, bool bPromptCJK);
33 CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, bool bPromptCJK);
34
35 private:
36 CPDF_CMap* LoadPredefinedCMap(const CFX_ByteString& name, bool bPromptCJK);
37 CPDF_CID2UnicodeMap* LoadCID2UnicodeMap(CIDSet charset, bool bPromptCJK);
38
39 std::map<CFX_ByteString, CPDF_CMap*> m_CMaps;
40 CPDF_CID2UnicodeMap* m_CID2UnicodeMaps[6];
41 };
42
43 class CFX_StockFontArray {
44 public:
45 CFX_StockFontArray();
46 ~CFX_StockFontArray();
47
48 // Takes ownership of |pFont|, returns unowned pointer to it.
49 CPDF_Font* SetFont(uint32_t index, std::unique_ptr<CPDF_Font> pFont);
50 CPDF_Font* GetFont(uint32_t index) const;
51
52 private:
53 std::unique_ptr<CPDF_Font> m_StockFonts[14];
54 };
55
56 class CPDF_FontGlobals {
57 public:
58 CPDF_FontGlobals();
59 ~CPDF_FontGlobals();
60
61 void Clear(CPDF_Document* pDoc);
62 CPDF_Font* Find(CPDF_Document* pDoc, uint32_t index);
63
64 // Takes ownership of |pFont|, returns unowned pointer to it.
65 CPDF_Font* Set(CPDF_Document* key,
66 uint32_t index,
67 std::unique_ptr<CPDF_Font> pFont);
68
69 CPDF_CMapManager m_CMapManager;
70 struct {
71 const struct FXCMAP_CMap* m_pMapList;
72 uint32_t m_Count;
73 } m_EmbeddedCharsets[CIDSET_NUM_SETS];
74 struct {
75 const uint16_t* m_pMap;
76 uint32_t m_Count;
77 } m_EmbeddedToUnicodes[CIDSET_NUM_SETS];
78
79 private:
80 std::map<CPDF_Document*, std::unique_ptr<CFX_StockFontArray>> m_StockMap;
81 };
82
83 struct CMap_CodeRange {
84 int m_CharSize;
85 uint8_t m_Lower[4];
86 uint8_t m_Upper[4];
87 };
88
89 class CPDF_CMapParser {
90 public:
91 CPDF_CMapParser();
92 ~CPDF_CMapParser();
93 void Initialize(CPDF_CMap* pMap);
94 void ParseWord(const CFX_ByteStringC& str);
95 CFX_BinaryBuf m_AddMaps;
96
97 private:
98 friend class fpdf_font_cid_CMap_GetCode_Test;
99 friend class fpdf_font_cid_CMap_GetCodeRange_Test;
100
101 static uint32_t CMap_GetCode(const CFX_ByteStringC& word);
102 static bool CMap_GetCodeRange(CMap_CodeRange& range,
103 const CFX_ByteStringC& first,
104 const CFX_ByteStringC& second);
105
106 CPDF_CMap* m_pCMap;
107 int m_Status;
108 int m_CodeSeq;
109 uint32_t m_CodePoints[4];
110 CFX_ArrayTemplate<CMap_CodeRange> m_CodeRanges;
111 CFX_ByteString m_LastWord;
112 };
113
114 enum CIDCoding : uint8_t {
115 CIDCODING_UNKNOWN = 0,
116 CIDCODING_GB,
117 CIDCODING_BIG5,
118 CIDCODING_JIS,
119 CIDCODING_KOREA,
120 CIDCODING_UCS2,
121 CIDCODING_CID,
122 CIDCODING_UTF16,
123 };
124
125 class CPDF_CMap {
126 public:
127 enum CodingScheme : uint8_t {
128 OneByte,
129 TwoBytes,
130 MixedTwoBytes,
131 MixedFourBytes
132 };
133
134 CPDF_CMap();
135 ~CPDF_CMap();
136
137 void LoadPredefined(CPDF_CMapManager* pMgr,
138 const CFX_ByteString& name,
139 bool bPromptCJK);
140 void LoadEmbedded(const uint8_t* pData, uint32_t dwSize);
141
142 bool IsLoaded() const;
143 bool IsVertWriting() const;
144 uint16_t CIDFromCharCode(uint32_t charcode) const;
145 int GetCharSize(uint32_t charcode) const;
146 uint32_t GetNextChar(const FX_CHAR* pString, int nStrLen, int& offset) const;
147 int CountChar(const FX_CHAR* pString, int size) const;
148 int AppendChar(FX_CHAR* str, uint32_t charcode) const;
149
150 private:
151 friend class CPDF_CMapParser;
152 friend class CPDF_CIDFont;
153
154 CFX_ByteString m_PredefinedCMap;
155 bool m_bVertical;
156 CIDSet m_Charset;
157 int m_Coding;
158 CodingScheme m_CodingScheme;
159 int m_nCodeRanges;
160 uint8_t* m_pLeadingBytes;
161 uint16_t* m_pMapping;
162 uint8_t* m_pAddMapping;
163 bool m_bLoaded;
164 const FXCMAP_CMap* m_pEmbedMap;
165 };
166
167 class CPDF_CID2UnicodeMap {
168 public:
169 CPDF_CID2UnicodeMap();
170 ~CPDF_CID2UnicodeMap();
171
172 bool IsLoaded();
173 void Load(CPDF_CMapManager* pMgr, CIDSet charset, bool bPromptCJK);
174 FX_WCHAR UnicodeFromCID(uint16_t CID);
175
176 private:
177 CIDSet m_Charset;
178 const uint16_t* m_pEmbeddedMap;
179 uint32_t m_EmbeddedCount;
180 };
181
182 class CPDF_ToUnicodeMap {
183 public:
184 CPDF_ToUnicodeMap();
185 ~CPDF_ToUnicodeMap();
186
187 void Load(CPDF_Stream* pStream);
188
189 CFX_WideString Lookup(uint32_t charcode) const;
190 uint32_t ReverseLookup(FX_WCHAR unicode) const;
191
192 private:
193 friend class fpdf_font_StringToCode_Test;
194 friend class fpdf_font_StringToWideString_Test;
195
196 static uint32_t StringToCode(const CFX_ByteStringC& str);
197 static CFX_WideString StringToWideString(const CFX_ByteStringC& str);
198
199 std::map<uint32_t, uint32_t> m_Map;
200 CPDF_CID2UnicodeMap* m_pBaseMap;
201 CFX_WideTextBuf m_MultiCharBuf;
202 };
203
204 #endif // CORE_FPDFAPI_FPDF_FONT_FONT_INT_H_
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_type3font.cpp ('k') | core/fpdfapi/fpdf_font/fpdf_font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698