OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ | 7 #ifndef FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ |
8 #define FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ | 8 #define FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ |
9 | 9 |
10 #include <memory> | |
11 | |
10 #include "core/fpdfdoc/include/ipvt_fontmap.h" | 12 #include "core/fpdfdoc/include/ipvt_fontmap.h" |
11 #include "fpdfsdk/fxedit/include/fx_edit.h" | 13 #include "fpdfsdk/fxedit/include/fx_edit.h" |
12 #include "public/fpdf_sysfontinfo.h" | 14 #include "public/fpdf_sysfontinfo.h" |
13 | 15 |
14 class CPDF_Document; | 16 class CPDF_Document; |
15 class CFX_SystemHandler; | 17 class CFX_SystemHandler; |
16 | 18 |
17 struct CPWL_FontMap_Data { | 19 struct CPWL_FontMap_Data { |
18 CPDF_Font* pFont; | 20 CPDF_Font* pFont; |
19 int32_t nCharset; | 21 int32_t nCharset; |
(...skipping 24 matching lines...) Expand all Loading... | |
44 #define VIETNAMESE_CHARSET 163 | 46 #define VIETNAMESE_CHARSET 163 |
45 #define THAI_CHARSET 222 | 47 #define THAI_CHARSET 222 |
46 #define EASTEUROPE_CHARSET 238 | 48 #define EASTEUROPE_CHARSET 238 |
47 #define RUSSIAN_CHARSET 204 | 49 #define RUSSIAN_CHARSET 204 |
48 #define BALTIC_CHARSET 186 | 50 #define BALTIC_CHARSET 186 |
49 | 51 |
50 #endif | 52 #endif |
51 | 53 |
52 class CPWL_FontMap : public IPVT_FontMap { | 54 class CPWL_FontMap : public IPVT_FontMap { |
53 public: | 55 public: |
56 using CharsetFontMap = FPDF_CharsetFontMap; | |
dsinclair
2016/08/03 12:47:55
Is this useful? Seems like it just saves 5 chars b
Wei Li
2016/08/03 17:54:47
Removed it.
| |
57 | |
54 CPWL_FontMap(CFX_SystemHandler* pSystemHandler); | 58 CPWL_FontMap(CFX_SystemHandler* pSystemHandler); |
55 ~CPWL_FontMap() override; | 59 ~CPWL_FontMap() override; |
56 | 60 |
57 // IPVT_FontMap | 61 // IPVT_FontMap |
58 CPDF_Font* GetPDFFont(int32_t nFontIndex) override; | 62 CPDF_Font* GetPDFFont(int32_t nFontIndex) override; |
59 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; | 63 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; |
60 int32_t GetWordFontIndex(uint16_t word, | 64 int32_t GetWordFontIndex(uint16_t word, |
61 int32_t nCharset, | 65 int32_t nCharset, |
62 int32_t nFontIndex) override; | 66 int32_t nFontIndex) override; |
63 int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; | 67 int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; |
64 int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; | 68 int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; |
65 | 69 |
66 void SetSystemHandler(CFX_SystemHandler* pSystemHandler); | 70 void SetSystemHandler(CFX_SystemHandler* pSystemHandler); |
67 int32_t GetFontMapCount() const; | 71 int32_t GetFontMapCount() const; |
68 const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; | 72 const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; |
69 static int32_t GetNativeCharset(); | 73 static int32_t GetNativeCharset(); |
70 CFX_ByteString GetNativeFontName(int32_t nCharset); | 74 CFX_ByteString GetNativeFontName(int32_t nCharset); |
71 | 75 |
72 static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); | 76 static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); |
73 | 77 |
74 CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, | 78 CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, |
75 CFX_ByteString& sFontName, | 79 CFX_ByteString& sFontName, |
76 uint8_t nCharset); | 80 uint8_t nCharset); |
77 static FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); | 81 static FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); |
78 CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); | 82 CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); |
79 CPDF_Font* AddSystemFont(CPDF_Document* pDoc, | 83 CPDF_Font* AddSystemFont(CPDF_Document* pDoc, |
80 CFX_ByteString& sFontName, | 84 CFX_ByteString& sFontName, |
81 uint8_t nCharset); | 85 uint8_t nCharset); |
82 | 86 |
87 static const CharsetFontMap defaultTTFMap[]; | |
88 | |
83 protected: | 89 protected: |
84 virtual void Initialize(); | 90 virtual void Initialize(); |
85 virtual CPDF_Document* GetDocument(); | 91 virtual CPDF_Document* GetDocument(); |
86 virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, | 92 virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, |
87 int32_t nCharset); | 93 int32_t nCharset); |
88 virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); | 94 virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); |
89 | 95 |
90 FX_BOOL KnowWord(int32_t nFontIndex, uint16_t word); | 96 FX_BOOL KnowWord(int32_t nFontIndex, uint16_t word); |
91 | 97 |
92 void Empty(); | 98 void Empty(); |
93 int32_t GetFontIndex(const CFX_ByteString& sFontName, | 99 int32_t GetFontIndex(const CFX_ByteString& sFontName, |
94 int32_t nCharset, | 100 int32_t nCharset, |
95 FX_BOOL bFind); | 101 FX_BOOL bFind); |
96 int32_t GetPWLFontIndex(uint16_t word, int32_t nCharset); | 102 int32_t GetPWLFontIndex(uint16_t word, int32_t nCharset); |
97 int32_t AddFontData(CPDF_Font* pFont, | 103 int32_t AddFontData(CPDF_Font* pFont, |
98 const CFX_ByteString& sFontAlias, | 104 const CFX_ByteString& sFontAlias, |
99 int32_t nCharset = DEFAULT_CHARSET); | 105 int32_t nCharset = DEFAULT_CHARSET); |
100 | 106 |
101 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, | 107 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, |
102 int32_t nCharset); | 108 int32_t nCharset); |
103 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); | 109 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); |
104 | 110 |
111 CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; | |
112 CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; | |
113 | |
105 private: | 114 private: |
106 CFX_ByteString GetFontName(int32_t nFontIndex); | 115 CFX_ByteString GetFontName(int32_t nFontIndex); |
107 int32_t FindFont(const CFX_ByteString& sFontName, | 116 int32_t FindFont(const CFX_ByteString& sFontName, |
108 int32_t nCharset = DEFAULT_CHARSET); | 117 int32_t nCharset = DEFAULT_CHARSET); |
109 | 118 |
110 CFX_ByteString GetNativeFont(int32_t nCharset); | 119 CFX_ByteString GetNativeFont(int32_t nCharset); |
111 | 120 |
112 public: | 121 std::unique_ptr<CPDF_Document> m_pPDFDoc; |
113 using CharsetFontMap = FPDF_CharsetFontMap; | |
114 static const CharsetFontMap defaultTTFMap[]; | |
115 | |
116 protected: | |
117 CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; | |
118 CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; | |
119 | |
120 private: | |
121 CPDF_Document* m_pPDFDoc; | |
122 CFX_SystemHandler* m_pSystemHandler; | 122 CFX_SystemHandler* m_pSystemHandler; |
123 }; | 123 }; |
124 | 124 |
125 class CPWL_DocFontMap : public CPWL_FontMap { | 125 class CPWL_DocFontMap : public CPWL_FontMap { |
126 public: | 126 public: |
127 CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, | 127 CPWL_DocFontMap(CFX_SystemHandler* pSystemHandler, |
128 CPDF_Document* pAttachedDoc); | 128 CPDF_Document* pAttachedDoc); |
129 ~CPWL_DocFontMap() override; | 129 ~CPWL_DocFontMap() override; |
130 | 130 |
131 private: | 131 private: |
132 // CPWL_FontMap: | 132 // CPWL_FontMap: |
133 CPDF_Document* GetDocument() override; | 133 CPDF_Document* GetDocument() override; |
134 | 134 |
135 CPDF_Document* m_pAttachedDoc; | 135 CPDF_Document* m_pAttachedDoc; |
136 }; | 136 }; |
137 | 137 |
138 #endif // FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ | 138 #endif // FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ |
OLD | NEW |