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

Side by Side Diff: xfa/src/fgas/src/font/fx_gefont.cpp

Issue 1411833003: XFA: Manually apply changes to fpdf_text.h and fx_font.h from master (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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/src/fdp/src/fde/fde_gedevice.cpp ('k') | xfa/src/fgas/src/font/fx_stdfontmgr.cpp » ('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 "../fgas_base.h" 7 #include "../fgas_base.h"
8 #include "fx_gefont.h" 8 #include "fx_gefont.h"
9 #include "fx_fontutils.h" 9 #include "fx_fontutils.h"
10 #ifndef _FXPLUS 10 #ifndef _FXPLUS
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 m_pRectArray(NULL), 125 m_pRectArray(NULL),
126 m_pBBoxMap(NULL), 126 m_pBBoxMap(NULL),
127 m_pProvider(NULL), 127 m_pProvider(NULL),
128 m_wCharSet(0xFFFF), 128 m_wCharSet(0xFFFF),
129 m_SubstFonts(), 129 m_SubstFonts(),
130 m_FontMapper(16) { 130 m_FontMapper(16) {
131 m_pFont = new CFX_Font; 131 m_pFont = new CFX_Font;
132 FXSYS_assert(m_pFont != NULL); 132 FXSYS_assert(m_pFont != NULL);
133 FXSYS_assert(src.m_pFont != NULL); 133 FXSYS_assert(src.m_pFont != NULL);
134 m_pFont->LoadClone(src.m_pFont); 134 m_pFont->LoadClone(src.m_pFont);
135 CFX_SubstFont*& pSubst = m_pFont->m_pSubstFont; 135 CFX_SubstFont* pSubst = m_pFont->GetSubstFont();
136 if (pSubst == NULL) { 136 if (!pSubst) {
137 pSubst = new CFX_SubstFont; 137 pSubst = new CFX_SubstFont;
138 m_pFont->SetSubstFont(pSubst);
138 } 139 }
139 if (pSubst) { 140 pSubst->m_Weight =
140 pSubst->m_Weight = 141 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL;
141 (dwFontStyles & FX_FONTSTYLE_Bold) ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL; 142 if (dwFontStyles & FX_FONTSTYLE_Italic) {
142 if (dwFontStyles & FX_FONTSTYLE_Italic) { 143 pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC;
143 pSubst->m_SubstFlags |= FXFONT_SUBST_ITALIC;
144 }
145 } 144 }
146 InitFont(); 145 InitFont();
147 } 146 }
148 CFX_GEFont::~CFX_GEFont() { 147 CFX_GEFont::~CFX_GEFont() {
149 int32_t iCount = m_SubstFonts.GetSize(); 148 int32_t iCount = m_SubstFonts.GetSize();
150 for (int32_t i = 0; i < iCount; i++) { 149 for (int32_t i = 0; i < iCount; i++) {
151 IFX_Font* pFont = (IFX_Font*)m_SubstFonts[i]; 150 IFX_Font* pFont = (IFX_Font*)m_SubstFonts[i];
152 pFont->Release(); 151 pFont->Release();
153 } 152 }
154 m_SubstFonts.RemoveAll(); 153 m_SubstFonts.RemoveAll();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 m_wCharSet = wCharSet; 228 m_wCharSet = wCharSet;
230 m_pFont = new CFX_Font; 229 m_pFont = new CFX_Font;
231 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) { 230 if ((dwFlags & FXFONT_ITALIC) && (dwFlags & FXFONT_BOLD)) {
232 csFontFamily += ",BoldItalic"; 231 csFontFamily += ",BoldItalic";
233 } else if (dwFlags & FXFONT_BOLD) { 232 } else if (dwFlags & FXFONT_BOLD) {
234 csFontFamily += ",Bold"; 233 csFontFamily += ",Bold";
235 } else if (dwFlags & FXFONT_ITALIC) { 234 } else if (dwFlags & FXFONT_ITALIC) {
236 csFontFamily += ",Italic"; 235 csFontFamily += ",Italic";
237 } 236 }
238 m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage); 237 m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage);
239 FX_BOOL bRet = m_pFont->m_Face != nullptr; 238 FX_BOOL bRet = m_pFont->GetFace() != nullptr;
240 if (bRet) { 239 if (bRet) {
241 InitFont(); 240 InitFont();
242 } 241 }
243 Unlock(); 242 Unlock();
244 return bRet; 243 return bRet;
245 } 244 }
246 FX_BOOL CFX_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) { 245 FX_BOOL CFX_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) {
247 if (m_pFont != NULL) { 246 if (m_pFont != NULL) {
248 return FALSE; 247 return FALSE;
249 } 248 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 if (GetFontStyles() == dwFontStyles) { 351 if (GetFontStyles() == dwFontStyles) {
353 return Retain(); 352 return Retain();
354 } 353 }
355 return new CFX_GEFont(*this, dwFontStyles); 354 return new CFX_GEFont(*this, dwFontStyles);
356 } 355 }
357 uint8_t CFX_GEFont::GetCharSet() const { 356 uint8_t CFX_GEFont::GetCharSet() const {
358 FXSYS_assert(m_pFont != NULL); 357 FXSYS_assert(m_pFont != NULL);
359 if (m_wCharSet != 0xFFFF) { 358 if (m_wCharSet != 0xFFFF) {
360 return (uint8_t)m_wCharSet; 359 return (uint8_t)m_wCharSet;
361 } 360 }
362 if (m_pFont->m_pSubstFont == NULL) { 361 if (m_pFont->GetSubstFont() == NULL) {
Lei Zhang 2015/10/23 19:32:52 !foo, and below too.
Tom Sepez 2015/10/23 19:40:47 Done.
363 return FX_CHARSET_Default; 362 return FX_CHARSET_Default;
364 } 363 }
365 return m_pFont->m_pSubstFont->m_Charset; 364 return m_pFont->GetSubstFont()->m_Charset;
366 } 365 }
367 void CFX_GEFont::GetFamilyName(CFX_WideString& wsFamily) const { 366 void CFX_GEFont::GetFamilyName(CFX_WideString& wsFamily) const {
368 FXSYS_assert(m_pFont != NULL); 367 FXSYS_assert(m_pFont != NULL);
369 if (m_pFont->m_pSubstFont == NULL || 368 if (m_pFont->GetSubstFont() == NULL ||
370 m_pFont->m_pSubstFont->m_Family.GetLength() == 0) { 369 m_pFont->GetSubstFont()->m_Family.GetLength() == 0) {
371 wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName()); 370 wsFamily = CFX_WideString::FromLocal(m_pFont->GetFamilyName());
372 } else { 371 } else {
373 wsFamily = CFX_WideString::FromLocal(m_pFont->m_pSubstFont->m_Family); 372 wsFamily = CFX_WideString::FromLocal(m_pFont->GetSubstFont()->m_Family);
374 } 373 }
375 } 374 }
376 void CFX_GEFont::GetPsName(CFX_WideString& wsName) const { 375 void CFX_GEFont::GetPsName(CFX_WideString& wsName) const {
377 wsName = m_pFont->GetPsName(); 376 wsName = m_pFont->GetPsName();
378 } 377 }
379 FX_DWORD CFX_GEFont::GetFontStyles() const { 378 FX_DWORD CFX_GEFont::GetFontStyles() const {
380 FXSYS_assert(m_pFont != NULL); 379 FXSYS_assert(m_pFont != NULL);
381 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 380 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
382 if (m_bUseLogFontStyle) { 381 if (m_bUseLogFontStyle) {
383 return m_dwLogFontStyle; 382 return m_dwLogFontStyle;
384 } 383 }
385 #endif 384 #endif
386 FX_DWORD dwStyles = 0; 385 FX_DWORD dwStyles = 0;
387 if (m_pFont->m_pSubstFont == NULL) { 386 if (m_pFont->GetSubstFont() == NULL) {
388 if (m_pFont->IsBold()) { 387 if (m_pFont->IsBold()) {
389 dwStyles |= FX_FONTSTYLE_Bold; 388 dwStyles |= FX_FONTSTYLE_Bold;
390 } 389 }
391 if (m_pFont->IsItalic()) { 390 if (m_pFont->IsItalic()) {
392 dwStyles |= FX_FONTSTYLE_Italic; 391 dwStyles |= FX_FONTSTYLE_Italic;
393 } 392 }
394 } else { 393 } else {
395 if (m_pFont->m_pSubstFont->m_Weight == FXFONT_FW_BOLD) { 394 if (m_pFont->GetSubstFont()->m_Weight == FXFONT_FW_BOLD) {
396 dwStyles |= FX_FONTSTYLE_Bold; 395 dwStyles |= FX_FONTSTYLE_Bold;
397 } 396 }
398 if (m_pFont->m_pSubstFont->m_SubstFlags & FXFONT_SUBST_ITALIC) { 397 if (m_pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_ITALIC) {
399 dwStyles |= FX_FONTSTYLE_Italic; 398 dwStyles |= FX_FONTSTYLE_Italic;
400 } 399 }
401 } 400 }
402 return dwStyles; 401 return dwStyles;
403 } 402 }
404 FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode, 403 FX_BOOL CFX_GEFont::GetCharWidth(FX_WCHAR wUnicode,
405 int32_t& iWidth, 404 int32_t& iWidth,
406 FX_BOOL bCharCode) { 405 FX_BOOL bCharCode) {
407 return GetCharWidth(wUnicode, iWidth, TRUE, bCharCode); 406 return GetCharWidth(wUnicode, iWidth, TRUE, bCharCode);
408 } 407 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 FX_BOOL bRet = m_pFont->GetBBox(rt); 482 FX_BOOL bRet = m_pFont->GetBBox(rt);
484 if (bRet) { 483 if (bRet) {
485 bbox.left = rt.left; 484 bbox.left = rt.left;
486 bbox.width = rt.Width(); 485 bbox.width = rt.Width();
487 bbox.top = rt.bottom; 486 bbox.top = rt.bottom;
488 bbox.height = -rt.Height(); 487 bbox.height = -rt.Height();
489 } 488 }
490 return bRet; 489 return bRet;
491 } 490 }
492 int32_t CFX_GEFont::GetItalicAngle() const { 491 int32_t CFX_GEFont::GetItalicAngle() const {
493 if (m_pFont->m_pSubstFont == NULL) { 492 if (m_pFont->GetSubstFont() == NULL) {
494 return 0; 493 return 0;
495 } 494 }
496 return m_pFont->m_pSubstFont->m_ItalicAngle; 495 return m_pFont->GetSubstFont()->m_ItalicAngle;
497 } 496 }
498 int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) { 497 int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, FX_BOOL bCharCode) {
499 return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode); 498 return GetGlyphIndex(wUnicode, TRUE, NULL, bCharCode);
500 } 499 }
501 int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode, 500 int32_t CFX_GEFont::GetGlyphIndex(FX_WCHAR wUnicode,
502 FX_BOOL bRecursive, 501 FX_BOOL bRecursive,
503 IFX_Font** ppFont, 502 IFX_Font** ppFont,
504 FX_BOOL bCharCode) { 503 FX_BOOL bCharCode) {
505 FXSYS_assert(m_pFontEncoding != NULL); 504 FXSYS_assert(m_pFontEncoding != NULL);
506 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode); 505 int32_t iGlyphIndex = m_pFontEncoding->GlyphFromCharCode(wUnicode);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 m_pRectArray->RemoveAll(); 590 m_pRectArray->RemoveAll();
592 } 591 }
593 Unlock(); 592 Unlock();
594 } 593 }
595 IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const { 594 IFX_Font* CFX_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
596 iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24; 595 iGlyphIndex = ((FX_DWORD)iGlyphIndex) >> 24;
597 return iGlyphIndex == 0 ? (IFX_Font*)this 596 return iGlyphIndex == 0 ? (IFX_Font*)this
598 : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1]; 597 : (IFX_Font*)m_SubstFonts[iGlyphIndex - 1];
599 } 598 }
600 #endif 599 #endif
OLDNEW
« no previous file with comments | « xfa/src/fdp/src/fde/fde_gedevice.cpp ('k') | xfa/src/fgas/src/font/fx_stdfontmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698