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 { |
266 CFX_WideString wsFamily; | |
275 if (!m_pFont->GetSubstFont() || | 267 if (!m_pFont->GetSubstFont() || |
276 m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { | 268 m_pFont->GetSubstFont()->m_Family.GetLength() == 0) { |
277 wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); | 269 wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName().AsStringC()); |
Tom Sepez
2016/11/21 21:17:51
nit: local not needed, just return CFX_WideString:
npm
2016/11/21 21:29:38
Done.
| |
278 } else { | 270 } else { |
279 wsFamily = CFX_WideString::FromLocal( | 271 wsFamily = CFX_WideString::FromLocal( |
280 m_pFont->GetSubstFont()->m_Family.AsStringC()); | 272 m_pFont->GetSubstFont()->m_Family.AsStringC()); |
281 } | 273 } |
274 return wsFamily; | |
282 } | 275 } |
283 | 276 |
284 uint32_t CFGAS_GEFont::GetFontStyles() const { | 277 uint32_t CFGAS_GEFont::GetFontStyles() const { |
285 ASSERT(m_pFont); | 278 ASSERT(m_pFont); |
286 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 279 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
287 if (m_bUseLogFontStyle) | 280 if (m_bUseLogFontStyle) |
288 return m_dwLogFontStyle; | 281 return m_dwLogFontStyle; |
289 #endif | 282 #endif |
290 | 283 |
291 uint32_t dwStyles = 0; | 284 uint32_t dwStyles = 0; |
(...skipping 30 matching lines...) Expand all Loading... | |
322 if (iWidth > 0) | 315 if (iWidth > 0) |
323 return true; | 316 return true; |
324 | 317 |
325 if (!m_pProvider || | 318 if (!m_pProvider || |
326 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { | 319 !m_pProvider->GetCharWidth(this, wUnicode, bCharCode, &iWidth)) { |
327 CFGAS_GEFont* pFont = nullptr; | 320 CFGAS_GEFont* pFont = nullptr; |
328 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); | 321 int32_t iGlyph = GetGlyphIndex(wUnicode, true, &pFont, bCharCode); |
329 if (iGlyph != 0xFFFF && pFont) { | 322 if (iGlyph != 0xFFFF && pFont) { |
330 if (pFont == this) { | 323 if (pFont == this) { |
331 iWidth = m_pFont->GetGlyphWidth(iGlyph); | 324 iWidth = m_pFont->GetGlyphWidth(iGlyph); |
332 if (iWidth < 0) { | 325 if (iWidth < 0) |
333 iWidth = -1; | 326 iWidth = -1; |
334 } | |
335 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, | 327 } else if (pFont->GetCharWidthInternal(wUnicode, iWidth, false, |
336 bCharCode)) { | 328 bCharCode)) { |
337 return true; | 329 return true; |
338 } | 330 } |
339 } else { | 331 } else { |
340 iWidth = -1; | 332 iWidth = -1; |
341 } | 333 } |
342 } | 334 } |
343 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); | 335 m_pCharWidthMap->SetAtGrow(wUnicode, iWidth); |
344 return iWidth > 0; | 336 return iWidth > 0; |
(...skipping 29 matching lines...) Expand all Loading... | |
374 return true; | 366 return true; |
375 } | 367 } |
376 } | 368 } |
377 } | 369 } |
378 if (!pRect) | 370 if (!pRect) |
379 return false; | 371 return false; |
380 | 372 |
381 bbox = *static_cast<const CFX_Rect*>(pRect); | 373 bbox = *static_cast<const CFX_Rect*>(pRect); |
382 return true; | 374 return true; |
383 } | 375 } |
376 | |
384 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { | 377 bool CFGAS_GEFont::GetBBox(CFX_Rect& bbox) { |
385 FX_RECT rt(0, 0, 0, 0); | 378 FX_RECT rt(0, 0, 0, 0); |
386 bool bRet = m_pFont->GetBBox(rt); | 379 if (!m_pFont->GetBBox(rt)) |
387 if (bRet) { | 380 return false; |
388 bbox.left = rt.left; | 381 bbox.left = rt.left; |
389 bbox.width = rt.Width(); | 382 bbox.width = rt.Width(); |
390 bbox.top = rt.bottom; | 383 bbox.top = rt.bottom; |
391 bbox.height = -rt.Height(); | 384 bbox.height = -rt.Height(); |
392 } | 385 return true; |
393 return bRet; | |
394 } | 386 } |
395 int32_t CFGAS_GEFont::GetItalicAngle() const { | 387 |
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) { | 388 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, bool bCharCode) { |
402 return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); | 389 return GetGlyphIndex(wUnicode, true, nullptr, bCharCode); |
403 } | 390 } |
391 | |
404 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, | 392 int32_t CFGAS_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, |
405 bool bRecursive, | 393 bool bRecursive, |
406 CFGAS_GEFont** ppFont, | 394 CFGAS_GEFont** ppFont, |
407 bool bCharCode) { | 395 bool bCharCode) { |
408 ASSERT(m_pFontEncoding); | 396 ASSERT(m_pFontEncoding); |
409 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); | 397 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); |
410 if (iGlyphIndex > 0) { | 398 if (iGlyphIndex > 0) { |
411 if (ppFont) { | 399 if (ppFont) |
412 *ppFont = this; | 400 *ppFont = this; |
413 } | |
414 return iGlyphIndex; | 401 return iGlyphIndex; |
415 } | 402 } |
416 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); | 403 const FGAS_FONTUSB* pFontUSB = FGAS_GetUnicodeBitField(wUnicode); |
417 if (!pFontUSB) { | 404 if (!pFontUSB) |
418 return 0xFFFF; | 405 return 0xFFFF; |
419 } | 406 |
420 uint16_t wBitField = pFontUSB->wBitField; | 407 uint16_t wBitField = pFontUSB->wBitField; |
421 if (wBitField >= 128) { | 408 if (wBitField >= 128) |
422 return 0xFFFF; | 409 return 0xFFFF; |
423 } | 410 |
424 auto it = m_FontMapper.find(wUnicode); | 411 auto it = m_FontMapper.find(wUnicode); |
425 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; | 412 CFGAS_GEFont* pFont = it != m_FontMapper.end() ? it->second : nullptr; |
426 if (pFont && pFont != this) { | 413 if (pFont && pFont != this) { |
427 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); | 414 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); |
428 if (iGlyphIndex != 0xFFFF) { | 415 if (iGlyphIndex != 0xFFFF) { |
429 int32_t i = m_SubstFonts.Find(pFont); | 416 int32_t i = m_SubstFonts.Find(pFont); |
430 if (i > -1) { | 417 if (i > -1) { |
431 iGlyphIndex |= ((i + 1) << 24); | 418 iGlyphIndex |= ((i + 1) << 24); |
432 if (ppFont) | 419 if (ppFont) |
433 *ppFont = pFont; | 420 *ppFont = pFont; |
434 return iGlyphIndex; | 421 return iGlyphIndex; |
435 } | 422 } |
436 } | 423 } |
437 } | 424 } |
438 if (m_pFontMgr && bRecursive) { | 425 if (!m_pFontMgr || !bRecursive) |
439 CFX_WideString wsFamily; | 426 return 0xFFFF; |
440 GetFamilyName(wsFamily); | 427 CFX_WideString wsFamily = GetFamilyName(); |
441 CFGAS_GEFont* pFont = m_pFontMgr->GetFontByUnicode( | 428 pFont = |
442 wUnicode, GetFontStyles(), wsFamily.c_str()); | 429 m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), wsFamily.c_str()); |
443 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 430 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
444 if (!pFont) | 431 if (!pFont) |
445 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); | 432 pFont = m_pFontMgr->GetFontByUnicode(wUnicode, GetFontStyles(), nullptr); |
446 #endif | 433 #endif |
447 if (pFont) { | 434 if (!pFont) |
448 if (pFont == this) { | 435 return 0xFFFF; |
449 pFont->Release(); | 436 if (pFont == this) { |
450 return 0xFFFF; | 437 pFont->Release(); |
451 } | 438 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 } | 439 } |
464 return 0xFFFF; | 440 m_FontMapper[wUnicode] = pFont; |
441 int32_t i = m_SubstFonts.GetSize(); | |
442 m_SubstFonts.Add(pFont); | |
443 iGlyphIndex = pFont->GetGlyphIndex(wUnicode, false, nullptr, bCharCode); | |
444 if (iGlyphIndex == 0xFFFF) | |
445 return 0xFFFF; | |
446 iGlyphIndex |= ((i + 1) << 24); | |
447 if (ppFont) | |
448 *ppFont = pFont; | |
449 return iGlyphIndex; | |
465 } | 450 } |
451 | |
466 int32_t CFGAS_GEFont::GetAscent() const { | 452 int32_t CFGAS_GEFont::GetAscent() const { |
467 return m_pFont->GetAscent(); | 453 return m_pFont->GetAscent(); |
468 } | 454 } |
455 | |
469 int32_t CFGAS_GEFont::GetDescent() const { | 456 int32_t CFGAS_GEFont::GetDescent() const { |
470 return m_pFont->GetDescent(); | 457 return m_pFont->GetDescent(); |
471 } | 458 } |
472 void CFGAS_GEFont::Reset() { | 459 |
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 { | 460 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
486 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; | 461 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; |
487 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 462 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
488 : m_SubstFonts[iGlyphIndex - 1]; | 463 : m_SubstFonts[iGlyphIndex - 1]; |
489 } | 464 } |
OLD | NEW |