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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_FontMap.cpp

Issue 1254703002: FX_BOOL considered harmful, part 2. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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 | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "../../include/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_FontMap.h" 9 #include "../../include/pdfwindow/PWL_FontMap.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 66 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
67 { 67 {
68 return pData->sFontName; 68 return pData->sFontName;
69 } 69 }
70 } 70 }
71 71
72 return ""; 72 return "";
73 } 73 }
74 74
75 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word) 75 bool CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word)
76 { 76 {
77 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 77 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
78 { 78 {
79 if (m_aData.GetAt(nFontIndex)) 79 if (m_aData.GetAt(nFontIndex))
80 { 80 {
81 return CharCodeFromUnicode(nFontIndex, word) >= 0; 81 return CharCodeFromUnicode(nFontIndex, word) >= 0;
82 } 82 }
83 } 83 }
84 84
85 return FALSE; 85 return false;
86 } 86 }
87 87
88 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t n FontIndex) 88 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t n FontIndex)
89 { 89 {
90 if (nFontIndex > 0) 90 if (nFontIndex > 0)
91 { 91 {
92 if (KnowWord(nFontIndex, word)) 92 if (KnowWord(nFontIndex, word))
93 return nFontIndex; 93 return nFontIndex;
94 } 94 }
95 else 95 else
96 { 96 {
97 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) 97 if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
98 { 98 {
99 if (nCharset == DEFAULT_CHARSET || 99 if (nCharset == DEFAULT_CHARSET ||
100 pData->nCharset == SYMBOL_CHARSET || 100 pData->nCharset == SYMBOL_CHARSET ||
101 nCharset == pData->nCharset) 101 nCharset == pData->nCharset)
102 { 102 {
103 if (KnowWord(0, word)) 103 if (KnowWord(0, word))
104 return 0; 104 return 0;
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 int32_t nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE); 109 int32_t nNewFontIndex = GetFontIndex(GetNativeFontName(nCharset), nCharset, true);
110 if (nNewFontIndex >= 0) 110 if (nNewFontIndex >= 0)
111 { 111 {
112 if (KnowWord(nNewFontIndex, word)) 112 if (KnowWord(nNewFontIndex, word))
113 return nNewFontIndex; 113 return nNewFontIndex;
114 } 114 }
115 nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE); 115 nNewFontIndex = GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, false);
116 if (nNewFontIndex >= 0) 116 if (nNewFontIndex >= 0)
117 { 117 {
118 if (KnowWord(nNewFontIndex, word)) 118 if (KnowWord(nNewFontIndex, word))
119 return nNewFontIndex; 119 return nNewFontIndex;
120 } 120 }
121 return -1; 121 return -1;
122 } 122 }
123 123
124 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word) 124 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word)
125 { 125 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 } 183 }
184 184
185 void CPWL_FontMap::Initial(const FX_CHAR* fontname) 185 void CPWL_FontMap::Initial(const FX_CHAR* fontname)
186 { 186 {
187 CFX_ByteString sFontName = fontname; 187 CFX_ByteString sFontName = fontname;
188 188
189 if (sFontName.IsEmpty()) 189 if (sFontName.IsEmpty())
190 sFontName = DEFAULT_FONT_NAME; 190 sFontName = DEFAULT_FONT_NAME;
191 191
192 GetFontIndex(sFontName, ANSI_CHARSET, FALSE); 192 GetFontIndex(sFontName, ANSI_CHARSET, false);
193 } 193 }
194 194
195 195
196 /* 196 /*
197 List of currently supported standard fonts: 197 List of currently supported standard fonts:
198 Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique 198 Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
199 Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique 199 Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique
200 Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic 200 Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
201 Symbol, ZapfDingbats 201 Symbol, ZapfDingbats
202 */ 202 */
203 203
204 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique", 204 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique",
205 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Oblique", 205 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Oblique",
206 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", 206 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
207 "Symbol", "ZapfDingbats"}; 207 "Symbol", "ZapfDingbats"};
208 208
209 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) 209 bool CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
210 { 210 {
211 for (int32_t i=0; i<14; i++) 211 for (int32_t i=0; i<14; i++)
212 { 212 {
213 if (sFontName == g_sDEStandardFontName[i]) 213 if (sFontName == g_sDEStandardFontName[i])
214 return TRUE; 214 return true;
215 } 215 }
216 216
217 return FALSE; 217 return false;
218 } 218 }
219 219
220 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset ) 220 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset )
221 { 221 {
222 for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++) 222 for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
223 { 223 {
224 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) 224 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
225 { 225 {
226 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset) 226 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nCharset)
227 { 227 {
228 if (sFontName.IsEmpty() || pData->sFontName == sFontName) 228 if (sFontName.IsEmpty() || pData->sFontName == sFontName)
229 return i; 229 return i;
230 } 230 }
231 } 231 }
232 } 232 }
233 233
234 return -1; 234 return -1;
235 } 235 }
236 236
237 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCha rset, FX_BOOL bFind) 237 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCha rset, bool bFind)
238 { 238 {
239 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset ); 239 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset );
240 if (nFontIndex >= 0) 240 if (nFontIndex >= 0)
241 return nFontIndex; 241 return nFontIndex;
242 242
243 CFX_ByteString sAlias; 243 CFX_ByteString sAlias;
244 CPDF_Font* pFont = NULL; 244 CPDF_Font* pFont = NULL;
245 if (bFind) 245 if (bFind)
246 pFont = FindFontSameCharset(sAlias, nCharset); 246 pFont = FindFontSameCharset(sAlias, nCharset);
247 247
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 559 }
560 560
561 CPWL_DocFontMap::~CPWL_DocFontMap() 561 CPWL_DocFontMap::~CPWL_DocFontMap()
562 { 562 {
563 } 563 }
564 564
565 CPDF_Document* CPWL_DocFontMap::GetDocument() 565 CPDF_Document* CPWL_DocFontMap::GetDocument()
566 { 566 {
567 return m_pAttachedDoc; 567 return m_pAttachedDoc;
568 } 568 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698