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

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

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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/pdfwindow/PWL_FontMap.h ('k') | fpdfsdk/pdfwindow/PWL_Icon.h » ('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 "fpdfsdk/pdfwindow/PWL_FontMap.h" 7 #include "fpdfsdk/pdfwindow/PWL_FontMap.h"
8 8
9 #include "core/fpdfapi/cpdf_modulemgr.h" 9 #include "core/fpdfapi/cpdf_modulemgr.h"
10 #include "core/fpdfapi/font/cpdf_font.h" 10 #include "core/fpdfapi/font/cpdf_font.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) { 69 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
70 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { 70 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
71 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) { 71 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) {
72 return pData->sFontName; 72 return pData->sFontName;
73 } 73 }
74 } 74 }
75 75
76 return ""; 76 return "";
77 } 77 }
78 78
79 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, uint16_t word) { 79 bool CPWL_FontMap::KnowWord(int32_t nFontIndex, uint16_t word) {
80 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) { 80 if (nFontIndex >= 0 && nFontIndex < m_aData.GetSize()) {
81 if (m_aData.GetAt(nFontIndex)) { 81 if (m_aData.GetAt(nFontIndex)) {
82 return CharCodeFromUnicode(nFontIndex, word) >= 0; 82 return CharCodeFromUnicode(nFontIndex, word) >= 0;
83 } 83 }
84 } 84 }
85 85
86 return FALSE; 86 return false;
87 } 87 }
88 88
89 int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word, 89 int32_t CPWL_FontMap::GetWordFontIndex(uint16_t word,
90 int32_t nCharset, 90 int32_t nCharset,
91 int32_t nFontIndex) { 91 int32_t nFontIndex) {
92 if (nFontIndex > 0) { 92 if (nFontIndex > 0) {
93 if (KnowWord(nFontIndex, word)) 93 if (KnowWord(nFontIndex, word))
94 return nFontIndex; 94 return nFontIndex;
95 } else { 95 } else {
96 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) { 96 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) {
97 if (nCharset == FXFONT_DEFAULT_CHARSET || 97 if (nCharset == FXFONT_DEFAULT_CHARSET ||
98 pData->nCharset == FXFONT_SYMBOL_CHARSET || 98 pData->nCharset == FXFONT_SYMBOL_CHARSET ||
99 nCharset == pData->nCharset) { 99 nCharset == pData->nCharset) {
100 if (KnowWord(0, word)) 100 if (KnowWord(0, word))
101 return 0; 101 return 0;
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 int32_t nNewFontIndex = 106 int32_t nNewFontIndex =
107 GetFontIndex(GetNativeFontName(nCharset), nCharset, TRUE); 107 GetFontIndex(GetNativeFontName(nCharset), nCharset, true);
108 if (nNewFontIndex >= 0) { 108 if (nNewFontIndex >= 0) {
109 if (KnowWord(nNewFontIndex, word)) 109 if (KnowWord(nNewFontIndex, word))
110 return nNewFontIndex; 110 return nNewFontIndex;
111 } 111 }
112 nNewFontIndex = 112 nNewFontIndex =
113 GetFontIndex("Arial Unicode MS", FXFONT_DEFAULT_CHARSET, FALSE); 113 GetFontIndex("Arial Unicode MS", FXFONT_DEFAULT_CHARSET, false);
114 if (nNewFontIndex >= 0) { 114 if (nNewFontIndex >= 0) {
115 if (KnowWord(nNewFontIndex, word)) 115 if (KnowWord(nNewFontIndex, word))
116 return nNewFontIndex; 116 return nNewFontIndex;
117 } 117 }
118 return -1; 118 return -1;
119 } 119 }
120 120
121 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { 121 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
122 CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex); 122 CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex);
123 if (!pData) 123 if (!pData)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 163 }
164 { 164 {
165 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++)
166 delete m_aNativeFont.GetAt(i); 166 delete m_aNativeFont.GetAt(i);
167 167
168 m_aNativeFont.RemoveAll(); 168 m_aNativeFont.RemoveAll();
169 } 169 }
170 } 170 }
171 171
172 void CPWL_FontMap::Initialize() { 172 void CPWL_FontMap::Initialize() {
173 GetFontIndex(kDefaultFontName, FXFONT_ANSI_CHARSET, FALSE); 173 GetFontIndex(kDefaultFontName, FXFONT_ANSI_CHARSET, false);
174 } 174 }
175 175
176 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) { 176 bool CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) {
177 for (size_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) { 177 for (size_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) {
178 if (sFontName == g_sDEStandardFontName[i]) 178 if (sFontName == g_sDEStandardFontName[i])
179 return TRUE; 179 return true;
180 } 180 }
181 181
182 return FALSE; 182 return false;
183 } 183 }
184 184
185 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, 185 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName,
186 int32_t nCharset) { 186 int32_t nCharset) {
187 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++) {
188 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) { 188 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) {
189 if (nCharset == FXFONT_DEFAULT_CHARSET || nCharset == pData->nCharset) { 189 if (nCharset == FXFONT_DEFAULT_CHARSET || nCharset == pData->nCharset) {
190 if (sFontName.IsEmpty() || pData->sFontName == sFontName) 190 if (sFontName.IsEmpty() || pData->sFontName == sFontName)
191 return i; 191 return i;
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 return -1; 196 return -1;
197 } 197 }
198 198
199 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, 199 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName,
200 int32_t nCharset, 200 int32_t nCharset,
201 FX_BOOL bFind) { 201 bool bFind) {
202 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset); 202 int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCharset);
203 if (nFontIndex >= 0) 203 if (nFontIndex >= 0)
204 return nFontIndex; 204 return nFontIndex;
205 205
206 CFX_ByteString sAlias; 206 CFX_ByteString sAlias;
207 CPDF_Font* pFont = nullptr; 207 CPDF_Font* pFont = nullptr;
208 if (bFind) 208 if (bFind)
209 pFont = FindFontSameCharset(sAlias, nCharset); 209 pFont = FindFontSameCharset(sAlias, nCharset);
210 210
211 if (!pFont) { 211 if (!pFont) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return FXFONT_RUSSIAN_CHARSET; 439 return FXFONT_RUSSIAN_CHARSET;
440 440
441 if (word >= 0x0100 && word <= 0x024F) 441 if (word >= 0x0100 && word <= 0x024F)
442 return FXFONT_EASTEUROPE_CHARSET; 442 return FXFONT_EASTEUROPE_CHARSET;
443 443
444 if (word >= 0x1E00 && word <= 0x1EFF) 444 if (word >= 0x1E00 && word <= 0x1EFF)
445 return FXFONT_VIETNAMESE_CHARSET; 445 return FXFONT_VIETNAMESE_CHARSET;
446 446
447 return FXFONT_ANSI_CHARSET; 447 return FXFONT_ANSI_CHARSET;
448 } 448 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_FontMap.h ('k') | fpdfsdk/pdfwindow/PWL_Icon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698