| 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 "xfa/fgas/font/fgas_gefont.h" | 7 #include "xfa/fgas/font/cfgas_gefont.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "core/fxge/cfx_substfont.h" | 12 #include "core/fxge/cfx_substfont.h" |
| 13 #include "core/fxge/cfx_unicodeencoding.h" | 13 #include "core/fxge/cfx_unicodeencoding.h" |
| 14 #include "core/fxge/cfx_unicodeencodingex.h" | 14 #include "core/fxge/cfx_unicodeencodingex.h" |
| 15 #include "third_party/base/ptr_util.h" |
| 15 #include "xfa/fgas/crt/fgas_codepage.h" | 16 #include "xfa/fgas/crt/fgas_codepage.h" |
| 16 #include "xfa/fgas/font/fgas_fontutils.h" | 17 #include "xfa/fgas/font/fgas_fontutils.h" |
| 17 #include "xfa/fxfa/xfa_fontmgr.h" | 18 #include "xfa/fxfa/xfa_fontmgr.h" |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, | 21 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, |
| 21 uint32_t dwFontStyles, | 22 uint32_t dwFontStyles, |
| 22 uint16_t wCodePage, | 23 uint16_t wCodePage, |
| 23 CFGAS_FontMgr* pFontMgr) { | 24 CFGAS_FontMgr* pFontMgr) { |
| 24 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 25 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 m_pSrcFont->Retain(); | 114 m_pSrcFont->Retain(); |
| 114 m_pFont = new CFX_Font; | 115 m_pFont = new CFX_Font; |
| 115 m_pFont->LoadClone(m_pSrcFont->m_pFont); | 116 m_pFont->LoadClone(m_pSrcFont->m_pFont); |
| 116 CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); | 117 CFX_SubstFont* pSubst = m_pFont->GetSubstFont(); |
| 117 if (!pSubst) { | 118 if (!pSubst) { |
| 118 pSubst = new CFX_SubstFont; | 119 pSubst = new CFX_SubstFont; |
| 119 m_pFont->SetSubstFont(std::unique_ptr<CFX_SubstFont>(pSubst)); | 120 m_pFont->SetSubstFont(std::unique_ptr<CFX_SubstFont>(pSubst)); |
| 120 } | 121 } |
| 121 pSubst->m_Weight = | 122 pSubst->m_Weight = |
| 122 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; | 123 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; |
| 123 if (dwFontStyles & FX_FONTSTYLE_Italic) { | 124 if (dwFontStyles & FX_FONTSTYLE_Italic) |
| 124 pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; | 125 pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC; |
| 125 } | |
| 126 InitFont(); | 126 InitFont(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 CFGAS_GEFont::~CFGAS_GEFont() { | 129 CFGAS_GEFont::~CFGAS_GEFont() { |
| 130 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) | 130 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) |
| 131 m_SubstFonts[i]->Release(); | 131 m_SubstFonts[i]->Release(); |
| 132 | 132 |
| 133 m_SubstFonts.RemoveAll(); | 133 m_SubstFonts.RemoveAll(); |
| 134 m_FontMapper.clear(); | 134 m_FontMapper.clear(); |
| 135 | 135 |
| 136 if (!m_bExternalFont) | 136 if (!m_bExternalFont) |
| 137 delete m_pFont; | 137 delete m_pFont; |
| 138 | 138 |
| 139 // If it is a shallow copy of another source font, | 139 // If it is a shallow copy of another source font, |
| 140 // decrease the refcount of the source font. | 140 // decrease the refcount of the source font. |
| 141 if (m_pSrcFont) | 141 if (m_pSrcFont) |
| 142 m_pSrcFont->Release(); | 142 m_pSrcFont->Release(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void CFGAS_GEFont::Release() { | 145 void CFGAS_GEFont::Release() { |
| 146 if (--m_iRefCount < 1) { | 146 if (--m_iRefCount < 1) { |
| 147 if (m_pFontMgr) { | 147 if (m_pFontMgr) |
| 148 m_pFontMgr->RemoveFont(this); | 148 m_pFontMgr->RemoveFont(this); |
| 149 } | |
| 150 delete this; | 149 delete this; |
| 151 } | 150 } |
| 152 } | 151 } |
| 153 CFGAS_GEFont* CFGAS_GEFont::Retain() { | 152 CFGAS_GEFont* CFGAS_GEFont::Retain() { |
| 154 ++m_iRefCount; | 153 ++m_iRefCount; |
| 155 return this; | 154 return this; |
| 156 } | 155 } |
| 157 | 156 |
| 158 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 157 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 159 bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, | 158 bool CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily, |
| 160 uint32_t dwFontStyles, | 159 uint32_t dwFontStyles, |
| 161 uint16_t wCodePage) { | 160 uint16_t wCodePage) { |
| 162 if (m_pFont) { | 161 if (m_pFont) |
| 163 return false; | 162 return false; |
| 164 } | |
| 165 CFX_ByteString csFontFamily; | 163 CFX_ByteString csFontFamily; |
| 166 if (pszFontFamily) { | 164 if (pszFontFamily) |
| 167 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); | 165 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); |
| 168 } | |
| 169 uint32_t dwFlags = 0; | 166 uint32_t dwFlags = 0; |
| 170 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { | 167 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) |
| 171 dwFlags |= FXFONT_FIXED_PITCH; | 168 dwFlags |= FXFONT_FIXED_PITCH; |
| 172 } | 169 if (dwFontStyles & FX_FONTSTYLE_Serif) |
| 173 if (dwFontStyles & FX_FONTSTYLE_Serif) { | |
| 174 dwFlags |= FXFONT_SERIF; | 170 dwFlags |= FXFONT_SERIF; |
| 175 } | 171 if (dwFontStyles & FX_FONTSTYLE_Symbolic) |
| 176 if (dwFontStyles & FX_FONTSTYLE_Symbolic) { | |
| 177 dwFlags |= FXFONT_SYMBOLIC; | 172 dwFlags |= FXFONT_SYMBOLIC; |
| 178 } | 173 if (dwFontStyles & FX_FONTSTYLE_Script) |
| 179 if (dwFontStyles & FX_FONTSTYLE_Script) { | |
| 180 dwFlags |= FXFONT_SCRIPT; | 174 dwFlags |= FXFONT_SCRIPT; |
| 181 } | 175 if (dwFontStyles & FX_FONTSTYLE_Italic) |
| 182 if (dwFontStyles & FX_FONTSTYLE_Italic) { | |
| 183 dwFlags |= FXFONT_ITALIC; | 176 dwFlags |= FXFONT_ITALIC; |
| 184 } | 177 if (dwFontStyles & FX_FONTSTYLE_Bold) |
| 185 if (dwFontStyles & FX_FONTSTYLE_Bold) { | |
| 186 dwFlags |= FXFONT_BOLD; | 178 dwFlags |= FXFONT_BOLD; |
| 187 } | 179 if (dwFontStyles & FX_FONTSTYLE_ExactMatch) |
| 188 if (dwFontStyles & FX_FONTSTYLE_ExactMatch) { | |
| 189 dwFlags |= FXFONT_EXACTMATCH; | 180 dwFlags |= FXFONT_EXACTMATCH; |
| 190 } | |
| 191 int32_t iWeight = | 181 int32_t iWeight = |
| 192 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; | 182 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; |
| 193 m_pFont = new CFX_Font; | 183 m_pFont = new CFX_Font; |
| 194 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { | 184 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) |
| 195 csFontFamily += ",BoldItalic"; | 185 csFontFamily += ",BoldItalic"; |
| 196 } else if (dwFlags & FXFONT_BOLD) { | 186 else if (dwFlags & FXFONT_BOLD) |
| 197 csFontFamily += ",Bold"; | 187 csFontFamily += ",Bold"; |
| 198 } else if (dwFlags & FXFONT_ITALIC) { | 188 else if (dwFlags & FXFONT_ITALIC) |
| 199 csFontFamily += ",Italic"; | 189 csFontFamily += ",Italic"; |
| 200 } | |
| 201 m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false); | 190 m_pFont->LoadSubst(csFontFamily, true, dwFlags, iWeight, 0, wCodePage, false); |
| 202 if (!m_pFont->GetFace()) | 191 if (!m_pFont->GetFace()) |
| 203 return false; | 192 return false; |
| 204 return InitFont(); | 193 return InitFont(); |
| 205 } | 194 } |
| 206 | 195 |
| 207 bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { | 196 bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { |
| 208 if (m_pFont) | 197 if (m_pFont) |
| 209 return false; | 198 return false; |
| 210 | 199 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 237 } |
| 249 | 238 |
| 250 bool CFGAS_GEFont::InitFont() { | 239 bool CFGAS_GEFont::InitFont() { |
| 251 if (!m_pFont) | 240 if (!m_pFont) |
| 252 return false; | 241 return false; |
| 253 if (!m_pFontEncoding) { | 242 if (!m_pFontEncoding) { |
| 254 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); | 243 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); |
| 255 if (!m_pFontEncoding) | 244 if (!m_pFontEncoding) |
| 256 return false; | 245 return false; |
| 257 } | 246 } |
| 258 if (!m_pCharWidthMap) | 247 if (!m_pCharWidthMap) { |
| 259 m_pCharWidthMap.reset(new CFX_DiscreteArrayTemplate<uint16_t>(1024)); | 248 m_pCharWidthMap = |
| 249 pdfium::MakeUnique<CFX_DiscreteArrayTemplate<uint16_t>>(1024); |
| 250 } |
| 260 if (!m_pRectArray) | 251 if (!m_pRectArray) |
| 261 m_pRectArray.reset(new CFX_MassArrayTemplate<CFX_Rect>(16)); | 252 m_pRectArray = pdfium::MakeUnique<CFX_MassArrayTemplate<CFX_Rect>>(16); |
| 262 if (!m_pBBoxMap) | 253 if (!m_pBBoxMap) |
| 263 m_pBBoxMap.reset(new CFX_MapPtrToPtr(16)); | 254 m_pBBoxMap = pdfium::MakeUnique<CFX_MapPtrToPtr>(16); |
| 264 | 255 |
| 265 return true; | 256 return true; |
| 266 } | 257 } |
| 267 | 258 |
| 268 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { | 259 CFGAS_GEFont* CFGAS_GEFont::Derive(uint32_t dwFontStyles, uint16_t wCodePage) { |
| 269 if (GetFontStyles() == dwFontStyles) | 260 if (GetFontStyles() == dwFontStyles) |
| 270 return Retain(); | 261 return Retain(); |
| 271 return new CFGAS_GEFont(this, dwFontStyles); | 262 return new CFGAS_GEFont(this, dwFontStyles); |
| 272 } | 263 } |
| 273 | 264 |
| 274 void CFGAS_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { | 265 CFX_WideString CFGAS_GEFont::GetFamilyName() const { |
| 275 if (!m_pFont->GetSubstFont() || | 266 if (!m_pFont->GetSubstFont() || |
| 276 m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { | 267 m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { |
| 277 wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); | 268 return CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); |
| 278 } else { | |
| 279 wsFamily = CFX_WideString::FromLocal( | |
| 280 m_pFont->GetSubstFont()->m_Family.AsStringC()); | |
| 281 } | 269 } |
| 270 return CFX_WideString::FromLocal( |
| 271 m_pFont->GetSubstFont()->m_Family.AsStringC()); |
| 282 } | 272 } |
| 283 | 273 |
| 284 uint32_t CFGAS_GEFont::GetFontStyles() const { | 274 uint32_t CFGAS_GEFont::GetFontStyles() const { |
| 285 ASSERT(m_pFont); | 275 ASSERT(m_pFont); |
| 286 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 276 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 287 if (m_bUseLogFontStyle) | 277 if (m_bUseLogFontStyle) |
| 288 return m_dwLogFontStyle; | 278 return m_dwLogFontStyle; |
| 289 #endif | 279 #endif |
| 290 | 280 |
| 291 uint32_t dwStyles = 0; | 281 uint32_t dwStyles = 0; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 322 if (iWidth > 0) | 312 if (iWidth > 0) |
| 323 return true; | 313 return true; |
| 324 | 314 |
| 325 if (!m_pProvider || | 315 if (!m_pProvider || |
| 326 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { | 316 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { |
| 327 CFGAS_GEFont* pFont = nullptr; | 317 CFGAS_GEFont* pFont = nullptr; |
| 328 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); | 318 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); |
| 329 if (iGlyph != 0xFFFF && pFont) { | 319 if (iGlyph != 0xFFFF && pFont) { |
| 330 if (pFont == this) { | 320 if (pFont == this) { |
| 331 iWidth = m_pFont->GetGlyphWidth(iGlyph); | 321 iWidth = m_pFont->GetGlyphWidth(iGlyph); |
| 332 if (iWidth < 0) { | 322 if (iWidth < 0) |
| 333 iWidth = -1; | 323 iWidth = -1; |
| 334 } | |
| 335 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, | 324 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, |
| 336 bCharCode)) { | 325 bCharCode)) { |
| 337 return true; | 326 return true; |
| 338 } | 327 } |
| 339 } else { | 328 } else { |
| 340 iWidth = -1; | 329 iWidth = -1; |
| 341 } | 330 } |
| 342 } | 331 } |
| 343 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); | 332 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); |
| 344 return iWidth > 0; | 333 return iWidth > 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 374 return true; | 363 return true; |
| 375 } | 364 } |
| 376 } | 365 } |
| 377 } | 366 } |
| 378 if (!pRect) | 367 if (!pRect) |
| 379 return false; | 368 return false; |
| 380 | 369 |
| 381 bbox = *static_cast<const CFX_Rect*>(pRect); | 370 bbox = *static_cast<const CFX_Rect*>(pRect); |
| 382 return true; | 371 return true; |
| 383 } | 372 } |
| 373 |
| 384 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { | 374 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { |
| 385 FX_RECT rt(0, 0, 0, 0); | 375 FX_RECT rt(0, 0, 0, 0); |
| 386 bool bRet = m_pFont->GetBBox(rt); | 376 if (!m_pFont->GetBBox(rt)) |
| 387 if (bRet) { | 377 return false; |
| 388 bbox.left = rt.left; | 378 bbox.left = rt.left; |
| 389 bbox.width = rt.Width(); | 379 bbox.width = rt.Width(); |
| 390 bbox.top = rt.bottom; | 380 bbox.top = rt.bottom; |
| 391 bbox.height = -rt.Height(); | 381 bbox.height = -rt.Height(); |
| 392 } | 382 return true; |
| 393 return bRet; | |
| 394 } | 383 } |
| 395 int32_t CFGAS_GEFont::GetItalicAngle() const { | 384 |
| 396 if (!m_pFont->GetSubstFont()) { | |
| 397 return 0; | |
| 398 } | |
| 399 return m_pFont->GetSubstFont()->m_ItalicAngle; | |
| 400 } | |
| 401 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) { | 385 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) { |
| 402 return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); | 386 return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); |
| 403 } | 387 } |
| 388 |
| 404 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, | 389 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
| 405 bool bRecursive, | 390 bool bRecursive, |
| 406 CFGAS_GEFont** ppFont, | 391 CFGAS_GEFont** ppFont, |
| 407 bool bCharCode) { | 392 bool bCharCode) { |
| 408 ASSERT(m_pFontEncoding); | 393 ASSERT(m_pFontEncoding); |
| 409 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); | 394 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); |
| 410 if (iGlyphIndex > 0) { | 395 if (iGlyphIndex > 0) { |
| 411 if (ppFont) { | 396 if (ppFont) |
| 412 *ppFont = this; | 397 *ppFont = this; |
| 413 } | |
| 414 return iGlyphIndex; | 398 return iGlyphIndex; |
| 415 } | 399 } |
| 416 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); | 400 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); |
| 417 if (!pFontUSB) { | 401 if (!pFontUSB) |
| 418 return 0xFFFF; | 402 return 0xFFFF; |
| 419 } | 403 |
| 420 uint16_t wBitField = pFontUSB->wBitField; | 404 uint16_t wBitField = pFontUSB->wBitField; |
| 421 if (wBitField >= 128) { | 405 if (wBitField >= 128) |
| 422 return 0xFFFF; | 406 return 0xFFFF; |
| 423 } | 407 |
| 424 auto it = m_FontMapper.find(wUnicode); | 408 auto it = m_FontMapper.find(wUnicode); |
| 425 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; | 409 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; |
| 426 if (pFont && pFont != this) { | 410 if (pFont && pFont != this) { |
| 427 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); | 411 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); |
| 428 if (iGlyphIndex != 0xFFFF) { | 412 if (iGlyphIndex != 0xFFFF) { |
| 429 int32_t i = m_SubstFonts.Find(pFont); | 413 int32_t i = m_SubstFonts.Find(pFont); |
| 430 if (i > -1) { | 414 if (i > -1) { |
| 431 iGlyphIndex |= ((i + 1) << 24); | 415 iGlyphIndex |= ((i + 1) << 24); |
| 432 if (ppFont) | 416 if (ppFont) |
| 433 *ppFont = pFont; | 417 *ppFont = pFont; |
| 434 return iGlyphIndex; | 418 return iGlyphIndex; |
| 435 } | 419 } |
| 436 } | 420 } |
| 437 } | 421 } |
| 438 if (m_pFontMgr && bRecursive) { | 422 if (!m_pFontMgr || !bRecursive) |
| 439 CFX_WideString wsFamily; | 423 return 0xFFFF; |
| 440 GetFamilyName(wsFamily); | 424 CFX_WideString wsFamily = GetFamilyName(); |
| 441 CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode( | 425 pFont = |
| 442 wUnicode, GetFontStyles(), wsFamily.c_str()); | 426 m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str()); |
| 443 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 427 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 444 if (!pFont) | 428 if (!pFont) |
| 445 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); | 429 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); |
| 446 #endif | 430 #endif |
| 447 if (pFont) { | 431 if (!pFont) |
| 448 if (pFont == this) { | 432 return 0xFFFF; |
| 449 pFont->Release(); | 433 if (pFont == this) { |
| 450 return 0xFFFF; | 434 pFont->Release(); |
| 451 } | 435 return 0xFFFF; |
| 452 m_FontMapper[wUnicode] = pFont; | |
| 453 int32_t i = m_SubstFonts.GetSize(); | |
| 454 m_SubstFonts.Add(pFont); | |
| 455 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); | |
| 456 if (iGlyphIndex != 0xFFFF) { | |
| 457 iGlyphIndex |= ((i + 1) << 24); | |
| 458 if (ppFont) | |
| 459 *ppFont = pFont; | |
| 460 return iGlyphIndex; | |
| 461 } | |
| 462 } | |
| 463 } | 436 } |
| 464 return 0xFFFF; | 437 m_FontMapper[wUnicode] = pFont; |
| 438 int32_t i = m_SubstFonts.GetSize(); |
| 439 m_SubstFonts.Add(pFont); |
| 440 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); |
| 441 if (iGlyphIndex == 0xFFFF) |
| 442 return 0xFFFF; |
| 443 iGlyphIndex |= ((i + 1) << 24); |
| 444 if (ppFont) |
| 445 *ppFont = pFont; |
| 446 return iGlyphIndex; |
| 465 } | 447 } |
| 448 |
| 466 int32_t CFGAS_GEFont::GetAscent() const { | 449 int32_t CFGAS_GEFont::GetAscent() const { |
| 467 return m_pFont->GetAscent(); | 450 return m_pFont->GetAscent(); |
| 468 } | 451 } |
| 452 |
| 469 int32_t CFGAS_GEFont::GetDescent() const { | 453 int32_t CFGAS_GEFont::GetDescent() const { |
| 470 return m_pFont->GetDescent(); | 454 return m_pFont->GetDescent(); |
| 471 } | 455 } |
| 472 void CFGAS_GEFont::Reset() { | 456 |
| 473 for (int32_t i = 0; i < m_SubstFonts.GetSize(); i++) | |
| 474 m_SubstFonts[i]->Reset(); | |
| 475 if (m_pCharWidthMap) { | |
| 476 m_pCharWidthMap->RemoveAll(); | |
| 477 } | |
| 478 if (m_pBBoxMap) { | |
| 479 m_pBBoxMap->RemoveAll(); | |
| 480 } | |
| 481 if (m_pRectArray) { | |
| 482 m_pRectArray->RemoveAll(false); | |
| 483 } | |
| 484 } | |
| 485 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 457 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
| 486 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; | 458 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; |
| 487 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 459 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
| 488 : m_SubstFonts[iGlyphIndex - 1]; | 460 : m_SubstFonts[iGlyphIndex - 1]; |
| 489 } | 461 } |
| OLD | NEW |