diff options
author | Lei Zhang <thestig@chromium.org> | 2018-06-25 22:01:07 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-25 22:01:07 +0000 |
commit | 76fb29d5ebae4fea2e5d1221f77e218a9b4b309a (patch) | |
tree | e274d6094b7850c7fc86325da790393a9bd145d8 /core/fpdfapi/page/cpdf_textobject.cpp | |
parent | 8c955c9d307272d43d532cd206abc4077076d212 (diff) | |
download | pdfium-76fb29d5ebae4fea2e5d1221f77e218a9b4b309a.tar.xz |
Clean up CPDF_StreamContentParser::AddTextObject().chromium/3473
Change-Id: I1794848607f2db3f1ef39dbd221b7219feb9254c
Reviewed-on: https://pdfium-review.googlesource.com/35990
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_textobject.cpp')
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index e678d5fc10..9da96f54f7 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -148,34 +148,34 @@ CFX_Matrix CPDF_TextObject::GetTextMatrix() const { } void CPDF_TextObject::SetSegments(const ByteString* pStrs, - const float* pKerning, - int nsegs) { + const std::vector<float>& kernings, + size_t nSegs) { m_CharCodes.clear(); m_CharPos.clear(); CPDF_Font* pFont = m_TextState.GetFont(); int nChars = 0; - for (int i = 0; i < nsegs; ++i) + for (size_t i = 0; i < nSegs; ++i) nChars += pFont->CountChar(pStrs[i].AsStringView()); - nChars += nsegs - 1; + nChars += nSegs - 1; m_CharCodes.resize(nChars); m_CharPos.resize(nChars - 1); size_t index = 0; - for (int i = 0; i < nsegs; ++i) { + for (size_t i = 0; i < nSegs; ++i) { 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]; + if (i != nSegs - 1) { + m_CharPos[index - 1] = kernings[i]; m_CharCodes[index++] = CPDF_Font::kInvalidCharCode; } } } void CPDF_TextObject::SetText(const ByteString& str) { - SetSegments(&str, nullptr, 1); + SetSegments(&str, std::vector<float>(), 1); RecalcPositionData(); SetDirty(true); } |