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 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" |
8 | 8 |
9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
11 | 11 |
12 #define DEFAULT_FONT_NAME "Helvetica" | 12 namespace { |
| 13 |
| 14 const char kDefaultFontName[] = "Helvetica"; |
| 15 |
| 16 const char* const g_sDEStandardFontName[] = {"Courier", |
| 17 "Courier-Bold", |
| 18 "Courier-BoldOblique", |
| 19 "Courier-Oblique", |
| 20 "Helvetica", |
| 21 "Helvetica-Bold", |
| 22 "Helvetica-BoldOblique", |
| 23 "Helvetica-Oblique", |
| 24 "Times-Roman", |
| 25 "Times-Bold", |
| 26 "Times-Italic", |
| 27 "Times-BoldItalic", |
| 28 "Symbol", |
| 29 "ZapfDingbats"}; |
| 30 |
| 31 } // namespace |
13 | 32 |
14 CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) | 33 CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler) |
15 : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) { | 34 : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) { |
16 ASSERT(m_pSystemHandler); | 35 ASSERT(m_pSystemHandler); |
17 } | 36 } |
18 | 37 |
19 CPWL_FontMap::~CPWL_FontMap() { | 38 CPWL_FontMap::~CPWL_FontMap() { |
20 delete m_pPDFDoc; | 39 delete m_pPDFDoc; |
21 m_pPDFDoc = NULL; | 40 m_pPDFDoc = NULL; |
22 | 41 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 163 } |
145 { | 164 { |
146 for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++) | 165 for (int32_t i = 0, sz = m_aNativeFont.GetSize(); i < sz; i++) |
147 delete m_aNativeFont.GetAt(i); | 166 delete m_aNativeFont.GetAt(i); |
148 | 167 |
149 m_aNativeFont.RemoveAll(); | 168 m_aNativeFont.RemoveAll(); |
150 } | 169 } |
151 } | 170 } |
152 | 171 |
153 void CPWL_FontMap::Initialize() { | 172 void CPWL_FontMap::Initialize() { |
154 GetFontIndex(DEFAULT_FONT_NAME, ANSI_CHARSET, FALSE); | 173 GetFontIndex(kDefaultFontName, ANSI_CHARSET, FALSE); |
155 } | 174 } |
156 | 175 |
157 /* | |
158 List of currently supported standard fonts: | |
159 Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique | |
160 Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique | |
161 Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic | |
162 Symbol, ZapfDingbats | |
163 */ | |
164 | |
165 const char* g_sDEStandardFontName[] = {"Courier", | |
166 "Courier-Bold", | |
167 "Courier-BoldOblique", | |
168 "Courier-Oblique", | |
169 "Helvetica", | |
170 "Helvetica-Bold", | |
171 "Helvetica-BoldOblique", | |
172 "Helvetica-Oblique", | |
173 "Times-Roman", | |
174 "Times-Bold", | |
175 "Times-Italic", | |
176 "Times-BoldItalic", | |
177 "Symbol", | |
178 "ZapfDingbats"}; | |
179 | |
180 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) { | 176 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) { |
181 for (int32_t i = 0; i < 14; i++) { | 177 for (int32_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) { |
182 if (sFontName == g_sDEStandardFontName[i]) | 178 if (sFontName == g_sDEStandardFontName[i]) |
183 return TRUE; | 179 return TRUE; |
184 } | 180 } |
185 | 181 |
186 return FALSE; | 182 return FALSE; |
187 } | 183 } |
188 | 184 |
189 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, | 185 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, |
190 int32_t nCharset) { | 186 int32_t nCharset) { |
191 for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) { | 187 for (int32_t i = 0, sz = m_aData.GetSize(); i < sz; i++) { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 489 |
494 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, | 490 CPWL_DocFontMap::CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, |
495 CPDF_Document* pAttachedDoc) | 491 CPDF_Document* pAttachedDoc) |
496 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} | 492 : CPWL_FontMap(pSystemHandler), m_pAttachedDoc(pAttachedDoc) {} |
497 | 493 |
498 CPWL_DocFontMap::~CPWL_DocFontMap() {} | 494 CPWL_DocFontMap::~CPWL_DocFontMap() {} |
499 | 495 |
500 CPDF_Document* CPWL_DocFontMap::GetDocument() { | 496 CPDF_Document* CPWL_DocFontMap::GetDocument() { |
501 return m_pAttachedDoc; | 497 return m_pAttachedDoc; |
502 } | 498 } |
OLD | NEW |