Use pdfium::span<TextCharPos> in fxge/
Preferable to discrete int, pointer arguments. Then use subspan()
operations to extract portions rather than size/pointer arithmetic.
Change-Id: I6e5cc4466aabe74d00aeb3bf0ad3df969ee526f1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/89890
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index 2031644..bd48888 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -74,17 +74,17 @@
continue;
CFX_Font* font = GetFont(pFont, fontPosition);
- if (!pDevice->DrawTextPath(i - startIndex, &pos[startIndex], font,
- font_size, mtText2User, pUser2Device,
- pGraphState, fill_argb, stroke_argb,
- pClippingPath, fill_options)) {
+ if (!pDevice->DrawTextPath(
+ pdfium::make_span(pos).subspan(startIndex, i - startIndex), font,
+ font_size, mtText2User, pUser2Device, pGraphState, fill_argb,
+ stroke_argb, pClippingPath, fill_options)) {
bDraw = false;
}
fontPosition = curFontPosition;
startIndex = i;
}
CFX_Font* font = GetFont(pFont, fontPosition);
- if (!pDevice->DrawTextPath(pos.size() - startIndex, &pos[startIndex], font,
+ if (!pDevice->DrawTextPath(pdfium::make_span(pos).subspan(startIndex), font,
font_size, mtText2User, pUser2Device, pGraphState,
fill_argb, stroke_argb, pClippingPath,
fill_options)) {
@@ -154,16 +154,16 @@
continue;
CFX_Font* font = GetFont(pFont, fontPosition);
- if (!pDevice->DrawNormalText(i - startIndex, &pos[startIndex], font,
- font_size, mtText2Device, fill_argb,
- text_options)) {
+ if (!pDevice->DrawNormalText(
+ pdfium::make_span(pos).subspan(startIndex, i - startIndex), font,
+ font_size, mtText2Device, fill_argb, text_options)) {
bDraw = false;
}
fontPosition = curFontPosition;
startIndex = i;
}
CFX_Font* font = GetFont(pFont, fontPosition);
- if (!pDevice->DrawNormalText(pos.size() - startIndex, &pos[startIndex], font,
+ if (!pDevice->DrawNormalText(pdfium::make_span(pos).subspan(startIndex), font,
font_size, mtText2Device, fill_argb,
text_options)) {
bDraw = false;
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 10727c1..2154ee1 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -1034,13 +1034,13 @@
void CFX_AggDeviceDriver::DestroyPlatform() {}
-bool CFX_AggDeviceDriver::DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
- CFX_Font* pFont,
- const CFX_Matrix& mtObject2Device,
- float font_size,
- uint32_t color,
- const CFX_TextRenderOptions& options) {
+bool CFX_AggDeviceDriver::DrawDeviceText(
+ pdfium::span<const TextCharPos> pCharPos,
+ CFX_Font* pFont,
+ const CFX_Matrix& mtObject2Device,
+ float font_size,
+ uint32_t color,
+ const CFX_TextRenderOptions& options) {
return false;
}
#endif // !BUILDFLAG(IS_APPLE)
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index e408408..21e4800 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -87,8 +87,7 @@
BlendMode blend_type) override;
bool ContinueDIBits(CFX_ImageRenderer* handle,
PauseIndicatorIface* pPause) override;
- bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/apple/fx_apple_impl.cpp b/core/fxge/apple/fx_apple_impl.cpp
index 8f2504a..606be3e 100644
--- a/core/fxge/apple/fx_apple_impl.cpp
+++ b/core/fxge/apple/fx_apple_impl.cpp
@@ -33,13 +33,12 @@
void DoNothing(void* info, const void* data, size_t size) {}
bool CGDrawGlyphRun(CGContextRef pContext,
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
uint32_t argb) {
- if (nChars == 0)
+ if (pCharPos.empty())
return true;
bool bNegSize = font_size < 0;
@@ -58,9 +57,10 @@
if (!pFont->GetPlatformFont())
return false;
}
- std::vector<uint16_t, FxAllocAllocator<uint16_t>> glyph_indices(nChars);
- std::vector<CGPoint> glyph_positions(nChars);
- for (int i = 0; i < nChars; i++) {
+ std::vector<uint16_t, FxAllocAllocator<uint16_t>> glyph_indices(
+ pCharPos.size());
+ std::vector<CGPoint> glyph_positions(pCharPos.size());
+ for (size_t i = 0; i < pCharPos.size(); i++) {
glyph_indices[i] =
pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID : pCharPos[i].m_GlyphIndex;
if (bNegSize)
@@ -78,8 +78,8 @@
}
quartz2d.SetGraphicsTextMatrix(pContext, new_matrix);
return quartz2d.DrawGraphicsString(pContext, pFont->GetPlatformFont(),
- font_size, glyph_indices.data(),
- glyph_positions.data(), nChars, argb);
+ font_size, glyph_indices, glyph_positions,
+ argb);
}
} // namespace
@@ -104,8 +104,7 @@
}
bool CFX_AggDeviceDriver::DrawDeviceText(
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
@@ -120,8 +119,8 @@
pFont->GetSubstFont()->m_Weight <= 600) {
return false;
}
- for (int i = 0; i < nChars; i++) {
- if (pCharPos[i].m_bGlyphAdjust)
+ for (const auto& cp : pCharPos) {
+ if (cp.m_bGlyphAdjust)
return false;
}
CGContextRef ctx = CGContextRef(m_pPlatformGraphics);
@@ -156,8 +155,8 @@
else
CGContextClipToRect(ctx, rect_cg);
- bool ret = CGDrawGlyphRun(ctx, nChars, pCharPos, pFont, mtObject2Device,
- font_size, argb);
+ bool ret =
+ CGDrawGlyphRun(ctx, pCharPos, pFont, mtObject2Device, font_size, argb);
if (pImageCG)
CGImageRelease(pImageCG);
CGContextRestoreGState(ctx);
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index 9eef74b..e48bb59 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -75,9 +75,8 @@
bool CQuartz2D::DrawGraphicsString(void* graphics,
void* font,
float fontSize,
- uint16_t* glyphIndices,
- CGPoint* glyphPositions,
- int32_t charsCount,
+ pdfium::span<uint16_t> glyphIndices,
+ pdfium::span<CGPoint> glyphPositions,
FX_ARGB argb) {
if (!graphics)
return false;
@@ -94,17 +93,17 @@
CGContextSetRGBFillColor(context, r / 255.f, g / 255.f, b / 255.f, a / 255.f);
CGContextSaveGState(context);
#if CGFLOAT_IS_DOUBLE
- CGPoint* glyphPositionsCG = new CGPoint[charsCount];
- for (int index = 0; index < charsCount; ++index) {
+ CGPoint* glyphPositionsCG = new CGPoint[glyphPositions.size()];
+ for (size_t index = 0; index < glyphPositions.size(); ++index) {
glyphPositionsCG[index].x = glyphPositions[index].x;
glyphPositionsCG[index].y = glyphPositions[index].y;
}
#else
- CGPoint* glyphPositionsCG = glyphPositions;
+ CGPoint* glyphPositionsCG = glyphPositions.data();
#endif
- CGContextShowGlyphsAtPositions(context,
- reinterpret_cast<CGGlyph*>(glyphIndices),
- glyphPositionsCG, charsCount);
+ CGContextShowGlyphsAtPositions(
+ context, reinterpret_cast<CGGlyph*>(glyphIndices.data()),
+ glyphPositionsCG, glyphPositions.size());
#if CGFLOAT_IS_DOUBLE
delete[] glyphPositionsCG;
#endif
diff --git a/core/fxge/apple/fx_quartz_device.h b/core/fxge/apple/fx_quartz_device.h
index fa78f06..9388f05 100644
--- a/core/fxge/apple/fx_quartz_device.h
+++ b/core/fxge/apple/fx_quartz_device.h
@@ -28,9 +28,8 @@
bool DrawGraphicsString(void* graphics,
void* font,
float fontSize,
- uint16_t* glyphIndices,
- CGPoint* glyphPositions,
- int32_t chars,
+ pdfium::span<uint16_t> glyphIndices,
+ pdfium::span<CGPoint> glyphPositions,
FX_ARGB argb);
};
diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp
index 1606a05..0539fbe 100644
--- a/core/fxge/cfx_renderdevice.cpp
+++ b/core/fxge/cfx_renderdevice.cpp
@@ -1011,8 +1011,7 @@
}
#endif
-bool CFX_RenderDevice::DrawNormalText(int nChars,
- const TextCharPos* pCharPos,
+bool CFX_RenderDevice::DrawNormalText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
float font_size,
const CFX_Matrix& mtText2Device,
@@ -1063,7 +1062,7 @@
if (GetDeviceType() != DeviceType::kDisplay) {
if (ShouldDrawDeviceText(pFont, options) &&
- m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, mtText2Device,
+ m_pDeviceDriver->DrawDeviceText(pCharPos, pFont, mtText2Device,
font_size, fill_color, text_options)) {
return true;
}
@@ -1071,7 +1070,7 @@
return false;
} else if (options.native_text) {
if (ShouldDrawDeviceText(pFont, options) &&
- m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, mtText2Device,
+ m_pDeviceDriver->DrawDeviceText(pCharPos, pFont, mtText2Device,
font_size, fill_color, text_options)) {
return true;
}
@@ -1085,12 +1084,11 @@
if (pFont->GetFaceRec()) {
CFX_FillRenderOptions path_options;
path_options.aliased_path = !is_text_smooth;
- return DrawTextPath(nChars, pCharPos, pFont, font_size, mtText2Device,
- nullptr, nullptr, fill_color, 0, nullptr,
- path_options);
+ return DrawTextPath(pCharPos, pFont, font_size, mtText2Device, nullptr,
+ nullptr, fill_color, 0, nullptr, path_options);
}
}
- std::vector<TextGlyphPos> glyphs(nChars);
+ std::vector<TextGlyphPos> glyphs(pCharPos.size());
CFX_Matrix deviceCtm = char2device;
for (size_t i = 0; i < glyphs.size(); ++i) {
@@ -1225,8 +1223,7 @@
return true;
}
-bool CFX_RenderDevice::DrawTextPath(int nChars,
- const TextCharPos* pCharPos,
+bool CFX_RenderDevice::DrawTextPath(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
float font_size,
const CFX_Matrix& mtText2User,
@@ -1236,8 +1233,7 @@
FX_ARGB stroke_color,
CFX_Path* pClippingPath,
const CFX_FillRenderOptions& fill_options) {
- for (int iChar = 0; iChar < nChars; ++iChar) {
- const TextCharPos& charpos = pCharPos[iChar];
+ for (const auto& charpos : pCharPos) {
CFX_Matrix matrix;
if (charpos.m_bGlyphAdjust) {
matrix = CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 44e0fdc..b8660aa 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -18,6 +18,7 @@
#include "core/fxge/dib/fx_dib.h"
#include "core/fxge/render_defines.h"
#include "core/fxge/renderdevicedriver_iface.h"
+#include "third_party/base/span.h"
class CFX_DIBBase;
class CFX_DIBitmap;
@@ -156,15 +157,13 @@
BlendMode blend_mode);
bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause);
- bool DrawNormalText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawNormalText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
float font_size,
const CFX_Matrix& mtText2Device,
uint32_t fill_color,
const CFX_TextRenderOptions& options);
- bool DrawTextPath(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawTextPath(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
float font_size,
const CFX_Matrix& mtText2User,
diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp
index f8e695b..57e9d67 100644
--- a/core/fxge/renderdevicedriver_iface.cpp
+++ b/core/fxge/renderdevicedriver_iface.cpp
@@ -50,8 +50,7 @@
}
bool RenderDeviceDriverIface::DrawDeviceText(
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h
index 1350487..b4c9eb9 100644
--- a/core/fxge/renderdevicedriver_iface.h
+++ b/core/fxge/renderdevicedriver_iface.h
@@ -14,6 +14,7 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/fx_dib.h"
+#include "third_party/base/span.h"
class CFX_DIBBase;
class CFX_DIBitmap;
@@ -95,8 +96,7 @@
BlendMode blend_type) = 0;
virtual bool ContinueDIBits(CFX_ImageRenderer* handle,
PauseIndicatorIface* pPause);
- virtual bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ virtual bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 06d8a24..b66de47 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -24,6 +24,7 @@
#include "core/fxcrt/cfx_bitstream.h"
#include "core/fxcrt/fx_memory_wrappers.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/stl_util.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_font.h"
#include "core/fxge/cfx_graphstatedata.h"
@@ -1715,15 +1716,15 @@
}
bool CFX_SkiaDeviceDriver::DrawDeviceText(
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
uint32_t color,
const CFX_TextRenderOptions& options) {
- if (m_pCache->DrawText(nChars, pCharPos, pFont, mtObject2Device, font_size,
- color, options)) {
+ int nChars = fxcrt::CollectionSize<int>(pCharPos);
+ if (m_pCache->DrawText(nChars, pCharPos.data(), pFont, mtObject2Device,
+ font_size, color, options)) {
return true;
}
sk_sp<SkTypeface> typeface(SkSafeRef(pFont->GetDeviceCache()));
diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h
index 34be146..39edcb6 100644
--- a/core/fxge/skia/fx_skia_device.h
+++ b/core/fxge/skia/fx_skia_device.h
@@ -133,8 +133,7 @@
const CFX_Matrix& matrix,
BlendMode blend_type);
- bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp
index 7c3c256..4fe61cc 100644
--- a/core/fxge/skia/fx_skia_device_embeddertest.cpp
+++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp
@@ -70,8 +70,8 @@
CFX_FillRenderOptions::WindingOptions(),
BlendMode::kNormal);
} else if (state.m_graphic == State::Graphic::kText) {
- driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, matrix,
- fontSize, 0xFF445566, kTextOptions);
+ driver->DrawDeviceText(charPos, &font, matrix, fontSize, 0xFF445566,
+ kTextOptions);
}
if (state.m_save == State::Save::kYes)
driver->RestoreState(true);
@@ -94,8 +94,8 @@
CFX_FillRenderOptions::WindingOptions(),
BlendMode::kNormal);
} else if (state.m_graphic == State::Graphic::kText) {
- driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, matrix2,
- fontSize, 0xFF445566, kTextOptions);
+ driver->DrawDeviceText(charPos, &font, matrix2, fontSize, 0xFF445566,
+ kTextOptions);
}
if (state.m_save == State::Save::kYes)
driver->RestoreState(false);
diff --git a/core/fxge/win32/cgdi_printer_driver.cpp b/core/fxge/win32/cgdi_printer_driver.cpp
index 3ce0ffa..df953f5 100644
--- a/core/fxge/win32/cgdi_printer_driver.cpp
+++ b/core/fxge/win32/cgdi_printer_driver.cpp
@@ -173,12 +173,12 @@
FXDIB_ResampleOptions(), blend_type);
}
-bool CGdiPrinterDriver::DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
- CFX_Font* pFont,
- const CFX_Matrix& mtObject2Device,
- float font_size,
- uint32_t color,
- const CFX_TextRenderOptions& options) {
+bool CGdiPrinterDriver::DrawDeviceText(
+ pdfium::span<const TextCharPos> pCharPos,
+ CFX_Font* pFont,
+ const CFX_Matrix& mtObject2Device,
+ float font_size,
+ uint32_t color,
+ const CFX_TextRenderOptions& /*options*/) {
return false;
}
diff --git a/core/fxge/win32/cgdi_printer_driver.h b/core/fxge/win32/cgdi_printer_driver.h
index e558603..c4c3f59 100644
--- a/core/fxge/win32/cgdi_printer_driver.h
+++ b/core/fxge/win32/cgdi_printer_driver.h
@@ -43,8 +43,7 @@
const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
- bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/win32/cps_printer_driver.cpp b/core/fxge/win32/cps_printer_driver.cpp
index 7aae0f8..52dff32 100644
--- a/core/fxge/win32/cps_printer_driver.cpp
+++ b/core/fxge/win32/cps_printer_driver.cpp
@@ -201,13 +201,12 @@
}
bool CPSPrinterDriver::DrawDeviceText(
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
uint32_t color,
const CFX_TextRenderOptions& /*options*/) {
- return m_PSRenderer.DrawText(nChars, pCharPos, pFont, mtObject2Device,
- font_size, color);
+ return m_PSRenderer.DrawText(pCharPos.size(), pCharPos.data(), pFont,
+ mtObject2Device, font_size, color);
}
diff --git a/core/fxge/win32/cps_printer_driver.h b/core/fxge/win32/cps_printer_driver.h
index a7b90fb..b4777ce 100644
--- a/core/fxge/win32/cps_printer_driver.h
+++ b/core/fxge/win32/cps_printer_driver.h
@@ -67,8 +67,7 @@
const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
- bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/core/fxge/win32/ctext_only_printer_driver.cpp b/core/fxge/win32/ctext_only_printer_driver.cpp
index eb847fb..2c69b98 100644
--- a/core/fxge/win32/ctext_only_printer_driver.cpp
+++ b/core/fxge/win32/ctext_only_printer_driver.cpp
@@ -125,8 +125,7 @@
}
bool CTextOnlyPrinterDriver::DrawDeviceText(
- int nChars,
- const TextCharPos* pCharPos,
+ pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
@@ -134,7 +133,7 @@
const CFX_TextRenderOptions& /*options*/) {
if (g_pdfium_print_mode != WindowsPrintMode::kTextOnly)
return false;
- if (nChars < 1 || !pFont || !pFont->IsEmbedded() || !pFont->IsTTFont())
+ if (pCharPos.empty() || !pFont || !pFont->IsEmbedded() || !pFont->IsTTFont())
return false;
// Scale factor used to minimize the kerning problems caused by rounding
@@ -146,7 +145,7 @@
// preserved in the text location. clrf characters seem to be ignored by
// label printers that use this driver.
WideString wsText;
- size_t len = nChars;
+ size_t len = pCharPos.size();
float fOffsetY = mtObject2Device.f * kScaleFactor;
if (m_SetOrigin && FXSYS_roundf(m_OriginY) != FXSYS_roundf(fOffsetY)) {
wsText += L"\r\n";
@@ -157,16 +156,14 @@
m_SetOrigin = true;
// Text
- for (int i = 0; i < nChars; ++i) {
+ for (const auto& charpos : pCharPos) {
// Only works with PDFs from Skia's PDF generator. Cannot handle arbitrary
// values from PDFs.
- const TextCharPos& charpos = pCharPos[i];
DCHECK_EQ(charpos.m_AdjustMatrix[0], 0);
DCHECK_EQ(charpos.m_AdjustMatrix[1], 0);
DCHECK_EQ(charpos.m_AdjustMatrix[2], 0);
DCHECK_EQ(charpos.m_AdjustMatrix[3], 0);
DCHECK_EQ(charpos.m_Origin.y, 0);
-
wsText += charpos.m_Unicode;
}
ByteString text = wsText.ToDefANSI();
diff --git a/core/fxge/win32/ctext_only_printer_driver.h b/core/fxge/win32/ctext_only_printer_driver.h
index b3a2be8..1ef5075 100644
--- a/core/fxge/win32/ctext_only_printer_driver.h
+++ b/core/fxge/win32/ctext_only_printer_driver.h
@@ -58,8 +58,7 @@
const FXDIB_ResampleOptions& options,
std::unique_ptr<CFX_ImageRenderer>* handle,
BlendMode blend_type) override;
- bool DrawDeviceText(int nChars,
- const TextCharPos* pCharPos,
+ bool DrawDeviceText(pdfium::span<const TextCharPos> pCharPos,
CFX_Font* pFont,
const CFX_Matrix& mtObject2Device,
float font_size,
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp
index 69759ac..37c444d 100644
--- a/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -183,9 +183,9 @@
CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, (float)locX,
(float)(locY + iFontSize));
affine_matrix.Concat(matrix);
- device->DrawNormalText(str.GetLength(), pCharPos, m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(pCharPos, str.GetLength()),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix, m_fontColor, GetTextRenderOptions());
}
bool CBC_OneDimWriter::ShowChars(WideStringView contents,
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 39b9971..9c7333c 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -179,9 +179,9 @@
(float)leftPosition * m_outputHScale,
(float)(m_Height - iTextHeight) + iFontSize);
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, &charpos[1], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(1, length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.Substr(7, 6);
length = tempStr.GetLength();
@@ -193,9 +193,9 @@
(float)(leftPosition + 47 * multiple) * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, &charpos[7], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(7, length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.First(1);
length = tempStr.GetLength();
@@ -208,9 +208,9 @@
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, charpos.data(), m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).first(length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
return true;
}
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 3bde116..a9b74c1 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -168,9 +168,9 @@
(float)leftPosition * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).first(iLen),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.Substr(4, 4);
iLen = tempStr.GetLength();
@@ -182,9 +182,9 @@
(float)(leftPosition + 33 * multiple) * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(iLen, &charpos[4], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(4, iLen),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
return true;
}
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index fd944db..bccd16e 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -161,9 +161,9 @@
(float)leftPosition * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, &charpos[1], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(1, length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.Substr(6, 5);
length = tempStr.GetLength();
@@ -174,9 +174,9 @@
(float)(leftPosition + 40 * multiple) * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, &charpos[6], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(6, length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.First(1);
length = tempStr.GetLength();
@@ -189,9 +189,9 @@
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, charpos.data(), m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).first(length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
tempStr = str.Substr(11, 1);
length = tempStr.GetLength();
@@ -203,9 +203,9 @@
(float)(leftPosition + 85 * multiple) * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(matrix);
- device->DrawNormalText(length, &charpos[11], m_pFont.Get(),
- static_cast<float>(iFontSize), affine_matrix1,
- m_fontColor, GetTextRenderOptions());
+ device->DrawNormalText(pdfium::make_span(charpos).subspan(11, length),
+ m_pFont.Get(), static_cast<float>(iFontSize),
+ affine_matrix1, m_fontColor, GetTextRenderOptions());
}
return true;
}
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index ab88ebe..a946e76 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -91,8 +91,8 @@
font = pFxFont;
#endif
- device->DrawNormalText(iCurCount, pCurCP, font, -fFontSize, matrix,
- color, kOptions);
+ device->DrawNormalText(pdfium::make_span(pCurCP, iCurCount), font,
+ -fFontSize, matrix, color, kOptions);
}
pCurFont = pSTFont;
pCurCP = &pos;
@@ -114,8 +114,8 @@
font = pFxFont;
#endif
- bRet = device->DrawNormalText(iCurCount, pCurCP, font, -fFontSize, matrix,
- color, kOptions);
+ bRet = device->DrawNormalText(pdfium::make_span(pCurCP, iCurCount), font,
+ -fFontSize, matrix, color, kOptions);
}
#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
device->Flush(false);