summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_textrenderer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/render/cpdf_textrenderer.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_textrenderer.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index 9cb8ce933e..28e28f8147 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -6,7 +6,7 @@
#include "core/fpdfapi/render/cpdf_textrenderer.h"
-#include <vector>
+#include <algorithm>
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfapi/render/cpdf_charposlist.h"
@@ -17,9 +17,8 @@
// static
bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
- int nChars,
- uint32_t* pCharCodes,
- FX_FLOAT* pCharPos,
+ const std::vector<uint32_t>& charCodes,
+ const std::vector<FX_FLOAT>& charPos,
CPDF_Font* pFont,
FX_FLOAT font_size,
const CFX_Matrix* pText2User,
@@ -30,7 +29,7 @@ bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
CFX_PathData* pClippingPath,
int nFlag) {
CPDF_CharPosList CharPosList;
- CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size);
+ CharPosList.Load(charCodes, charPos, pFont, font_size);
if (CharPosList.m_nChars == 0)
return true;
@@ -84,26 +83,16 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
return;
int offset = 0;
- uint32_t* pCharCodes;
- FX_FLOAT* pCharPos;
std::vector<uint32_t> codes;
std::vector<FX_FLOAT> positions;
- if (nChars == 1) {
- pCharCodes = reinterpret_cast<uint32_t*>(
- pFont->GetNextChar(str.c_str(), str.GetLength(), offset));
- pCharPos = nullptr;
- } else {
- codes.resize(nChars);
- positions.resize(nChars - 1);
- FX_FLOAT cur_pos = 0;
- for (int i = 0; i < nChars; i++) {
- codes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
- if (i)
- positions[i - 1] = cur_pos;
- cur_pos += pFont->GetCharWidthF(codes[i]) * font_size / 1000;
- }
- pCharCodes = codes.data();
- pCharPos = positions.data();
+ codes.resize(nChars);
+ positions.resize(nChars - 1);
+ FX_FLOAT cur_pos = 0;
+ for (int i = 0; i < nChars; i++) {
+ codes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
+ if (i)
+ positions[i - 1] = cur_pos;
+ cur_pos += pFont->GetCharWidthF(codes[i]) * font_size / 1000;
}
CFX_Matrix matrix;
if (pMatrix)
@@ -113,27 +102,25 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
matrix.f = origin_y;
if (stroke_argb == 0) {
- DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
- &matrix, fill_argb, pOptions);
+ DrawNormalText(pDevice, codes, positions, pFont, font_size, &matrix,
+ fill_argb, pOptions);
} else {
- DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
- &matrix, nullptr, pGraphState, fill_argb, stroke_argb, nullptr,
- 0);
+ DrawTextPath(pDevice, codes, positions, pFont, font_size, &matrix, nullptr,
+ pGraphState, fill_argb, stroke_argb, nullptr, 0);
}
}
// static
bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice,
- int nChars,
- uint32_t* pCharCodes,
- FX_FLOAT* pCharPos,
+ const std::vector<uint32_t>& charCodes,
+ const std::vector<FX_FLOAT>& charPos,
CPDF_Font* pFont,
FX_FLOAT font_size,
const CFX_Matrix* pText2Device,
FX_ARGB fill_argb,
const CPDF_RenderOptions* pOptions) {
CPDF_CharPosList CharPosList;
- CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size);
+ CharPosList.Load(charCodes, charPos, pFont, font_size);
if (CharPosList.m_nChars == 0)
return true;
int FXGE_flags = 0;