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> | 10 #include <memory> |
(...skipping 15 matching lines...) Expand all Loading... |
26 int32_t nCharset; | 26 int32_t nCharset; |
27 CFX_ByteString sFontName; | 27 CFX_ByteString sFontName; |
28 }; | 28 }; |
29 | 29 |
30 #ifndef ANSI_CHARSET | 30 #ifndef ANSI_CHARSET |
31 | 31 |
32 #define ANSI_CHARSET 0 | 32 #define ANSI_CHARSET 0 |
33 #define DEFAULT_CHARSET 1 | 33 #define DEFAULT_CHARSET 1 |
34 #define SYMBOL_CHARSET 2 | 34 #define SYMBOL_CHARSET 2 |
35 #define SHIFTJIS_CHARSET 128 | 35 #define SHIFTJIS_CHARSET 128 |
36 #define HANGEUL_CHARSET 129 | |
37 #define HANGUL_CHARSET 129 | 36 #define HANGUL_CHARSET 129 |
38 #define GB2312_CHARSET 134 | 37 #define GB2312_CHARSET 134 |
39 #define CHINESEBIG5_CHARSET 136 | 38 #define CHINESEBIG5_CHARSET 136 |
40 #define OEM_CHARSET 255 | |
41 #define JOHAB_CHARSET 130 | 39 #define JOHAB_CHARSET 130 |
42 #define HEBREW_CHARSET 177 | 40 #define HEBREW_CHARSET 177 |
43 #define ARABIC_CHARSET 178 | 41 #define ARABIC_CHARSET 178 |
44 #define GREEK_CHARSET 161 | 42 #define GREEK_CHARSET 161 |
45 #define TURKISH_CHARSET 162 | 43 #define TURKISH_CHARSET 162 |
46 #define VIETNAMESE_CHARSET 163 | 44 #define VIETNAMESE_CHARSET 163 |
47 #define THAI_CHARSET 222 | 45 #define THAI_CHARSET 222 |
48 #define EASTEUROPE_CHARSET 238 | 46 #define EASTEUROPE_CHARSET 238 |
49 #define RUSSIAN_CHARSET 204 | 47 #define RUSSIAN_CHARSET 204 |
50 #define BALTIC_CHARSET 186 | 48 #define BALTIC_CHARSET 186 |
51 | 49 |
52 #endif | 50 #endif |
53 | 51 |
54 class CPWL_FontMap : public IPVT_FontMap { | 52 class CPWL_FontMap : public IPVT_FontMap { |
55 public: | 53 public: |
56 CPWL_FontMap(CFX_SystemHandler* pSystemHandler); | 54 CPWL_FontMap(CFX_SystemHandler* pSystemHandler); |
57 ~CPWL_FontMap() override; | 55 ~CPWL_FontMap() override; |
58 | 56 |
59 // IPVT_FontMap | 57 // IPVT_FontMap |
60 CPDF_Font* GetPDFFont(int32_t nFontIndex) override; | 58 CPDF_Font* GetPDFFont(int32_t nFontIndex) override; |
61 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; | 59 CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; |
62 int32_t GetWordFontIndex(uint16_t word, | 60 int32_t GetWordFontIndex(uint16_t word, |
63 int32_t nCharset, | 61 int32_t nCharset, |
64 int32_t nFontIndex) override; | 62 int32_t nFontIndex) override; |
65 int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; | 63 int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; |
66 int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; | 64 int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; |
67 | 65 |
68 int32_t GetFontMapCount() const; | |
69 const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; | 66 const CPWL_FontMap_Data* GetFontMapData(int32_t nIndex) const; |
70 static int32_t GetNativeCharset(); | 67 static int32_t GetNativeCharset(); |
71 CFX_ByteString GetNativeFontName(int32_t nCharset); | 68 CFX_ByteString GetNativeFontName(int32_t nCharset); |
72 | 69 |
73 static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); | 70 static CFX_ByteString GetDefaultFontByCharset(int32_t nCharset); |
74 static const FPDF_CharsetFontMap defaultTTFMap[]; | 71 static const FPDF_CharsetFontMap defaultTTFMap[]; |
75 | 72 |
76 protected: | 73 protected: |
77 virtual void Initialize(); | 74 virtual void Initialize(); |
78 virtual CPDF_Document* GetDocument(); | 75 virtual CPDF_Document* GetDocument(); |
79 virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, | 76 virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, |
80 int32_t nCharset); | 77 int32_t nCharset); |
81 virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); | 78 virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); |
82 | 79 |
83 FX_BOOL KnowWord(int32_t nFontIndex, uint16_t word); | 80 FX_BOOL KnowWord(int32_t nFontIndex, uint16_t word); |
84 | 81 |
85 void Empty(); | 82 void Empty(); |
86 int32_t GetFontIndex(const CFX_ByteString& sFontName, | 83 int32_t GetFontIndex(const CFX_ByteString& sFontName, |
87 int32_t nCharset, | 84 int32_t nCharset, |
88 FX_BOOL bFind); | 85 FX_BOOL bFind); |
89 int32_t GetPWLFontIndex(uint16_t word, int32_t nCharset); | |
90 int32_t AddFontData(CPDF_Font* pFont, | 86 int32_t AddFontData(CPDF_Font* pFont, |
91 const CFX_ByteString& sFontAlias, | 87 const CFX_ByteString& sFontAlias, |
92 int32_t nCharset = DEFAULT_CHARSET); | 88 int32_t nCharset = DEFAULT_CHARSET); |
93 | 89 |
94 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, | 90 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, |
95 int32_t nCharset); | 91 int32_t nCharset); |
96 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); | 92 CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); |
97 | 93 |
98 CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; | 94 CFX_ArrayTemplate<CPWL_FontMap_Data*> m_aData; |
99 CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; | 95 CFX_ArrayTemplate<CPWL_FontMap_Native*> m_aNativeFont; |
100 | 96 |
101 private: | 97 private: |
102 CFX_ByteString GetFontName(int32_t nFontIndex); | |
103 int32_t FindFont(const CFX_ByteString& sFontName, | 98 int32_t FindFont(const CFX_ByteString& sFontName, |
104 int32_t nCharset = DEFAULT_CHARSET); | 99 int32_t nCharset = DEFAULT_CHARSET); |
105 | 100 |
106 CFX_ByteString GetNativeFont(int32_t nCharset); | 101 CFX_ByteString GetNativeFont(int32_t nCharset); |
107 CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, | 102 CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, |
108 CFX_ByteString& sFontName, | 103 CFX_ByteString& sFontName, |
109 uint8_t nCharset); | 104 uint8_t nCharset); |
110 FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); | 105 FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); |
111 CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); | 106 CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); |
112 CPDF_Font* AddSystemFont(CPDF_Document* pDoc, | 107 CPDF_Font* AddSystemFont(CPDF_Document* pDoc, |
113 CFX_ByteString& sFontName, | 108 CFX_ByteString& sFontName, |
114 uint8_t nCharset); | 109 uint8_t nCharset); |
115 | 110 |
116 std::unique_ptr<CPDF_Document> m_pPDFDoc; | 111 std::unique_ptr<CPDF_Document> m_pPDFDoc; |
117 CFX_SystemHandler* const m_pSystemHandler; | 112 CFX_SystemHandler* const m_pSystemHandler; |
118 }; | 113 }; |
119 | 114 |
120 #endif // FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ | 115 #endif // FPDFSDK_PDFWINDOW_PWL_FONTMAP_H_ |
OLD | NEW |