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

Side by Side Diff: core/fpdfapi/fpdf_font/cpdf_simplefont.cpp

Issue 2368693002: Remove FX_BOOL from cpdf_font (Closed)
Patch Set: And again Created 4 years, 2 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
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfapi/fpdf_font/cpdf_simplefont.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_simplefont.h"
8 8
9 #include "core/fpdfapi/fpdf_font/font_int.h" 9 #include "core/fpdfapi/fpdf_font/font_int.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 FX_RECT CPDF_SimpleFont::GetCharBBox(uint32_t charcode, int level) { 94 FX_RECT CPDF_SimpleFont::GetCharBBox(uint32_t charcode, int level) {
95 if (charcode > 0xff) 95 if (charcode > 0xff)
96 charcode = 0; 96 charcode = 0;
97 97
98 if (m_CharBBox[charcode].left == -1) 98 if (m_CharBBox[charcode].left == -1)
99 LoadCharMetrics(charcode); 99 LoadCharMetrics(charcode);
100 100
101 return m_CharBBox[charcode]; 101 return m_CharBBox[charcode];
102 } 102 }
103 103
104 FX_BOOL CPDF_SimpleFont::LoadCommon() { 104 bool CPDF_SimpleFont::LoadCommon() {
105 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor"); 105 CPDF_Dictionary* pFontDesc = m_pFontDict->GetDictFor("FontDescriptor");
106 if (pFontDesc) { 106 if (pFontDesc) {
107 LoadFontDescriptor(pFontDesc); 107 LoadFontDescriptor(pFontDesc);
108 } 108 }
109 CPDF_Array* pWidthArray = m_pFontDict->GetArrayFor("Widths"); 109 CPDF_Array* pWidthArray = m_pFontDict->GetArrayFor("Widths");
110 m_bUseFontWidth = !pWidthArray; 110 m_bUseFontWidth = !pWidthArray;
111 if (pWidthArray) { 111 if (pWidthArray) {
112 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) { 112 if (pFontDesc && pFontDesc->KeyExist("MissingWidth")) {
113 int MissingWidth = pFontDesc->GetIntegerFor("MissingWidth"); 113 int MissingWidth = pFontDesc->GetIntegerFor("MissingWidth");
114 for (int i = 0; i < 256; i++) { 114 for (int i = 0; i < 256; i++) {
(...skipping 20 matching lines...) Expand all
135 } 135 }
136 if (!(m_Flags & PDFFONT_SYMBOLIC)) { 136 if (!(m_Flags & PDFFONT_SYMBOLIC)) {
137 m_BaseEncoding = PDFFONT_ENCODING_STANDARD; 137 m_BaseEncoding = PDFFONT_ENCODING_STANDARD;
138 } 138 }
139 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding"); 139 CPDF_Object* pEncoding = m_pFontDict->GetDirectObjectFor("Encoding");
140 LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile, 140 LoadPDFEncoding(pEncoding, m_BaseEncoding, &m_CharNames, !!m_pFontFile,
141 m_Font.IsTTFont()); 141 m_Font.IsTTFont());
142 LoadGlyphMap(); 142 LoadGlyphMap();
143 m_CharNames.clear(); 143 m_CharNames.clear();
144 if (!m_Font.GetFace()) 144 if (!m_Font.GetFace())
145 return TRUE; 145 return true;
146 146
147 if (m_Flags & PDFFONT_ALLCAP) { 147 if (m_Flags & PDFFONT_ALLCAP) {
148 unsigned char kLowercases[][2] = {{'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}}; 148 unsigned char kLowercases[][2] = {{'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}};
149 for (size_t range = 0; range < FX_ArraySize(kLowercases); ++range) { 149 for (size_t range = 0; range < FX_ArraySize(kLowercases); ++range) {
150 const auto& lower = kLowercases[range]; 150 const auto& lower = kLowercases[range];
151 for (int i = lower[0]; i <= lower[1]; ++i) { 151 for (int i = lower[0]; i <= lower[1]; ++i) {
152 if (m_GlyphIndex[i] != 0xffff && m_pFontFile) 152 if (m_GlyphIndex[i] != 0xffff && m_pFontFile)
153 continue; 153 continue;
154 154
155 int j = i - 32; 155 int j = i - 32;
156 m_GlyphIndex[i] = m_GlyphIndex[j]; 156 m_GlyphIndex[i] = m_GlyphIndex[j];
157 if (m_CharWidth[j]) { 157 if (m_CharWidth[j]) {
158 m_CharWidth[i] = m_CharWidth[j]; 158 m_CharWidth[i] = m_CharWidth[j];
159 m_CharBBox[i] = m_CharBBox[j]; 159 m_CharBBox[i] = m_CharBBox[j];
160 } 160 }
161 } 161 }
162 } 162 }
163 } 163 }
164 CheckFontMetrics(); 164 CheckFontMetrics();
165 return TRUE; 165 return true;
166 } 166 }
167 167
168 void CPDF_SimpleFont::LoadSubstFont() { 168 void CPDF_SimpleFont::LoadSubstFont() {
169 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) { 169 if (!m_bUseFontWidth && !(m_Flags & PDFFONT_FIXEDPITCH)) {
170 int width = 0, i; 170 int width = 0, i;
171 for (i = 0; i < 256; i++) { 171 for (i = 0; i < 256; i++) {
172 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) { 172 if (m_CharWidth[i] == 0 || m_CharWidth[i] == 0xffff) {
173 continue; 173 continue;
174 } 174 }
175 if (width == 0) { 175 if (width == 0) {
176 width = m_CharWidth[i]; 176 width = m_CharWidth[i];
177 } else if (width != m_CharWidth[i]) { 177 } else if (width != m_CharWidth[i]) {
178 break; 178 break;
179 } 179 }
180 } 180 }
181 if (i == 256 && width) { 181 if (i == 256 && width) {
182 m_Flags |= PDFFONT_FIXEDPITCH; 182 m_Flags |= PDFFONT_FIXEDPITCH;
183 } 183 }
184 } 184 }
185 pdfium::base::CheckedNumeric<int> safeStemV(m_StemV); 185 pdfium::base::CheckedNumeric<int> safeStemV(m_StemV);
186 if (m_StemV < 140) 186 if (m_StemV < 140)
187 safeStemV *= 5; 187 safeStemV *= 5;
188 else 188 else
189 safeStemV = safeStemV * 4 + 140; 189 safeStemV = safeStemV * 4 + 140;
190 m_Font.LoadSubst(m_BaseFont, IsTrueTypeFont(), m_Flags, 190 m_Font.LoadSubst(m_BaseFont, IsTrueTypeFont(), m_Flags,
191 safeStemV.ValueOrDefault(FXFONT_FW_NORMAL), m_ItalicAngle, 191 safeStemV.ValueOrDefault(FXFONT_FW_NORMAL), m_ItalicAngle, 0,
192 0); 192 false);
193 } 193 }
194 194
195 FX_BOOL CPDF_SimpleFont::IsUnicodeCompatible() const { 195 bool CPDF_SimpleFont::IsUnicodeCompatible() const {
196 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN && 196 return m_BaseEncoding != PDFFONT_ENCODING_BUILTIN &&
197 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL && 197 m_BaseEncoding != PDFFONT_ENCODING_ADOBE_SYMBOL &&
198 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS; 198 m_BaseEncoding != PDFFONT_ENCODING_ZAPFDINGBATS;
199 } 199 }
200 200
201 CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const { 201 CFX_WideString CPDF_SimpleFont::UnicodeFromCharCode(uint32_t charcode) const {
202 CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode); 202 CFX_WideString unicode = CPDF_Font::UnicodeFromCharCode(charcode);
203 if (!unicode.IsEmpty()) 203 if (!unicode.IsEmpty())
204 return unicode; 204 return unicode;
205 FX_WCHAR ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode); 205 FX_WCHAR ret = m_Encoding.UnicodeFromCharCode((uint8_t)charcode);
206 if (ret == 0) 206 if (ret == 0)
207 return CFX_WideString(); 207 return CFX_WideString();
208 return ret; 208 return ret;
209 } 209 }
210 210
211 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const { 211 uint32_t CPDF_SimpleFont::CharCodeFromUnicode(FX_WCHAR unicode) const {
212 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode); 212 uint32_t ret = CPDF_Font::CharCodeFromUnicode(unicode);
213 if (ret) 213 if (ret)
214 return ret; 214 return ret;
215 return m_Encoding.CharCodeFromUnicode(unicode); 215 return m_Encoding.CharCodeFromUnicode(unicode);
216 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698