| 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/fpdftext/include/cpdf_textpage.h" | 7 #include "core/fpdftext/include/cpdf_textpage.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const int nItems = pTextObj->CountItems(); | 47 const int nItems = pTextObj->CountItems(); |
| 48 if (pTextObj->m_TextState->m_CharSpace && nItems >= 3) { | 48 if (pTextObj->m_TextState->m_CharSpace && nItems >= 3) { |
| 49 bool bAllChar = true; | 49 bool bAllChar = true; |
| 50 FX_FLOAT spacing = | 50 FX_FLOAT spacing = |
| 51 matrix.TransformDistance(pTextObj->m_TextState->m_CharSpace); | 51 matrix.TransformDistance(pTextObj->m_TextState->m_CharSpace); |
| 52 baseSpace = spacing; | 52 baseSpace = spacing; |
| 53 for (int i = 0; i < nItems; i++) { | 53 for (int i = 0; i < nItems; i++) { |
| 54 CPDF_TextObjectItem item; | 54 CPDF_TextObjectItem item; |
| 55 pTextObj->GetItemInfo(i, &item); | 55 pTextObj->GetItemInfo(i, &item); |
| 56 if (item.m_CharCode == static_cast<uint32_t>(-1)) { | 56 if (item.m_CharCode == static_cast<uint32_t>(-1)) { |
| 57 FX_FLOAT fontsize_h = pTextObj->m_TextState->GetFontSizeH(); | 57 FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); |
| 58 FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; | 58 FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; |
| 59 baseSpace = std::min(baseSpace, kerning + spacing); | 59 baseSpace = std::min(baseSpace, kerning + spacing); |
| 60 bAllChar = false; | 60 bAllChar = false; |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 if (baseSpace < 0.0 || (nItems == 3 && !bAllChar)) | 63 if (baseSpace < 0.0 || (nItems == 3 && !bAllChar)) |
| 64 baseSpace = 0.0; | 64 baseSpace = 0.0; |
| 65 } | 65 } |
| 66 return baseSpace; | 66 return baseSpace; |
| 67 } | 67 } |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 charinfo.m_OriginX = 0; | 1077 charinfo.m_OriginX = 0; |
| 1078 charinfo.m_OriginY = 0; | 1078 charinfo.m_OriginY = 0; |
| 1079 pTextObj->GetItemInfo(i, &item); | 1079 pTextObj->GetItemInfo(i, &item); |
| 1080 if (item.m_CharCode == static_cast<uint32_t>(-1)) { | 1080 if (item.m_CharCode == static_cast<uint32_t>(-1)) { |
| 1081 CFX_WideString str = m_TempTextBuf.MakeString(); | 1081 CFX_WideString str = m_TempTextBuf.MakeString(); |
| 1082 if (str.IsEmpty()) | 1082 if (str.IsEmpty()) |
| 1083 str = m_TextBuf.AsStringC(); | 1083 str = m_TextBuf.AsStringC(); |
| 1084 if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_SPACE_CHAR) | 1084 if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_SPACE_CHAR) |
| 1085 continue; | 1085 continue; |
| 1086 | 1086 |
| 1087 FX_FLOAT fontsize_h = pTextObj->m_TextState->GetFontSizeH(); | 1087 FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); |
| 1088 spacing = -fontsize_h * item.m_OriginX / 1000; | 1088 spacing = -fontsize_h * item.m_OriginX / 1000; |
| 1089 continue; | 1089 continue; |
| 1090 } | 1090 } |
| 1091 FX_FLOAT charSpace = pTextObj->m_TextState->m_CharSpace; | 1091 FX_FLOAT charSpace = pTextObj->m_TextState->m_CharSpace; |
| 1092 if (charSpace > 0.001) | 1092 if (charSpace > 0.001) |
| 1093 spacing += matrix.TransformDistance(charSpace); | 1093 spacing += matrix.TransformDistance(charSpace); |
| 1094 else if (charSpace < -0.001) | 1094 else if (charSpace < -0.001) |
| 1095 spacing -= matrix.TransformDistance(FXSYS_fabs(charSpace)); | 1095 spacing -= matrix.TransformDistance(FXSYS_fabs(charSpace)); |
| 1096 spacing -= baseSpace; | 1096 spacing -= baseSpace; |
| 1097 if (spacing && i > 0) { | 1097 if (spacing && i > 0) { |
| 1098 int last_width = 0; | 1098 int last_width = 0; |
| 1099 FX_FLOAT fontsize_h = pTextObj->m_TextState->GetFontSizeH(); | 1099 FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); |
| 1100 uint32_t space_charcode = pFont->CharCodeFromUnicode(' '); | 1100 uint32_t space_charcode = pFont->CharCodeFromUnicode(' '); |
| 1101 FX_FLOAT threshold = 0; | 1101 FX_FLOAT threshold = 0; |
| 1102 if (space_charcode != CPDF_Font::kInvalidCharCode) | 1102 if (space_charcode != CPDF_Font::kInvalidCharCode) |
| 1103 threshold = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; | 1103 threshold = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; |
| 1104 if (threshold > fontsize_h / 3) | 1104 if (threshold > fontsize_h / 3) |
| 1105 threshold = 0; | 1105 threshold = 0; |
| 1106 else | 1106 else |
| 1107 threshold /= 2; | 1107 threshold /= 2; |
| 1108 if (threshold == 0) { | 1108 if (threshold == 0) { |
| 1109 threshold = fontsize_h; | 1109 threshold = fontsize_h; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 info.m_OriginY); | 1540 info.m_OriginY); |
| 1541 return TRUE; | 1541 return TRUE; |
| 1542 } | 1542 } |
| 1543 | 1543 |
| 1544 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, | 1544 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, |
| 1545 const CFX_FloatRect& rect2) { | 1545 const CFX_FloatRect& rect2) { |
| 1546 CFX_FloatRect rect = rect1; | 1546 CFX_FloatRect rect = rect1; |
| 1547 rect.Intersect(rect2); | 1547 rect.Intersect(rect2); |
| 1548 return !rect.IsEmpty(); | 1548 return !rect.IsEmpty(); |
| 1549 } | 1549 } |
| OLD | NEW |