diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-09 20:33:45 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-09 20:33:45 +0000 |
commit | e372ad7333bdd6bb0c579cf074843ef0c6f3414f (patch) | |
tree | 9928344d0def23d3fb070713a88947aceb6b5c71 /core/fpdfapi/page | |
parent | 0d8e530fbf898c1ba1ba4d3d91aa17e3fd4d8317 (diff) | |
download | pdfium-e372ad7333bdd6bb0c579cf074843ef0c6f3414f.tar.xz |
Use ByteStringView / pdfium::span in CPDF font as appropriate.chromium/3393
Change-Id: I92c7ba605bf95a9023ad046b8dddebe0a0592802
Reviewed-on: https://pdfium-review.googlesource.com/29992
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 402bf2ef66..36a4722773 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -152,18 +152,17 @@ void CPDF_TextObject::SetSegments(const ByteString* pStrs, CPDF_Font* pFont = m_TextState.GetFont(); int nChars = 0; for (int i = 0; i < nsegs; ++i) - nChars += pFont->CountChar(pStrs[i].c_str(), pStrs[i].GetLength()); + nChars += pFont->CountChar(pStrs[i].AsStringView()); nChars += nsegs - 1; m_CharCodes.resize(nChars); m_CharPos.resize(nChars - 1); - int index = 0; + size_t index = 0; for (int i = 0; i < nsegs; ++i) { - const char* segment = pStrs[i].c_str(); - int len = pStrs[i].GetLength(); - int offset = 0; - while (offset < len) { - ASSERT(static_cast<size_t>(index) < m_CharCodes.size()); - m_CharCodes[index++] = pFont->GetNextChar(segment, len, offset); + ByteStringView segment = pStrs[i].AsStringView(); + size_t offset = 0; + while (offset < segment.GetLength()) { + ASSERT(index < m_CharCodes.size()); + m_CharCodes[index++] = pFont->GetNextChar(segment, offset); } if (i != nsegs - 1) { m_CharPos[index - 1] = pKerning[i]; |