diff options
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.cpp | 38 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textobject.h | 14 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_charposlist.cpp | 18 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 15 |
4 files changed, 46 insertions, 39 deletions
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 1534bc65d6..0404a595bf 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -10,6 +10,10 @@ #include "core/fpdfapi/font/cpdf_font.h" #include "third_party/base/ptr_util.h" +CPDF_TextObjectItem::CPDF_TextObjectItem() : m_CharCode(0) {} + +CPDF_TextObjectItem::~CPDF_TextObjectItem() {} + CPDF_TextObject::CPDF_TextObject() : m_PosX(0), m_PosY(0), @@ -31,26 +35,26 @@ int CPDF_TextObject::CountItems() const { void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { pInfo->m_CharCode = m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[index]; - pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0; - pInfo->m_OriginY = 0; - if (pInfo->m_CharCode == CPDF_Font::kInvalidCharCode) { + pInfo->m_Origin = CFX_PointF(index ? m_pCharPos[index - 1] : 0, 0); + if (pInfo->m_CharCode == CPDF_Font::kInvalidCharCode) return; - } + CPDF_Font* pFont = m_TextState.GetFont(); - if (!pFont->IsCIDFont()) { + if (!pFont->IsCIDFont()) return; - } - if (!pFont->AsCIDFont()->IsVertWriting()) { + if (!pFont->AsCIDFont()->IsVertWriting()) return; - } + uint16_t CID = pFont->AsCIDFont()->CIDFromCharCode(pInfo->m_CharCode); - pInfo->m_OriginY = pInfo->m_OriginX; - pInfo->m_OriginX = 0; - short vx, vy; + pInfo->m_Origin = CFX_PointF(0, pInfo->m_Origin.x); + + short vx; + short vy; pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); + FX_FLOAT fontsize = m_TextState.GetFontSize(); - pInfo->m_OriginX -= fontsize * vx / 1000; - pInfo->m_OriginY -= fontsize * vy / 1000; + pInfo->m_Origin.x -= fontsize * vx / 1000; + pInfo->m_Origin.y -= fontsize * vy / 1000; } int CPDF_TextObject::CountChars() const { @@ -223,12 +227,12 @@ FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const { return pCIDFont->GetVertWidth(CID) * fontsize; } -FX_FLOAT CPDF_TextObject::GetPosX() const { - return m_PosX; +CFX_FloatRect CPDF_TextObject::GetRect() const { + return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top); } -FX_FLOAT CPDF_TextObject::GetPosY() const { - return m_PosY; +CFX_PointF CPDF_TextObject::GetPos() const { + return CFX_PointF(m_PosX, m_PosY); } CPDF_Font* CPDF_TextObject::GetFont() const { diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index 2e54f2035e..7445f0d110 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -13,10 +13,13 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" -struct CPDF_TextObjectItem { +class CPDF_TextObjectItem { + public: + CPDF_TextObjectItem(); + ~CPDF_TextObjectItem(); + uint32_t m_CharCode; - FX_FLOAT m_OriginX; - FX_FLOAT m_OriginY; + CFX_PointF m_Origin; }; class CPDF_TextObject : public CPDF_PageObject { @@ -38,8 +41,9 @@ class CPDF_TextObject : public CPDF_PageObject { void GetCharInfo(int index, uint32_t& charcode, FX_FLOAT& kerning) const; void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; FX_FLOAT GetCharWidth(uint32_t charcode) const; - FX_FLOAT GetPosX() const; - FX_FLOAT GetPosY() const; + + CFX_FloatRect GetRect() const; + CFX_PointF GetPos() const; CFX_Matrix GetTextMatrix() const; CPDF_Font* GetFont() const; FX_FLOAT GetFontSize() const; diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp index 05f441cc0f..bf361e2da1 100644 --- a/core/fpdfapi/render/cpdf_charposlist.cpp +++ b/core/fpdfapi/render/cpdf_charposlist.cpp @@ -56,20 +56,20 @@ void CPDF_CharPosList::Load(int nChars, } else { charpos.m_FontCharWidth = 0; } - charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; - charpos.m_OriginY = 0; + charpos.m_Origin = CFX_PointF(iChar ? pCharPos[iChar - 1] : 0, 0); charpos.m_bGlyphAdjust = false; if (!pCIDFont) { continue; } uint16_t CID = pCIDFont->CIDFromCharCode(CharCode); if (bVertWriting) { - charpos.m_OriginY = charpos.m_OriginX; - charpos.m_OriginX = 0; - short vx, vy; + charpos.m_Origin = CFX_PointF(0, charpos.m_Origin.x); + + short vx; + short vy; pCIDFont->GetVertOrigin(CID, vx, vy); - charpos.m_OriginX -= FontSize * vx / 1000; - charpos.m_OriginY -= FontSize * vy / 1000; + charpos.m_Origin.x -= FontSize * vx / 1000; + charpos.m_Origin.y -= FontSize * vy / 1000; } const uint8_t* pTransform = pCIDFont->GetCIDTransform(CID); if (pTransform && !bVert) { @@ -77,9 +77,9 @@ void CPDF_CharPosList::Load(int nChars, charpos.m_AdjustMatrix[2] = pCIDFont->CIDTransformToFloat(pTransform[2]); charpos.m_AdjustMatrix[1] = pCIDFont->CIDTransformToFloat(pTransform[1]); charpos.m_AdjustMatrix[3] = pCIDFont->CIDTransformToFloat(pTransform[3]); - charpos.m_OriginX += + charpos.m_Origin.x += pCIDFont->CIDTransformToFloat(pTransform[4]) * FontSize; - charpos.m_OriginY += + charpos.m_Origin.y += pCIDFont->CIDTransformToFloat(pTransform[5]) * FontSize; charpos.m_bGlyphAdjust = true; } diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index b8fd7c743a..b71fd31392 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1832,8 +1832,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, continue; m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap, - glyph.m_OriginX + glyph.m_pGlyph->m_Left, - glyph.m_OriginY - glyph.m_pGlyph->m_Top, + glyph.m_Origin.x + glyph.m_pGlyph->m_Left, + glyph.m_Origin.y - glyph.m_pGlyph->m_Top, fill_argb); } glyphs.clear(); @@ -1898,8 +1898,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, origin_y - pBitmap->m_Top, fill_argb); } else { glyphs[iChar].m_pGlyph = pBitmap; - glyphs[iChar].m_OriginX = origin_x; - glyphs[iChar].m_OriginY = origin_y; + glyphs[iChar].m_Origin = CFX_Point(origin_x, origin_y); } } else { CFX_Matrix image_matrix = pType3Char->m_ImageMatrix; @@ -1929,14 +1928,14 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, if (!glyph.m_pGlyph) continue; - pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX; + pdfium::base::CheckedNumeric<int> left = glyph.m_Origin.x; left += glyph.m_pGlyph->m_Left; left -= rect.left; left *= sa; if (!left.IsValid()) continue; - pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY; + pdfium::base::CheckedNumeric<int> top = glyph.m_Origin.y; top -= glyph.m_pGlyph->m_Top; top -= rect.top; top *= sd; @@ -2001,8 +2000,8 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); } - matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX, - charpos.m_OriginY)); + matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_Origin.x, + charpos.m_Origin.y)); path.m_Path.Append(pPath, &matrix); path.m_Matrix = *pTextMatrix; path.m_bStroke = bStroke; |