Chromium Code Reviews| 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 "../../../include/fpdfapi/fpdf_module.h" | 7 #include "../../../include/fpdfapi/fpdf_module.h" |
| 8 #include "../../../include/fpdfapi/fpdf_page.h" | 8 #include "../../../include/fpdfapi/fpdf_page.h" |
| 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
| 10 #include "../../../include/fpdfapi/fpdf_resource.h" | 10 #include "../../../include/fpdfapi/fpdf_resource.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 } | 112 } |
| 113 CPDF_Font::~CPDF_Font() { | 113 CPDF_Font::~CPDF_Font() { |
| 114 delete m_pCharMap; | 114 delete m_pCharMap; |
| 115 m_pCharMap = NULL; | 115 m_pCharMap = NULL; |
| 116 | 116 |
| 117 delete m_pToUnicodeMap; | 117 delete m_pToUnicodeMap; |
| 118 m_pToUnicodeMap = NULL; | 118 m_pToUnicodeMap = NULL; |
| 119 | 119 |
| 120 if (m_pFontFile) { | 120 if (m_pFontFile) { |
| 121 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( | 121 m_pDocument->GetPageData()->ReleaseFontFileStreamAcc( |
| 122 (CPDF_Stream*)m_pFontFile->GetStream()); | 122 const_cast<CPDF_Stream*>(m_pFontFile->GetStream()->AsStream())); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 FX_BOOL CPDF_Font::IsVertWriting() const { | 125 FX_BOOL CPDF_Font::IsVertWriting() const { |
| 126 FX_BOOL bVertWriting = FALSE; | 126 FX_BOOL bVertWriting = FALSE; |
| 127 CPDF_CIDFont* pCIDFont = GetCIDFont(); | 127 CPDF_CIDFont* pCIDFont = GetCIDFont(); |
| 128 if (pCIDFont) { | 128 if (pCIDFont) { |
| 129 bVertWriting = pCIDFont->IsVertWriting(); | 129 bVertWriting = pCIDFont->IsVertWriting(); |
| 130 } else { | 130 } else { |
| 131 bVertWriting = m_Font.IsVertical(); | 131 bVertWriting = m_Font.IsVertical(); |
| 132 } | 132 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 m_Descent = -m_Descent; | 251 m_Descent = -m_Descent; |
| 252 } | 252 } |
| 253 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); | 253 CPDF_Array* pBBox = pFontDesc->GetArray(FX_BSTRC("FontBBox")); |
| 254 if (pBBox) { | 254 if (pBBox) { |
| 255 m_FontBBox.left = pBBox->GetInteger(0); | 255 m_FontBBox.left = pBBox->GetInteger(0); |
| 256 m_FontBBox.bottom = pBBox->GetInteger(1); | 256 m_FontBBox.bottom = pBBox->GetInteger(1); |
| 257 m_FontBBox.right = pBBox->GetInteger(2); | 257 m_FontBBox.right = pBBox->GetInteger(2); |
| 258 m_FontBBox.top = pBBox->GetInteger(3); | 258 m_FontBBox.top = pBBox->GetInteger(3); |
| 259 } | 259 } |
| 260 CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); | 260 CPDF_Stream* pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile")); |
| 261 if (pFontFile == NULL) { | 261 if (!pFontFile) |
| 262 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); | 262 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile2")); |
| 263 } | 263 if (!pFontFile) |
| 264 if (pFontFile == NULL) { | |
| 265 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); | 264 pFontFile = pFontDesc->GetStream(FX_BSTRC("FontFile3")); |
| 266 } | 265 if (!pFontFile) |
| 267 if (pFontFile) { | 266 return; |
| 268 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); | 267 |
| 269 if (m_pFontFile == NULL) { | 268 m_pFontFile = m_pDocument->LoadFontFile(pFontFile); |
| 270 return; | 269 if (!m_pFontFile) |
| 271 } | 270 return; |
| 272 const uint8_t* pFontData = m_pFontFile->GetData(); | 271 |
| 273 FX_DWORD dwFontSize = m_pFontFile->GetSize(); | 272 const uint8_t* pFontData = m_pFontFile->GetData(); |
|
dsinclair
2015/10/22 19:54:50
This method conflicted. The code below here is dif
Tom Sepez
2015/10/22 20:44:44
OK for now, but its most likely that master is rig
| |
| 274 m_Font.LoadEmbedded(pFontData, dwFontSize); | 273 FX_DWORD dwFontSize = m_pFontFile->GetSize(); |
| 275 if (m_Font.m_Face == NULL) { | 274 m_Font.LoadEmbedded(pFontData, dwFontSize); |
| 276 m_pFontFile = NULL; | 275 if (!m_Font.m_Face) |
| 277 } | 276 m_pFontFile = nullptr; |
| 278 } | |
| 279 } | 277 } |
| 280 short TT2PDF(int m, FXFT_Face face) { | 278 short TT2PDF(int m, FXFT_Face face) { |
| 281 int upm = FXFT_Get_Face_UnitsPerEM(face); | 279 int upm = FXFT_Get_Face_UnitsPerEM(face); |
| 282 if (upm == 0) { | 280 if (upm == 0) { |
| 283 return (short)m; | 281 return (short)m; |
| 284 } | 282 } |
| 285 return (m * 1000 + upm / 2) / upm; | 283 return (m * 1000 + upm / 2) / upm; |
| 286 } | 284 } |
| 287 void CPDF_Font::CheckFontMetrics() { | 285 void CPDF_Font::CheckFontMetrics() { |
| 288 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && | 286 if (m_FontBBox.top == 0 && m_FontBBox.bottom == 0 && m_FontBBox.left == 0 && |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1703 } | 1701 } |
| 1704 } | 1702 } |
| 1705 } | 1703 } |
| 1706 } | 1704 } |
| 1707 return TRUE; | 1705 return TRUE; |
| 1708 } | 1706 } |
| 1709 void CPDF_Type3Font::CheckType3FontMetrics() { | 1707 void CPDF_Type3Font::CheckType3FontMetrics() { |
| 1710 CheckFontMetrics(); | 1708 CheckFontMetrics(); |
| 1711 } | 1709 } |
| 1712 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) { | 1710 CPDF_Type3Char* CPDF_Type3Font::LoadChar(FX_DWORD charcode, int level) { |
| 1713 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) { | 1711 if (level >= _FPDF_MAX_TYPE3_FORM_LEVEL_) |
| 1714 return NULL; | 1712 return nullptr; |
| 1715 } | 1713 |
| 1716 CPDF_Type3Char* pChar = NULL; | 1714 CPDF_Type3Char* pChar = nullptr; |
| 1717 if (m_CacheMap.Lookup((void*)(uintptr_t)charcode, (void*&)pChar)) { | 1715 if (m_CacheMap.Lookup((void*)(uintptr_t)charcode, (void*&)pChar)) { |
| 1718 if (pChar->m_bPageRequired && m_pPageResources) { | 1716 if (pChar->m_bPageRequired && m_pPageResources) { |
| 1719 delete pChar; | 1717 delete pChar; |
| 1720 m_CacheMap.RemoveKey((void*)(uintptr_t)charcode); | 1718 m_CacheMap.RemoveKey((void*)(uintptr_t)charcode); |
| 1721 return LoadChar(charcode, level + 1); | 1719 return LoadChar(charcode, level + 1); |
| 1722 } | 1720 } |
| 1723 return pChar; | 1721 return pChar; |
| 1724 } | 1722 } |
| 1725 const FX_CHAR* name = | 1723 const FX_CHAR* name = |
| 1726 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); | 1724 GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode); |
| 1727 if (name == NULL) { | 1725 if (!name) |
| 1728 return NULL; | 1726 return nullptr; |
| 1729 } | 1727 |
| 1730 CPDF_Stream* pStream = | 1728 CPDF_Stream* pStream = |
| 1731 (CPDF_Stream*)(m_pCharProcs ? m_pCharProcs->GetElementValue(name) : NULL); | 1729 ToStream(m_pCharProcs ? m_pCharProcs->GetElementValue(name) : nullptr); |
| 1732 if (pStream == NULL || pStream->GetType() != PDFOBJ_STREAM) { | 1730 if (!pStream) |
| 1733 return NULL; | 1731 return nullptr; |
| 1734 } | 1732 |
| 1735 pChar = new CPDF_Type3Char; | 1733 pChar = new CPDF_Type3Char; |
| 1736 pChar->m_pForm = new CPDF_Form( | 1734 pChar->m_pForm = new CPDF_Form( |
| 1737 m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, | 1735 m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources, |
| 1738 pStream, NULL); | 1736 pStream, nullptr); |
| 1739 pChar->m_pForm->ParseContent(NULL, NULL, pChar, NULL, level + 1); | 1737 pChar->m_pForm->ParseContent(nullptr, nullptr, pChar, nullptr, level + 1); |
| 1740 FX_FLOAT scale = m_FontMatrix.GetXUnit(); | 1738 FX_FLOAT scale = m_FontMatrix.GetXUnit(); |
| 1741 pChar->m_Width = (int32_t)(pChar->m_Width * scale + 0.5f); | 1739 pChar->m_Width = (int32_t)(pChar->m_Width * scale + 0.5f); |
| 1742 FX_RECT& rcBBox = pChar->m_BBox; | 1740 FX_RECT& rcBBox = pChar->m_BBox; |
| 1743 CFX_FloatRect char_rect( | 1741 CFX_FloatRect char_rect( |
| 1744 (FX_FLOAT)rcBBox.left / 1000.0f, (FX_FLOAT)rcBBox.bottom / 1000.0f, | 1742 (FX_FLOAT)rcBBox.left / 1000.0f, (FX_FLOAT)rcBBox.bottom / 1000.0f, |
| 1745 (FX_FLOAT)rcBBox.right / 1000.0f, (FX_FLOAT)rcBBox.top / 1000.0f); | 1743 (FX_FLOAT)rcBBox.right / 1000.0f, (FX_FLOAT)rcBBox.top / 1000.0f); |
| 1746 if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) { | 1744 if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) { |
| 1747 char_rect = pChar->m_pForm->CalcBoundingBox(); | 1745 char_rect = pChar->m_pForm->CalcBoundingBox(); |
| 1748 } | 1746 } |
| 1749 char_rect.Transform(&m_FontMatrix); | 1747 char_rect.Transform(&m_FontMatrix); |
| 1750 rcBBox.left = FXSYS_round(char_rect.left * 1000); | 1748 rcBBox.left = FXSYS_round(char_rect.left * 1000); |
| 1751 rcBBox.right = FXSYS_round(char_rect.right * 1000); | 1749 rcBBox.right = FXSYS_round(char_rect.right * 1000); |
| 1752 rcBBox.top = FXSYS_round(char_rect.top * 1000); | 1750 rcBBox.top = FXSYS_round(char_rect.top * 1000); |
| 1753 rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000); | 1751 rcBBox.bottom = FXSYS_round(char_rect.bottom * 1000); |
| 1754 m_CacheMap.SetAt((void*)(uintptr_t)charcode, pChar); | 1752 m_CacheMap.SetAt((void*)(uintptr_t)charcode, pChar); |
| 1755 if (pChar->m_pForm->CountObjects() == 0) { | 1753 if (pChar->m_pForm->CountObjects() == 0) { |
| 1756 delete pChar->m_pForm; | 1754 delete pChar->m_pForm; |
| 1757 pChar->m_pForm = NULL; | 1755 pChar->m_pForm = nullptr; |
| 1758 } | 1756 } |
| 1759 return pChar; | 1757 return pChar; |
| 1760 } | 1758 } |
| 1761 int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) { | 1759 int CPDF_Type3Font::GetCharWidthF(FX_DWORD charcode, int level) { |
| 1762 if (charcode > 0xff) { | 1760 if (charcode > 0xff) { |
| 1763 charcode = 0; | 1761 charcode = 0; |
| 1764 } | 1762 } |
| 1765 if (m_CharWidthL[charcode]) { | 1763 if (m_CharWidthL[charcode]) { |
| 1766 return m_CharWidthL[charcode]; | 1764 return m_CharWidthL[charcode]; |
| 1767 } | 1765 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1782 CPDF_Type3Char::CPDF_Type3Char() { | 1780 CPDF_Type3Char::CPDF_Type3Char() { |
| 1783 m_pForm = NULL; | 1781 m_pForm = NULL; |
| 1784 m_pBitmap = NULL; | 1782 m_pBitmap = NULL; |
| 1785 m_bPageRequired = FALSE; | 1783 m_bPageRequired = FALSE; |
| 1786 m_bColored = FALSE; | 1784 m_bColored = FALSE; |
| 1787 } | 1785 } |
| 1788 CPDF_Type3Char::~CPDF_Type3Char() { | 1786 CPDF_Type3Char::~CPDF_Type3Char() { |
| 1789 delete m_pForm; | 1787 delete m_pForm; |
| 1790 delete m_pBitmap; | 1788 delete m_pBitmap; |
| 1791 } | 1789 } |
| OLD | NEW |