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

Side by Side Diff: xfa/fgas/font/fgas_gefont.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: 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 | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.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 "xfa/fgas/font/fgas_gefont.h" 7 #include "xfa/fgas/font/fgas_gefont.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (!pFont->LoadFontInternal(pBuffer, iLength)) { 66 if (!pFont->LoadFontInternal(pBuffer, iLength)) {
67 pFont->Release(); 67 pFont->Release();
68 return nullptr; 68 return nullptr;
69 } 69 }
70 return pFont; 70 return pFont;
71 } 71 }
72 72
73 // static 73 // static
74 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, 74 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream,
75 IFGAS_FontMgr* pFontMgr, 75 IFGAS_FontMgr* pFontMgr,
76 FX_BOOL bSaveStream) { 76 bool bSaveStream) {
77 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); 77 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
78 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { 78 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) {
79 pFont->Release(); 79 pFont->Release();
80 return nullptr; 80 return nullptr;
81 } 81 }
82 return pFont; 82 return pFont;
83 } 83 }
84 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 84 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
85 85
86 CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) 86 CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
87 : 87 :
88 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 88 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
89 m_bUseLogFontStyle(FALSE), 89 m_bUseLogFontStyle(false),
90 m_dwLogFontStyle(0), 90 m_dwLogFontStyle(0),
91 #endif 91 #endif
92 m_pFont(nullptr), 92 m_pFont(nullptr),
93 m_pSrcFont(nullptr), 93 m_pSrcFont(nullptr),
94 m_pFontMgr(pFontMgr), 94 m_pFontMgr(pFontMgr),
95 m_iRefCount(1), 95 m_iRefCount(1),
96 m_bExternalFont(false), 96 m_bExternalFont(false),
97 m_pProvider(nullptr) { 97 m_pProvider(nullptr) {
98 } 98 }
99 99
100 CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles) 100 CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles)
101 : 101 :
102 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 102 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
103 m_bUseLogFontStyle(FALSE), 103 m_bUseLogFontStyle(false),
104 m_dwLogFontStyle(0), 104 m_dwLogFontStyle(0),
105 #endif 105 #endif
106 m_pFont(nullptr), 106 m_pFont(nullptr),
107 m_pSrcFont(src), 107 m_pSrcFont(src),
108 m_pFontMgr(src->m_pFontMgr), 108 m_pFontMgr(src->m_pFontMgr),
109 m_iRefCount(1), 109 m_iRefCount(1),
110 m_bExternalFont(false), 110 m_bExternalFont(false),
111 m_pProvider(nullptr) { 111 m_pProvider(nullptr) {
112 ASSERT(m_pSrcFont->m_pFont); 112 ASSERT(m_pSrcFont->m_pFont);
113 m_pSrcFont->Retain(); 113 m_pSrcFont->Retain();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 delete this; 150 delete this;
151 } 151 }
152 } 152 }
153 CFGAS_GEFont* CFGAS_GEFont::Retain() { 153 CFGAS_GEFont* CFGAS_GEFont::Retain() {
154 ++m_iRefCount; 154 ++m_iRefCount;
155 return this; 155 return this;
156 } 156 }
157 157
158 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 158 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
159 FX_BOOL CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, 159 bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily,
160 uint32_t dwFontStyles, 160 uint32_t dwFontStyles,
161 uint16_t wCodePage) { 161 uint16_t wCodePage) {
162 if (m_pFont) { 162 if (m_pFont) {
163 return FALSE; 163 return false;
164 } 164 }
165 CFX_ByteString csFontFamily; 165 CFX_ByteString csFontFamily;
166 if (pszFontFamily) { 166 if (pszFontFamily) {
167 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); 167 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
168 } 168 }
169 uint32_t dwFlags = 0; 169 uint32_t dwFlags = 0;
170 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { 170 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
171 dwFlags |= FXFONT_FIXED_PITCH; 171 dwFlags |= FXFONT_FIXED_PITCH;
172 } 172 }
173 if (dwFontStyles & FX_FONTSTYLE_Serif) { 173 if (dwFontStyles & FX_FONTSTYLE_Serif) {
(...skipping 17 matching lines...) Expand all
191 int32_t iWeight = 191 int32_t iWeight =
192 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; 192 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
193 m_pFont = new CFX_Font; 193 m_pFont = new CFX_Font;
194 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { 194 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) {
195 csFontFamily += ",BoldItalic"; 195 csFontFamily += ",BoldItalic";
196 } else if (dwFlags & FXFONT_BOLD) { 196 } else if (dwFlags & FXFONT_BOLD) {
197 csFontFamily += ",Bold"; 197 csFontFamily += ",Bold";
198 } else if (dwFlags & FXFONT_ITALIC) { 198 } else if (dwFlags & FXFONT_ITALIC) {
199 csFontFamily += ",Italic"; 199 csFontFamily += ",Italic";
200 } 200 }
201 m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage, false); 201 m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false);
202 if (!m_pFont->GetFace()) 202 if (!m_pFont->GetFace())
203 return false; 203 return false;
204 return InitFont(); 204 return InitFont();
205 } 205 }
206 206
207 FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { 207 bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
208 if (m_pFont) 208 if (m_pFont)
209 return FALSE; 209 return false;
210 210
211 m_pFont = new CFX_Font; 211 m_pFont = new CFX_Font;
212 if (!m_pFont->LoadEmbedded(pBuffer, length)) 212 if (!m_pFont->LoadEmbedded(pBuffer, length))
213 return FALSE; 213 return false;
214 return InitFont(); 214 return InitFont();
215 } 215 }
216 216
217 FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, 217 bool CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream) {
218 FX_BOOL bSaveStream) {
219 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) 218 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
220 return FALSE; 219 return false;
221 if (bSaveStream) 220 if (bSaveStream)
222 m_pStream.reset(pFontStream); 221 m_pStream.reset(pFontStream);
223 222
224 m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE)); 223 m_pFileRead.reset(FX_CreateFileRead(pFontStream, false));
225 m_pFont = new CFX_Font; 224 m_pFont = new CFX_Font;
226 if (m_pFont->LoadFile(m_pFileRead.get())) 225 if (m_pFont->LoadFile(m_pFileRead.get()))
227 return InitFont(); 226 return InitFont();
228 m_pFileRead.reset(); 227 m_pFileRead.reset();
229 return FALSE; 228 return false;
230 } 229 }
231 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 230 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
232 231
233 FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { 232 bool CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) {
234 if (m_pFont || !pExternalFont) 233 if (m_pFont || !pExternalFont)
235 return FALSE; 234 return false;
236 235
237 m_pFont = pExternalFont; 236 m_pFont = pExternalFont;
238 m_bExternalFont = true; 237 m_bExternalFont = true;
239 return InitFont(); 238 return InitFont();
240 } 239 }
241 240
242 FX_BOOL CFGAS_GEFont::LoadFontInternal( 241 bool CFGAS_GEFont::LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont) {
243 std::unique_ptr<CFX_Font> pInternalFont) {
244 if (m_pFont || !pInternalFont) 242 if (m_pFont || !pInternalFont)
245 return FALSE; 243 return false;
246 244
247 m_pFont = pInternalFont.release(); 245 m_pFont = pInternalFont.release();
248 m_bExternalFont = false; 246 m_bExternalFont = false;
249 return InitFont(); 247 return InitFont();
250 } 248 }
251 249
252 FX_BOOL CFGAS_GEFont::InitFont() { 250 bool CFGAS_GEFont::InitFont() {
253 if (!m_pFont) 251 if (!m_pFont)
254 return FALSE; 252 return false;
255 if (!m_pFontEncoding) { 253 if (!m_pFontEncoding) {
256 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); 254 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont));
257 if (!m_pFontEncoding) 255 if (!m_pFontEncoding)
258 return FALSE; 256 return false;
259 } 257 }
260 if (!m_pCharWidthMap) 258 if (!m_pCharWidthMap)
261 m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024)); 259 m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024));
262 if (!m_pRectArray) 260 if (!m_pRectArray)
263 m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16)); 261 m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16));
264 if (!m_pBBoxMap) 262 if (!m_pBBoxMap)
265 m_pBBoxMap.reset(new CFX_MapPtrToPtr(16)); 263 m_pBBoxMap.reset(new CFX_MapPtrToPtr(16));
266 264
267 return TRUE; 265 return true;
268 } 266 }
269 267
270 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { 268 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) {
271 if (GetFontStyles() == dwFontStyles) 269 if (GetFontStyles() == dwFontStyles)
272 return Retain(); 270 return Retain();
273 return new CFGAS_GEFont(this, dwFontStyles); 271 return new CFGAS_GEFont(this, dwFontStyles);
274 } 272 }
275 273
276 void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { 274 void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const {
277 if (!m_pFont->GetSubstFont() || 275 if (!m_pFont->GetSubstFont() ||
(...skipping 21 matching lines...) Expand all
299 dwStyles |= FX_FONTSTYLE_Italic; 297 dwStyles |= FX_FONTSTYLE_Italic;
300 } else { 298 } else {
301 if (m_pFont->IsBold()) 299 if (m_pFont->IsBold())
302 dwStyles |= FX_FONTSTYLE_Bold; 300 dwStyles |= FX_FONTSTYLE_Bold;
303 if (m_pFont->IsItalic()) 301 if (m_pFont->IsItalic())
304 dwStyles |= FX_FONTSTYLE_Italic; 302 dwStyles |= FX_FONTSTYLE_Italic;
305 } 303 }
306 return dwStyles; 304 return dwStyles;
307 } 305 }
308 306
309 FX_BOOL CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode, 307 bool CFGAS_GEFont::GetCharWidth(FX_WCHAR wUnicode,
310 int32_t& iWidth, 308 int32_t& iWidth,
311 bool bCharCode) { 309 bool bCharCode) {
312 return GetCharWidthInternal(wUnicode, iWidth, true, bCharCode); 310 return GetCharWidthInternal(wUnicode, iWidth, true, bCharCode);
313 } 311 }
314 312
315 FX_BOOL CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode, 313 bool CFGAS_GEFont::GetCharWidthInternal(FX_WCHAR wUnicode,
316 int32_t& iWidth, 314 int32_t& iWidth,
317 bool bRecursive, 315 bool bRecursive,
318 bool bCharCode) { 316 bool bCharCode) {
319 ASSERT(m_pCharWidthMap); 317 ASSERT(m_pCharWidthMap);
320 iWidth = m_pCharWidthMap->GetAt(wUnicode, 0); 318 iWidth = m_pCharWidthMap->GetAt(wUnicode, 0);
321 if (iWidth == 65535) 319 if (iWidth == 65535)
322 return FALSE; 320 return false;
323 321
324 if (iWidth > 0) 322 if (iWidth > 0)
325 return TRUE; 323 return true;
326 324
327 if (!m_pProvider || 325 if (!m_pProvider ||
328 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { 326 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) {
329 CFGAS_GEFont* pFont = nullptr; 327 CFGAS_GEFont* pFont = nullptr;
330 int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); 328 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
331 if (iGlyph != 0xFFFF && pFont) { 329 if (iGlyph != 0xFFFF && pFont) {
332 if (pFont == this) { 330 if (pFont == this) {
333 iWidth = m_pFont->GetGlyphWidth(iGlyph); 331 iWidth = m_pFont->GetGlyphWidth(iGlyph);
334 if (iWidth < 0) { 332 if (iWidth < 0) {
335 iWidth = -1; 333 iWidth = -1;
336 } 334 }
337 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, 335 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false,
338 bCharCode)) { 336 bCharCode)) {
339 return TRUE; 337 return true;
340 } 338 }
341 } else { 339 } else {
342 iWidth = -1; 340 iWidth = -1;
343 } 341 }
344 } 342 }
345 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); 343 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth);
346 return iWidth > 0; 344 return iWidth > 0;
347 } 345 }
348 346
349 FX_BOOL CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode, 347 bool CFGAS_GEFont::GetCharBBox(FX_WCHAR wUnicode,
350 CFX_Rect& bbox, 348 CFX_Rect& bbox,
351 FX_BOOL bCharCode) { 349 bool bCharCode) {
352 return GetCharBBoxInternal(wUnicode, bbox, TRUE, bCharCode); 350 return GetCharBBoxInternal(wUnicode, bbox, true, bCharCode);
353 } 351 }
354 352
355 FX_BOOL CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, 353 bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode,
356 CFX_Rect& bbox, 354 CFX_Rect& bbox,
357 FX_BOOL bRecursive, 355 bool bRecursive,
358 FX_BOOL bCharCode) { 356 bool bCharCode) {
359 ASSERT(m_pRectArray); 357 ASSERT(m_pRectArray);
360 ASSERT(m_pBBoxMap); 358 ASSERT(m_pBBoxMap);
361 void* pRect = nullptr; 359 void* pRect = nullptr;
362 if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) { 360 if (!m_pBBoxMap->Lookup((void*)(uintptr_t)wUnicode, pRect)) {
363 CFGAS_GEFont* pFont = nullptr; 361 CFGAS_GEFont* pFont = nullptr;
364 int32_t iGlyph = GetGlyphIndex(wUnicode, TRUE, &pFont, bCharCode); 362 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode);
365 if (iGlyph != 0xFFFF && pFont) { 363 if (iGlyph != 0xFFFF && pFont) {
366 if (pFont == this) { 364 if (pFont == this) {
367 FX_RECT rtBBox; 365 FX_RECT rtBBox;
368 if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { 366 if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) {
369 CFX_Rect rt; 367 CFX_Rect rt;
370 rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); 368 rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height());
371 int32_t index = m_pRectArray->Add(rt); 369 int32_t index = m_pRectArray->Add(rt);
372 pRect = m_pRectArray->GetPtrAt(index); 370 pRect = m_pRectArray->GetPtrAt(index);
373 m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect); 371 m_pBBoxMap->SetAt((void*)(uintptr_t)wUnicode, pRect);
374 } 372 }
375 } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, FALSE, bCharCode)) { 373 } else if (pFont->GetCharBBoxInternal(wUnicode, bbox, false, bCharCode)) {
376 return TRUE; 374 return true;
377 } 375 }
378 } 376 }
379 } 377 }
380 if (!pRect) 378 if (!pRect)
381 return FALSE; 379 return false;
382 380
383 bbox = *static_cast<const CFX_Rect*>(pRect); 381 bbox = *static_cast<const CFX_Rect*>(pRect);
384 return TRUE; 382 return true;
385 } 383 }
386 FX_BOOL CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { 384 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) {
387 FX_RECT rt(0, 0, 0, 0); 385 FX_RECT rt(0, 0, 0, 0);
388 FX_BOOL bRet = m_pFont->GetBBox(rt); 386 bool bRet = m_pFont->GetBBox(rt);
389 if (bRet) { 387 if (bRet) {
390 bbox.left = rt.left; 388 bbox.left = rt.left;
391 bbox.width = rt.Width(); 389 bbox.width = rt.Width();
392 bbox.top = rt.bottom; 390 bbox.top = rt.bottom;
393 bbox.height = -rt.Height(); 391 bbox.height = -rt.Height();
394 } 392 }
395 return bRet; 393 return bRet;
396 } 394 }
397 int32_t CFGAS_GEFont::GetItalicAngle() const { 395 int32_t CFGAS_GEFont::GetItalicAngle() const {
398 if (!m_pFont->GetSubstFont()) { 396 if (!m_pFont->GetSubstFont()) {
399 return 0; 397 return 0;
400 } 398 }
401 return m_pFont->GetSubstFont()->m_ItalicAngle; 399 return m_pFont->GetSubstFont()->m_ItalicAngle;
402 } 400 }
403 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { 401 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) {
404 return GetGlyphIndex(wUnicode, TRUE, nullptr, bCharCode); 402 return GetGlyphIndex(wUnicode, true, nullptr, bCharCode);
405 } 403 }
406 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, 404 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
407 FX_BOOL bRecursive, 405 bool bRecursive,
408 CFGAS_GEFont** ppFont, 406 CFGAS_GEFont** ppFont,
409 FX_BOOL bCharCode) { 407 bool bCharCode) {
410 ASSERT(m_pFontEncoding); 408 ASSERT(m_pFontEncoding);
411 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); 409 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode);
412 if (iGlyphIndex > 0) { 410 if (iGlyphIndex > 0) {
413 if (ppFont) { 411 if (ppFont) {
414 *ppFont = this; 412 *ppFont = this;
415 } 413 }
416 return iGlyphIndex; 414 return iGlyphIndex;
417 } 415 }
418 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); 416 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode);
419 if (!pFontUSB) { 417 if (!pFontUSB) {
420 return 0xFFFF; 418 return 0xFFFF;
421 } 419 }
422 uint16_t wBitField = pFontUSB->wBitField; 420 uint16_t wBitField = pFontUSB->wBitField;
423 if (wBitField >= 128) { 421 if (wBitField >= 128) {
424 return 0xFFFF; 422 return 0xFFFF;
425 } 423 }
426 auto it = m_FontMapper.find(wUnicode); 424 auto it = m_FontMapper.find(wUnicode);
427 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; 425 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr;
428 if (pFont && pFont != this) { 426 if (pFont && pFont != this) {
429 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); 427 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode);
430 if (iGlyphIndex != 0xFFFF) { 428 if (iGlyphIndex != 0xFFFF) {
431 int32_t i = m_SubstFonts.Find(pFont); 429 int32_t i = m_SubstFonts.Find(pFont);
432 if (i > -1) { 430 if (i > -1) {
433 iGlyphIndex |= ((i + 1) << 24); 431 iGlyphIndex |= ((i + 1) << 24);
434 if (ppFont) 432 if (ppFont)
435 *ppFont = pFont; 433 *ppFont = pFont;
436 return iGlyphIndex; 434 return iGlyphIndex;
437 } 435 }
438 } 436 }
439 } 437 }
(...skipping 10 matching lines...) Expand all
450 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); 448 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr);
451 #endif 449 #endif
452 if (pFont) { 450 if (pFont) {
453 if (pFont == this) { 451 if (pFont == this) {
454 pFont->Release(); 452 pFont->Release();
455 return 0xFFFF; 453 return 0xFFFF;
456 } 454 }
457 m_FontMapper[wUnicode] = pFont; 455 m_FontMapper[wUnicode] = pFont;
458 int32_t i = m_SubstFonts.GetSize(); 456 int32_t i = m_SubstFonts.GetSize();
459 m_SubstFonts.Add(pFont); 457 m_SubstFonts.Add(pFont);
460 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, FALSE, nullptr, bCharCode); 458 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode);
461 if (iGlyphIndex != 0xFFFF) { 459 if (iGlyphIndex != 0xFFFF) {
462 iGlyphIndex |= ((i + 1) << 24); 460 iGlyphIndex |= ((i + 1) << 24);
463 if (ppFont) 461 if (ppFont)
464 *ppFont = pFont; 462 *ppFont = pFont;
465 return iGlyphIndex; 463 return iGlyphIndex;
466 } 464 }
467 } 465 }
468 } 466 }
469 return 0xFFFF; 467 return 0xFFFF;
470 } 468 }
471 int32_t CFGAS_GEFont::GetAscent() const { 469 int32_t CFGAS_GEFont::GetAscent() const {
472 return m_pFont->GetAscent(); 470 return m_pFont->GetAscent();
473 } 471 }
474 int32_t CFGAS_GEFont::GetDescent() const { 472 int32_t CFGAS_GEFont::GetDescent() const {
475 return m_pFont->GetDescent(); 473 return m_pFont->GetDescent();
476 } 474 }
477 void CFGAS_GEFont::Reset() { 475 void CFGAS_GEFont::Reset() {
478 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) 476 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++)
479 m_SubstFonts[i]->Reset(); 477 m_SubstFonts[i]->Reset();
480 if (m_pCharWidthMap) { 478 if (m_pCharWidthMap) {
481 m_pCharWidthMap->RemoveAll(); 479 m_pCharWidthMap->RemoveAll();
482 } 480 }
483 if (m_pBBoxMap) { 481 if (m_pBBoxMap) {
484 m_pBBoxMap->RemoveAll(); 482 m_pBBoxMap->RemoveAll();
485 } 483 }
486 if (m_pRectArray) { 484 if (m_pRectArray) {
487 m_pRectArray->RemoveAll(FALSE); 485 m_pRectArray->RemoveAll(false);
488 } 486 }
489 } 487 }
490 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { 488 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
491 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; 489 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24;
492 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) 490 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this)
493 : m_SubstFonts[iGlyphIndex - 1]; 491 : m_SubstFonts[iGlyphIndex - 1];
494 } 492 }
OLDNEW
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698