summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp2
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp28
-rw-r--r--core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h25
-rw-r--r--fpdfsdk/fxedit/fxet_pageobjs.cpp139
4 files changed, 85 insertions, 109 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 365e4c0464..b69863b5b0 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -816,7 +816,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj,
&text_device, textobj->m_nChars, textobj->m_pCharCodes,
textobj->m_pCharPos, textobj->m_TextState.GetFont(),
textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix,
- textobj->m_GraphState, (FX_ARGB)-1, 0, NULL);
+ textobj->m_GraphState, (FX_ARGB)-1, 0, nullptr, 0);
}
}
CPDF_RenderStatus bitmap_render;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 7c2fec7c78..e4ee49afc9 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -528,9 +528,11 @@ class CPDF_CharPosList {
CPDF_CharPosList::CPDF_CharPosList() {
m_pCharPos = NULL;
}
+
CPDF_CharPosList::~CPDF_CharPosList() {
FX_Free(m_pCharPos);
}
+
void CPDF_CharPosList::Load(int nChars,
uint32_t* pCharCodes,
FX_FLOAT* pCharPos,
@@ -590,6 +592,7 @@ void CPDF_CharPosList::Load(int nChars,
}
}
+// static
FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
int nChars,
uint32_t* pCharCodes,
@@ -614,24 +617,7 @@ FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice,
pClippingPath, nFlag);
}
-void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
- int left,
- int top,
- CPDF_Font* pFont,
- int height,
- const CFX_ByteString& str,
- FX_ARGB argb) {
- FX_RECT font_bbox;
- pFont->GetFontBBox(font_bbox);
- FX_FLOAT font_size =
- (FX_FLOAT)height * 1000.0f / (FX_FLOAT)(font_bbox.top - font_bbox.bottom);
- FX_FLOAT origin_x = (FX_FLOAT)left;
- FX_FLOAT origin_y =
- (FX_FLOAT)top + font_size * (FX_FLOAT)font_bbox.top / 1000.0f;
- CFX_Matrix matrix(1.0f, 0, 0, -1.0f, 0, 0);
- DrawTextString(pDevice, origin_x, origin_y, pFont, font_size, &matrix, str,
- argb);
-}
+// static
void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
FX_FLOAT origin_x,
FX_FLOAT origin_y,
@@ -680,7 +666,8 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
&matrix, fill_argb, pOptions);
} else {
DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
- &matrix, NULL, pGraphState, fill_argb, stroke_argb, NULL);
+ &matrix, nullptr, pGraphState, fill_argb, stroke_argb,
+ nullptr, 0);
}
}
@@ -689,6 +676,8 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
FX_Free(pCharPos);
}
}
+
+// static
FX_BOOL CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice,
int nChars,
uint32_t* pCharCodes,
@@ -734,6 +723,7 @@ FX_BOOL CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice,
&pFont->m_Font, pCache, font_size,
pText2Device, fill_argb, FXGE_flags);
}
+
void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
const CFX_Matrix* pObj2Device,
CPDF_Font* pFont,
diff --git a/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h b/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
index d532196675..c4031bbbff 100644
--- a/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
+++ b/core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h
@@ -21,14 +21,6 @@ class CPDF_Font;
class CPDF_TextRenderer {
public:
static void DrawTextString(CFX_RenderDevice* pDevice,
- int left,
- int top,
- CPDF_Font* pFont,
- int height,
- const CFX_ByteString& str,
- FX_ARGB argb);
-
- static void DrawTextString(CFX_RenderDevice* pDevice,
FX_FLOAT origin_x,
FX_FLOAT origin_y,
CPDF_Font* pFont,
@@ -36,9 +28,9 @@ class CPDF_TextRenderer {
const CFX_Matrix* matrix,
const CFX_ByteString& str,
FX_ARGB fill_argb,
- FX_ARGB stroke_argb = 0,
- const CFX_GraphStateData* pGraphState = NULL,
- const CPDF_RenderOptions* pOptions = NULL);
+ FX_ARGB stroke_argb,
+ const CFX_GraphStateData* pGraphState,
+ const CPDF_RenderOptions* pOptions);
static FX_BOOL DrawTextPath(CFX_RenderDevice* pDevice,
int nChars,
@@ -52,7 +44,7 @@ class CPDF_TextRenderer {
FX_ARGB fill_argb,
FX_ARGB stroke_argb,
CFX_PathData* pClippingPath,
- int nFlag = 0);
+ int nFlag);
static FX_BOOL DrawNormalText(CFX_RenderDevice* pDevice,
int nChars,
@@ -63,15 +55,6 @@ class CPDF_TextRenderer {
const CFX_Matrix* pText2Device,
FX_ARGB fill_argb,
const CPDF_RenderOptions* pOptions);
-
- static FX_BOOL DrawType3Text(CFX_RenderDevice* pDevice,
- int nChars,
- uint32_t* pCharCodes,
- FX_FLOAT* pCharPos,
- CPDF_Font* pFont,
- FX_FLOAT font_size,
- const CFX_Matrix* pText2Device,
- FX_ARGB fill_argb);
};
#endif // CORE_FPDFAPI_FPDF_RENDER_INCLUDE_CPDF_TEXTRENDERER_H_
diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp
index 91039f49de..f12fffb373 100644
--- a/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -17,6 +17,8 @@
#include "fpdfsdk/fxedit/include/fx_edit.h"
#include "fpdfsdk/fxedit/include/fxet_edit.h"
+namespace {
+
CFX_FloatRect GetUnderLineRect(const CPVT_Word& word) {
return CFX_FloatRect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f,
word.ptWord.x + word.fWidth,
@@ -31,15 +33,15 @@ CFX_FloatRect GetCrossoutRect(const CPVT_Word& word) {
word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f);
}
-static void DrawTextString(CFX_RenderDevice* pDevice,
- const CFX_FloatPoint& pt,
- CPDF_Font* pFont,
- FX_FLOAT fFontSize,
- CFX_Matrix* pUser2Device,
- const CFX_ByteString& str,
- FX_ARGB crTextFill,
- FX_ARGB crTextStroke,
- int32_t nHorzScale) {
+void DrawTextString(CFX_RenderDevice* pDevice,
+ const CFX_FloatPoint& pt,
+ CPDF_Font* pFont,
+ FX_FLOAT fFontSize,
+ CFX_Matrix* pUser2Device,
+ const CFX_ByteString& str,
+ FX_ARGB crTextFill,
+ FX_ARGB crTextStroke,
+ int32_t nHorzScale) {
FX_FLOAT x = pt.x, y = pt.y;
pUser2Device->Transform(x, y);
@@ -65,7 +67,7 @@ static void DrawTextString(CFX_RenderDevice* pDevice,
&ro);
} else {
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
- str, crTextFill, 0, NULL, &ro);
+ str, crTextFill, 0, nullptr, &ro);
}
} else {
CPDF_RenderOptions ro;
@@ -86,12 +88,70 @@ static void DrawTextString(CFX_RenderDevice* pDevice,
} else {
CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
pUser2Device, str, crTextFill, 0,
- NULL, &ro);
+ nullptr, &ro);
}
}
}
}
+void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
+ FX_COLORREF crFill,
+ const CFX_FloatRect& rcFill) {
+ std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject);
+ CFX_PathData* pPathData = pPathObj->m_Path.GetModify();
+ pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top);
+
+ FX_FLOAT rgb[3];
+ rgb[0] = FXARGB_R(crFill) / 255.0f;
+ rgb[1] = FXARGB_G(crFill) / 255.0f;
+ rgb[2] = FXARGB_B(crFill) / 255.0f;
+ pPathObj->m_ColorState.SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+
+ pPathObj->m_FillType = FXFILL_ALTERNATE;
+ pPathObj->m_bStroke = FALSE;
+ pObjectHolder->GetPageObjectList()->push_back(std::move(pPathObj));
+}
+
+CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
+ FX_COLORREF crText,
+ CPDF_Font* pFont,
+ FX_FLOAT fFontSize,
+ FX_FLOAT fCharSpace,
+ int32_t nHorzScale,
+ const CFX_FloatPoint& point,
+ const CFX_ByteString& text) {
+ std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject);
+ CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify();
+ pTextStateData->m_pFont = pFont;
+ pTextStateData->m_FontSize = fFontSize;
+ pTextStateData->m_CharSpace = fCharSpace;
+ pTextStateData->m_WordSpace = 0;
+ pTextStateData->m_TextMode = TextRenderingMode::MODE_FILL;
+ pTextStateData->m_Matrix[0] = nHorzScale / 100.0f;
+ pTextStateData->m_Matrix[1] = 0;
+ pTextStateData->m_Matrix[2] = 0;
+ pTextStateData->m_Matrix[3] = 1;
+
+ FX_FLOAT rgb[3];
+ rgb[0] = FXARGB_R(crText) / 255.0f;
+ rgb[1] = FXARGB_G(crText) / 255.0f;
+ rgb[2] = FXARGB_B(crText) / 255.0f;
+ pTxtObj->m_ColorState.SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+ pTxtObj->m_ColorState.SetStrokeColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+
+ pTxtObj->SetPosition(point.x, point.y);
+ pTxtObj->SetText(text);
+
+ CPDF_TextObject* pRet = pTxtObj.get();
+ pObjectHolder->GetPageObjectList()->push_back(std::move(pTxtObj));
+ return pRet;
+}
+
+} // namespace
+
void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
CFX_Matrix* pUser2Device,
IFX_Edit* pEdit,
@@ -388,63 +448,6 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
pDevice->RestoreState(false);
}
-static void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
- FX_COLORREF crFill,
- const CFX_FloatRect& rcFill) {
- std::unique_ptr<CPDF_PathObject> pPathObj(new CPDF_PathObject);
- CFX_PathData* pPathData = pPathObj->m_Path.GetModify();
- pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top);
-
- FX_FLOAT rgb[3];
- rgb[0] = FXARGB_R(crFill) / 255.0f;
- rgb[1] = FXARGB_G(crFill) / 255.0f;
- rgb[2] = FXARGB_B(crFill) / 255.0f;
- pPathObj->m_ColorState.SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
-
- pPathObj->m_FillType = FXFILL_ALTERNATE;
- pPathObj->m_bStroke = FALSE;
- pObjectHolder->GetPageObjectList()->push_back(std::move(pPathObj));
-}
-
-static CPDF_TextObject* AddTextObjToPageObjects(
- CPDF_PageObjectHolder* pObjectHolder,
- FX_COLORREF crText,
- CPDF_Font* pFont,
- FX_FLOAT fFontSize,
- FX_FLOAT fCharSpace,
- int32_t nHorzScale,
- const CFX_FloatPoint& point,
- const CFX_ByteString& text) {
- std::unique_ptr<CPDF_TextObject> pTxtObj(new CPDF_TextObject);
- CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify();
- pTextStateData->m_pFont = pFont;
- pTextStateData->m_FontSize = fFontSize;
- pTextStateData->m_CharSpace = fCharSpace;
- pTextStateData->m_WordSpace = 0;
- pTextStateData->m_TextMode = TextRenderingMode::MODE_FILL;
- pTextStateData->m_Matrix[0] = nHorzScale / 100.0f;
- pTextStateData->m_Matrix[1] = 0;
- pTextStateData->m_Matrix[2] = 0;
- pTextStateData->m_Matrix[3] = 1;
-
- FX_FLOAT rgb[3];
- rgb[0] = FXARGB_R(crText) / 255.0f;
- rgb[1] = FXARGB_G(crText) / 255.0f;
- rgb[2] = FXARGB_B(crText) / 255.0f;
- pTxtObj->m_ColorState.SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
- pTxtObj->m_ColorState.SetStrokeColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
-
- pTxtObj->SetPosition(point.x, point.y);
- pTxtObj->SetText(text);
-
- CPDF_TextObject* pRet = pTxtObj.get();
- pObjectHolder->GetPageObjectList()->push_back(std::move(pTxtObj));
- return pRet;
-}
-
void IFX_Edit::GeneratePageObjects(
CPDF_PageObjectHolder* pObjectHolder,
IFX_Edit* pEdit,