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 "core/src/fpdfapi/fpdf_page/pageint.h" | 7 #include "core/src/fpdfapi/fpdf_page/pageint.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { | 65 void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { |
66 pInfo->m_CharCode = | 66 pInfo->m_CharCode = |
67 m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[index]; | 67 m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[index]; |
68 pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; | 68 pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; |
69 pInfo->m_OriginY = 0; | 69 pInfo->m_OriginY = 0; |
70 if (pInfo->m_CharCode == -1) { | 70 if (pInfo->m_CharCode == -1) { |
71 return; | 71 return; |
72 } | 72 } |
73 CPDF_Font* pFont = m_TextState.GetFont(); | 73 CPDF_Font* pFont = m_TextState.GetFont(); |
74 if (pFont->GetFontType() != PDFFONT_CIDFONT) { | 74 if (!pFont->IsCIDFont()) { |
75 return; | 75 return; |
76 } | 76 } |
77 if (!((CPDF_CIDFont*)pFont)->IsVertWriting()) { | 77 if (!pFont->AsCIDFont()->IsVertWriting()) { |
78 return; | 78 return; |
79 } | 79 } |
80 FX_WORD CID = ((CPDF_CIDFont*)pFont)->CIDFromCharCode(pInfo->m_CharCode); | 80 FX_WORD CID = pFont->AsCIDFont()->CIDFromCharCode(pInfo->m_CharCode); |
81 pInfo->m_OriginY = pInfo->m_OriginX; | 81 pInfo->m_OriginY = pInfo->m_OriginX; |
82 pInfo->m_OriginX = 0; | 82 pInfo->m_OriginX = 0; |
83 short vx, vy; | 83 short vx, vy; |
84 ((CPDF_CIDFont*)pFont)->GetVertOrigin(CID, vx, vy); | 84 pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); |
85 FX_FLOAT fontsize = m_TextState.GetFontSize(); | 85 FX_FLOAT fontsize = m_TextState.GetFontSize(); |
86 pInfo->m_OriginX -= fontsize * vx / 1000; | 86 pInfo->m_OriginX -= fontsize * vx / 1000; |
87 pInfo->m_OriginY -= fontsize * vy / 1000; | 87 pInfo->m_OriginY -= fontsize * vy / 1000; |
88 } | 88 } |
89 | 89 |
90 int CPDF_TextObject::CountChars() const { | 90 int CPDF_TextObject::CountChars() const { |
91 if (m_nChars == 1) { | 91 if (m_nChars == 1) { |
92 return 1; | 92 return 1; |
93 } | 93 } |
94 int count = 0; | 94 int count = 0; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 void CPDF_TextObject::SetText(const CFX_ByteString& str) { | 208 void CPDF_TextObject::SetText(const CFX_ByteString& str) { |
209 SetSegments(&str, nullptr, 1); | 209 SetSegments(&str, nullptr, 1); |
210 RecalcPositionData(); | 210 RecalcPositionData(); |
211 } | 211 } |
212 | 212 |
213 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const { | 213 FX_FLOAT CPDF_TextObject::GetCharWidth(FX_DWORD charcode) const { |
214 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; | 214 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; |
215 CPDF_Font* pFont = m_TextState.GetFont(); | 215 CPDF_Font* pFont = m_TextState.GetFont(); |
216 FX_BOOL bVertWriting = FALSE; | 216 FX_BOOL bVertWriting = FALSE; |
217 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 217 CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); |
218 if (pCIDFont) { | 218 if (pCIDFont) { |
219 bVertWriting = pCIDFont->IsVertWriting(); | 219 bVertWriting = pCIDFont->IsVertWriting(); |
220 } | 220 } |
221 if (!bVertWriting) | 221 if (!bVertWriting) |
222 return pFont->GetCharWidthF(charcode, 0) * fontsize; | 222 return pFont->GetCharWidthF(charcode, 0) * fontsize; |
223 | 223 |
224 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); | 224 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); |
225 return pCIDFont->GetVertWidth(CID) * fontsize; | 225 return pCIDFont->GetVertWidth(CID) * fontsize; |
226 } | 226 } |
227 | 227 |
228 void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, | 228 void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, |
229 FX_FLOAT* pTextAdvanceY, | 229 FX_FLOAT* pTextAdvanceY, |
230 FX_FLOAT horz_scale, | 230 FX_FLOAT horz_scale, |
231 int level) { | 231 int level) { |
232 FX_FLOAT curpos = 0; | 232 FX_FLOAT curpos = 0; |
233 FX_FLOAT min_x = 10000 * 1.0f; | 233 FX_FLOAT min_x = 10000 * 1.0f; |
234 FX_FLOAT max_x = -10000 * 1.0f; | 234 FX_FLOAT max_x = -10000 * 1.0f; |
235 FX_FLOAT min_y = 10000 * 1.0f; | 235 FX_FLOAT min_y = 10000 * 1.0f; |
236 FX_FLOAT max_y = -10000 * 1.0f; | 236 FX_FLOAT max_y = -10000 * 1.0f; |
237 CPDF_Font* pFont = m_TextState.GetFont(); | 237 CPDF_Font* pFont = m_TextState.GetFont(); |
238 FX_BOOL bVertWriting = FALSE; | 238 FX_BOOL bVertWriting = FALSE; |
239 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 239 CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); |
240 if (pCIDFont) { | 240 if (pCIDFont) { |
241 bVertWriting = pCIDFont->IsVertWriting(); | 241 bVertWriting = pCIDFont->IsVertWriting(); |
242 } | 242 } |
243 FX_FLOAT fontsize = m_TextState.GetFontSize(); | 243 FX_FLOAT fontsize = m_TextState.GetFontSize(); |
244 for (int i = 0; i < m_nChars; ++i) { | 244 for (int i = 0; i < m_nChars; ++i) { |
245 FX_DWORD charcode = | 245 FX_DWORD charcode = |
246 m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; | 246 m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i]; |
247 if (i > 0) { | 247 if (i > 0) { |
248 if (charcode == (FX_DWORD)-1) { | 248 if (charcode == (FX_DWORD)-1) { |
249 curpos -= (m_pCharPos[i - 1] * fontsize) / 1000; | 249 curpos -= (m_pCharPos[i - 1] * fontsize) / 1000; |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 matrix = m_PageMatrix; | 759 matrix = m_PageMatrix; |
760 matrix.Concat(display_matrix); | 760 matrix.Concat(display_matrix); |
761 } | 761 } |
762 | 762 |
763 CPDF_ParseOptions::CPDF_ParseOptions() { | 763 CPDF_ParseOptions::CPDF_ParseOptions() { |
764 m_bTextOnly = FALSE; | 764 m_bTextOnly = FALSE; |
765 m_bMarkedContent = TRUE; | 765 m_bMarkedContent = TRUE; |
766 m_bSeparateForm = TRUE; | 766 m_bSeparateForm = TRUE; |
767 m_bDecodeInlineImage = FALSE; | 767 m_bDecodeInlineImage = FALSE; |
768 } | 768 } |
OLD | NEW |