OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfapi/fpdf_page/include/cpdf_textobject.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" |
8 | 8 |
9 CPDF_TextObject::CPDF_TextObject() | 9 CPDF_TextObject::CPDF_TextObject() |
10 : m_PosX(0), | 10 : m_PosX(0), |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (pInfo->m_CharCode == -1) { | 28 if (pInfo->m_CharCode == -1) { |
29 return; | 29 return; |
30 } | 30 } |
31 CPDF_Font* pFont = m_TextState.GetFont(); | 31 CPDF_Font* pFont = m_TextState.GetFont(); |
32 if (!pFont->IsCIDFont()) { | 32 if (!pFont->IsCIDFont()) { |
33 return; | 33 return; |
34 } | 34 } |
35 if (!pFont->AsCIDFont()->IsVertWriting()) { | 35 if (!pFont->AsCIDFont()->IsVertWriting()) { |
36 return; | 36 return; |
37 } | 37 } |
38 FX_WORD CID = pFont->AsCIDFont()->CIDFromCharCode(pInfo->m_CharCode); | 38 uint16_t CID = pFont->AsCIDFont()->CIDFromCharCode(pInfo->m_CharCode); |
39 pInfo->m_OriginY = pInfo->m_OriginX; | 39 pInfo->m_OriginY = pInfo->m_OriginX; |
40 pInfo->m_OriginX = 0; | 40 pInfo->m_OriginX = 0; |
41 short vx, vy; | 41 short vx, vy; |
42 pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); | 42 pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); |
43 FX_FLOAT fontsize = m_TextState.GetFontSize(); | 43 FX_FLOAT fontsize = m_TextState.GetFontSize(); |
44 pInfo->m_OriginX -= fontsize * vx / 1000; | 44 pInfo->m_OriginX -= fontsize * vx / 1000; |
45 pInfo->m_OriginY -= fontsize * vy / 1000; | 45 pInfo->m_OriginY -= fontsize * vy / 1000; |
46 } | 46 } |
47 | 47 |
48 int CPDF_TextObject::CountChars() const { | 48 int CPDF_TextObject::CountChars() const { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; | 172 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; |
173 CPDF_Font* pFont = m_TextState.GetFont(); | 173 CPDF_Font* pFont = m_TextState.GetFont(); |
174 FX_BOOL bVertWriting = FALSE; | 174 FX_BOOL bVertWriting = FALSE; |
175 CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); | 175 CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); |
176 if (pCIDFont) { | 176 if (pCIDFont) { |
177 bVertWriting = pCIDFont->IsVertWriting(); | 177 bVertWriting = pCIDFont->IsVertWriting(); |
178 } | 178 } |
179 if (!bVertWriting) | 179 if (!bVertWriting) |
180 return pFont->GetCharWidthF(charcode, 0) * fontsize; | 180 return pFont->GetCharWidthF(charcode, 0) * fontsize; |
181 | 181 |
182 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); | 182 uint16_t CID = pCIDFont->CIDFromCharCode(charcode); |
183 return pCIDFont->GetVertWidth(CID) * fontsize; | 183 return pCIDFont->GetVertWidth(CID) * fontsize; |
184 } | 184 } |
185 | 185 |
186 void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, | 186 void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX, |
187 FX_FLOAT* pTextAdvanceY, | 187 FX_FLOAT* pTextAdvanceY, |
188 FX_FLOAT horz_scale, | 188 FX_FLOAT horz_scale, |
189 int level) { | 189 int level) { |
190 FX_FLOAT curpos = 0; | 190 FX_FLOAT curpos = 0; |
191 FX_FLOAT min_x = 10000 * 1.0f; | 191 FX_FLOAT min_x = 10000 * 1.0f; |
192 FX_FLOAT max_x = -10000 * 1.0f; | 192 FX_FLOAT max_x = -10000 * 1.0f; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 max_x = char_left; | 233 max_x = char_left; |
234 } | 234 } |
235 if (min_x > char_right) { | 235 if (min_x > char_right) { |
236 min_x = char_right; | 236 min_x = char_right; |
237 } | 237 } |
238 if (max_x < char_right) { | 238 if (max_x < char_right) { |
239 max_x = char_right; | 239 max_x = char_right; |
240 } | 240 } |
241 charwidth = pFont->GetCharWidthF(charcode, level) * fontsize / 1000; | 241 charwidth = pFont->GetCharWidthF(charcode, level) * fontsize / 1000; |
242 } else { | 242 } else { |
243 FX_WORD CID = pCIDFont->CIDFromCharCode(charcode); | 243 uint16_t CID = pCIDFont->CIDFromCharCode(charcode); |
244 short vx; | 244 short vx; |
245 short vy; | 245 short vy; |
246 pCIDFont->GetVertOrigin(CID, vx, vy); | 246 pCIDFont->GetVertOrigin(CID, vx, vy); |
247 char_rect.left -= vx; | 247 char_rect.left -= vx; |
248 char_rect.right -= vx; | 248 char_rect.right -= vx; |
249 char_rect.top -= vy; | 249 char_rect.top -= vy; |
250 char_rect.bottom -= vy; | 250 char_rect.bottom -= vy; |
251 if (min_x > char_rect.left) { | 251 if (min_x > char_rect.left) { |
252 min_x = (FX_FLOAT)char_rect.left; | 252 min_x = (FX_FLOAT)char_rect.left; |
253 } | 253 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) { | 336 void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) { |
337 FX_FLOAT dx = x - m_PosX; | 337 FX_FLOAT dx = x - m_PosX; |
338 FX_FLOAT dy = y - m_PosY; | 338 FX_FLOAT dy = y - m_PosY; |
339 m_PosX = x; | 339 m_PosX = x; |
340 m_PosY = y; | 340 m_PosY = y; |
341 m_Left += dx; | 341 m_Left += dx; |
342 m_Right += dx; | 342 m_Right += dx; |
343 m_Top += dy; | 343 m_Top += dy; |
344 m_Bottom += dy; | 344 m_Bottom += dy; |
345 } | 345 } |
OLD | NEW |