From da83d3a5cc09c4056310b3cf299dbbccd5c70d11 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 13 Feb 2017 15:30:30 -0500 Subject: Convert Origins to points MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL converts various OriginX, OriginY pairs into CFX_PointF objects. Change-Id: I9141f7fc713c710b2014d4fdcdec7dc93501f844 Reviewed-on: https://pdfium-review.googlesource.com/2575 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña --- core/fpdfapi/page/cpdf_textobject.cpp | 38 ++--- core/fpdfapi/page/cpdf_textobject.h | 14 +- core/fpdfapi/render/cpdf_charposlist.cpp | 18 +-- core/fpdfapi/render/cpdf_renderstatus.cpp | 15 +- core/fpdftext/cpdf_textpage.cpp | 242 ++++++++++++++---------------- core/fpdftext/cpdf_textpage.h | 19 ++- core/fxcrt/fx_basic_coords.cpp | 15 ++ core/fxcrt/fx_coordinates.h | 3 + core/fxge/apple/fx_apple_platform.cpp | 11 +- core/fxge/cfx_renderdevice.h | 10 +- core/fxge/fx_font.h | 13 +- core/fxge/ge/cfx_renderdevice.cpp | 52 ++++--- core/fxge/ge/fx_ge_text.cpp | 10 +- core/fxge/ifx_renderdevicedriver.h | 2 +- core/fxge/skia/fx_skia_device.cpp | 5 +- core/fxge/skia/fx_skia_device.h | 2 +- core/fxge/win32/cfx_psrenderer.cpp | 2 +- core/fxge/win32/cfx_psrenderer.h | 2 +- core/fxge/win32/fx_win32_print.cpp | 4 +- core/fxge/win32/win32_int.h | 2 +- xfa/fde/fde_visualset.h | 2 +- xfa/fgas/layout/fgas_rtfbreak.cpp | 27 ++-- xfa/fgas/layout/fgas_textbreak.cpp | 35 +++-- xfa/fxbarcode/oned/BC_OneDimWriter.cpp | 6 +- xfa/fxfa/app/cxfa_textlayout.cpp | 22 +-- xfa/fxgraphics/cfx_graphics.cpp | 6 +- 26 files changed, 310 insertions(+), 267 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 left = glyph.m_OriginX; + pdfium::base::CheckedNumeric left = glyph.m_Origin.x; left += glyph.m_pGlyph->m_Left; left -= rect.left; left *= sa; if (!left.IsValid()) continue; - pdfium::base::CheckedNumeric top = glyph.m_OriginY; + pdfium::base::CheckedNumeric 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; diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 55551dcfa0..bd068a596b 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -55,7 +55,7 @@ FX_FLOAT CalculateBaseSpace(const CPDF_TextObject* pTextObj, pTextObj->GetItemInfo(i, &item); if (item.m_CharCode == static_cast(-1)) { FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); - FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; + FX_FLOAT kerning = -fontsize_h * item.m_Origin.x / 1000; baseSpace = std::min(baseSpace, kerning + spacing); bAllChar = false; } @@ -108,6 +108,22 @@ float MaskPercentFilled(const std::vector& mask, } // namespace +FPDF_CHAR_INFO::FPDF_CHAR_INFO() + : m_Unicode(0), + m_Charcode(0), + m_Flag(0), + m_FontSize(0), + m_pTextObj(nullptr) {} + +FPDF_CHAR_INFO::~FPDF_CHAR_INFO() {} + +PAGECHAR_INFO::PAGECHAR_INFO() + : m_CharCode(0), m_Unicode(0), m_Flag(0), m_pTextObj(nullptr), m_Index(0) {} + +PAGECHAR_INFO::PAGECHAR_INFO(const PAGECHAR_INFO&) = default; + +PAGECHAR_INFO::~PAGECHAR_INFO() {} + CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags) : m_pPage(pPage), m_parserflag(flags), @@ -239,30 +255,30 @@ std::vector CPDF_TextPage::GetRectArray(int start, bFlagNewRect = true; } if (bFlagNewRect) { - FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_OriginY; CFX_Matrix matrix = info_curchar.m_pTextObj->GetTextMatrix(); matrix.Concat(info_curchar.m_Matrix); CFX_Matrix matrix_reverse; matrix_reverse.SetReverse(matrix); - matrix_reverse.TransformPoint(orgX, orgY); + CFX_PointF origin = matrix_reverse.Transform(info_curchar.m_Origin); + rect.left = info_curchar.m_CharBox.left; rect.right = info_curchar.m_CharBox.right; if (pCurObj->GetFont()->GetTypeDescent()) { - rect.bottom = orgY + + rect.bottom = origin.y + pCurObj->GetFont()->GetTypeDescent() * pCurObj->GetFontSize() / 1000; - FX_FLOAT xPosTemp = orgX; + FX_FLOAT xPosTemp = origin.x; matrix.TransformPoint(xPosTemp, rect.bottom); } else { rect.bottom = info_curchar.m_CharBox.bottom; } if (pCurObj->GetFont()->GetTypeAscent()) { rect.top = - orgY + + origin.y + pCurObj->GetFont()->GetTypeAscent() * pCurObj->GetFontSize() / 1000; FX_FLOAT xPosTemp = - orgX + + origin.x + GetCharWidth(info_curchar.m_CharCode, pCurObj->GetFont()) * pCurObj->GetFontSize() / 1000; matrix.TransformPoint(xPosTemp, rect.top); @@ -297,7 +313,7 @@ int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point, while (pos < pdfium::CollectionSize(m_CharList)) { PAGECHAR_INFO charinfo = m_CharList[pos]; CFX_FloatRect charrect = charinfo.m_CharBox; - if (charrect.Contains(point.x, point.y)) + if (charrect.Contains(point)) break; if (xTolerance > 0 || yTolerance > 0) { CFX_FloatRect charRectExt; @@ -306,7 +322,7 @@ int CPDF_TextPage::GetIndexAtPos(CFX_FloatPoint point, charRectExt.right = charrect.right + xTolerance / 2; charRectExt.top = charrect.top + yTolerance / 2; charRectExt.bottom = charrect.bottom - yTolerance / 2; - if (charRectExt.Contains(point.x, point.y)) { + if (charRectExt.Contains(point)) { double curXdif, curYdif; curXdif = FXSYS_fabs(point.x - charrect.left) < FXSYS_fabs(point.x - charrect.right) @@ -338,9 +354,9 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { CFX_WideString strText; for (const auto& charinfo : m_CharList) { if (IsRectIntersect(rect, charinfo.m_CharBox)) { - if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar && + if (FXSYS_fabs(posy - charinfo.m_Origin.y) > 0 && !IsContainPreChar && IsAddLineFeed) { - posy = charinfo.m_OriginY; + posy = charinfo.m_Origin.y; if (!strText.IsEmpty()) strText += L"\r\n"; } @@ -379,8 +395,7 @@ void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { const PAGECHAR_INFO& charinfo = m_CharList[index]; info->m_Charcode = charinfo.m_CharCode; - info->m_OriginX = charinfo.m_OriginX; - info->m_OriginY = charinfo.m_OriginY; + info->m_Origin = charinfo.m_Origin; info->m_Unicode = charinfo.m_Unicode; info->m_Flag = charinfo.m_Flag; info->m_CharBox = charinfo.m_CharBox; @@ -738,10 +753,9 @@ void CPDF_TextPage::ProcessTextObject( const CFX_Matrix& formMatrix, const CPDF_PageObjectList* pObjList, CPDF_PageObjectList::const_iterator ObjPos) { - CFX_FloatRect re(pTextObj->m_Left, pTextObj->m_Bottom, pTextObj->m_Right, - pTextObj->m_Top); if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f) return; + size_t count = m_LineObj.size(); PDFTEXT_Obj Obj; Obj.m_pTextObj = pTextObj; @@ -752,6 +766,7 @@ void CPDF_TextPage::ProcessTextObject( } if (IsSameAsPreTextObject(pTextObj, pObjList, ObjPos)) return; + PDFTEXT_Obj prev_Obj = m_LineObj[count - 1]; CPDF_TextObjectItem item; int nItem = prev_Obj.m_pTextObj->CountItems(); @@ -776,28 +791,28 @@ void CPDF_TextPage::ProcessTextObject( FX_FLOAT threshold = prev_width > this_width ? prev_width / 4 : this_width / 4; - FX_FLOAT prev_x = prev_Obj.m_pTextObj->GetPosX(), - prev_y = prev_Obj.m_pTextObj->GetPosY(); - prev_Obj.m_formMatrix.TransformPoint(prev_x, prev_y); - m_DisplayMatrix.TransformPoint(prev_x, prev_y); - FX_FLOAT this_x = pTextObj->GetPosX(), this_y = pTextObj->GetPosY(); - formMatrix.TransformPoint(this_x, this_y); - m_DisplayMatrix.TransformPoint(this_x, this_y); - if (FXSYS_fabs(this_y - prev_y) > threshold * 2) { + CFX_PointF prev = prev_Obj.m_pTextObj->GetPos(); + prev_Obj.m_formMatrix.Transform(prev); + m_DisplayMatrix.Transform(prev); + + CFX_PointF this_pos = pTextObj->GetPos(); + formMatrix.Transform(this_pos); + m_DisplayMatrix.Transform(this_pos); + if (FXSYS_fabs(this_pos.y - prev.y) > threshold * 2) { for (size_t i = 0; i < count; i++) ProcessTextObject(m_LineObj[i]); m_LineObj.clear(); m_LineObj.push_back(Obj); return; } + size_t i; for (i = count; i > 0; --i) { PDFTEXT_Obj prev_text_obj = m_LineObj[i - 1]; - FX_FLOAT Prev_x = prev_text_obj.m_pTextObj->GetPosX(), - Prev_y = prev_text_obj.m_pTextObj->GetPosY(); - prev_text_obj.m_formMatrix.TransformPoint(Prev_x, Prev_y); - m_DisplayMatrix.TransformPoint(Prev_x, Prev_y); - if (this_x >= Prev_x) { + CFX_PointF new_prev = prev_text_obj.m_pTextObj->GetPos(); + prev_text_obj.m_formMatrix.Transform(new_prev); + m_DisplayMatrix.Transform(new_prev); + if (this_pos.x >= new_prev.x) { m_LineObj.insert(m_LineObj.begin() + i, Obj); break; } @@ -893,14 +908,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { CFX_Matrix matrix = pTextObj->GetTextMatrix(); matrix.Concat(Obj.m_formMatrix); - FX_FLOAT fPosX = pTextObj->GetPosX(); - FX_FLOAT fPosY = pTextObj->GetPosY(); int nCharInfoIndex = m_TextBuf.GetLength(); - CFX_FloatRect charBox; - charBox.top = pTextObj->m_Top; - charBox.left = pTextObj->m_Left; - charBox.right = pTextObj->m_Right; - charBox.bottom = pTextObj->m_Bottom; for (FX_STRSIZE k = 0; k < nItems; k++) { FX_WCHAR wChar = actText.GetAt(k); if (wChar <= 0x80 && !isprint(wChar)) @@ -909,17 +917,13 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { continue; PAGECHAR_INFO charinfo; - charinfo.m_OriginX = fPosX; - charinfo.m_OriginY = fPosY; + charinfo.m_Origin = pTextObj->GetPos(); charinfo.m_Index = nCharInfoIndex; charinfo.m_Unicode = wChar; charinfo.m_CharCode = pFont->CharCodeFromUnicode(wChar); charinfo.m_Flag = FPDFTEXT_CHAR_PIECE; charinfo.m_pTextObj = pTextObj; - charinfo.m_CharBox.top = charBox.top; - charinfo.m_CharBox.left = charBox.left; - charinfo.m_CharBox.right = charBox.right; - charinfo.m_CharBox.bottom = charBox.bottom; + charinfo.m_CharBox = pTextObj->GetRect(); charinfo.m_Matrix = matrix; m_TempTextBuf.AppendChar(wChar); m_TempCharList.push_back(charinfo); @@ -989,15 +993,11 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { GenerateCharacter result = GenerateCharacter::None; if (m_pPreTextObj) { result = ProcessInsertObject(pTextObj, formMatrix); - if (result == GenerateCharacter::LineBreak) { - m_CurlineRect = - CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, - Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); - } else { - m_CurlineRect.Union( - CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, - Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top)); - } + if (result == GenerateCharacter::LineBreak) + m_CurlineRect = Obj.m_pTextObj->GetRect(); + else + m_CurlineRect.Union(Obj.m_pTextObj->GetRect()); + switch (result) { case GenerateCharacter::None: break; @@ -1044,10 +1044,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { break; } } else { - m_CurlineRect = - CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, - Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); + m_CurlineRect = Obj.m_pTextObj->GetRect(); } + if (ePreMKC == FPDFText_MarkedContent::Delay) { ProcessMarkedContent(Obj); m_pPreTextObj = pTextObj; @@ -1070,8 +1069,6 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { for (int i = 0; i < nItems; i++) { CPDF_TextObjectItem item; PAGECHAR_INFO charinfo; - charinfo.m_OriginX = 0; - charinfo.m_OriginY = 0; pTextObj->GetItemInfo(i, &item); if (item.m_CharCode == static_cast(-1)) { CFX_WideString str = m_TempTextBuf.MakeString(); @@ -1081,7 +1078,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { continue; FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); - spacing = -fontsize_h * item.m_OriginX / 1000; + spacing = -fontsize_h * item.m_Origin.x / 1000; continue; } FX_FLOAT charSpace = pTextObj->m_TextState.GetCharSpace(); @@ -1118,12 +1115,10 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_CharCode = CPDF_Font::kInvalidCharCode; charinfo.m_Matrix = formMatrix; - charinfo.m_OriginX = item.m_OriginX; - charinfo.m_OriginY = item.m_OriginY; - matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY); + charinfo.m_Origin = matrix.Transform(item.m_Origin); charinfo.m_CharBox = - CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY, - charinfo.m_OriginX, charinfo.m_OriginY); + CFX_FloatRect(charinfo.m_Origin.x, charinfo.m_Origin.y, + charinfo.m_Origin.x, charinfo.m_Origin.y); m_TempCharList.push_back(charinfo); } if (item.m_CharCode == CPDF_Font::kInvalidCharCode) @@ -1144,20 +1139,18 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL; charinfo.m_pTextObj = pTextObj; - charinfo.m_OriginX = item.m_OriginX; - charinfo.m_OriginY = item.m_OriginY; - matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY); + charinfo.m_Origin = matrix.Transform(item.m_Origin); FX_RECT rect = charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode); charinfo.m_CharBox.top = - rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY; + rect.top * pTextObj->GetFontSize() / 1000 + item.m_Origin.y; charinfo.m_CharBox.left = - rect.left * pTextObj->GetFontSize() / 1000 + item.m_OriginX; + rect.left * pTextObj->GetFontSize() / 1000 + item.m_Origin.x; charinfo.m_CharBox.right = - rect.right * pTextObj->GetFontSize() / 1000 + item.m_OriginX; + rect.right * pTextObj->GetFontSize() / 1000 + item.m_Origin.x; charinfo.m_CharBox.bottom = - rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_OriginY; + rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_Origin.y; if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) < 0.01f) { charinfo.m_CharBox.top = charinfo.m_CharBox.bottom + pTextObj->GetFontSize(); @@ -1185,8 +1178,10 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1]; if (charinfo1.m_CharCode == charinfo.m_CharCode && charinfo1.m_pTextObj->GetFont() == charinfo.m_pTextObj->GetFont() && - FXSYS_fabs(charinfo1.m_OriginX - charinfo.m_OriginX) < threshold && - FXSYS_fabs(charinfo1.m_OriginY - charinfo.m_OriginY) < threshold) { + FXSYS_fabs(charinfo1.m_Origin.x - charinfo.m_Origin.x) < + threshold && + FXSYS_fabs(charinfo1.m_Origin.y - charinfo.m_Origin.y) < + threshold) { bDel = true; break; } @@ -1227,10 +1222,11 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( pTextObj->GetCharInfo(nChars - 1, &last); CFX_Matrix textMatrix = pTextObj->GetTextMatrix(); - textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); - textMatrix.TransformPoint(last.m_OriginX, last.m_OriginY); - FX_FLOAT dX = FXSYS_fabs(last.m_OriginX - first.m_OriginX); - FX_FLOAT dY = FXSYS_fabs(last.m_OriginY - first.m_OriginY); + first.m_Origin = textMatrix.Transform(first.m_Origin); + last.m_Origin = textMatrix.Transform(last.m_Origin); + + FX_FLOAT dX = FXSYS_fabs(last.m_Origin.x - first.m_Origin.x); + FX_FLOAT dY = FXSYS_fabs(last.m_Origin.y - first.m_Origin.y); if (dX <= 0.0001f && dY <= 0.0001f) return TextOrientation::Unknown; @@ -1287,10 +1283,8 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( if (WritingMode == TextOrientation::Unknown) WritingMode = GetTextObjectWritingMode(m_pPreTextObj); - CFX_FloatRect this_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, - pObj->m_Top); - CFX_FloatRect prev_rect(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, - m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); + CFX_FloatRect this_rect = pObj->GetRect(); + CFX_FloatRect prev_rect = m_pPreTextObj->GetRect(); CPDF_TextObjectItem PrevItem, item; int nItem = m_pPreTextObj->CountItems(); m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem); @@ -1325,7 +1319,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( } } } - FX_FLOAT last_pos = PrevItem.m_OriginX; + FX_FLOAT last_pos = PrevItem.m_Origin.x; int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont()); FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000; last_width = FXSYS_fabs(last_width); @@ -1340,42 +1334,39 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( CFX_Matrix prev_reverse; prev_reverse.SetReverse(prev_matrix); - FX_FLOAT x = pObj->GetPosX(); - FX_FLOAT y = pObj->GetPosY(); - formMatrix.TransformPoint(x, y); - prev_reverse.TransformPoint(x, y); + + CFX_PointF pos = pObj->GetPos(); + formMatrix.Transform(pos); + prev_reverse.Transform(pos); if (last_width < this_width) threshold = prev_reverse.TransformDistance(threshold); bool bNewline = false; if (WritingMode == TextOrientation::Horizontal) { - CFX_FloatRect rect1(m_pPreTextObj->m_Left, pObj->m_Bottom, - m_pPreTextObj->m_Right, pObj->m_Top); - CFX_FloatRect rect2(m_pPreTextObj->m_Left, m_pPreTextObj->m_Bottom, - m_pPreTextObj->m_Right, m_pPreTextObj->m_Top); + CFX_FloatRect rect1 = m_pPreTextObj->GetRect(); + CFX_FloatRect rect2 = m_pPreTextObj->GetRect(); CFX_FloatRect rect3 = rect1; rect1.Intersect(rect2); if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) || - ((y > threshold * 2 || y < threshold * -3) && - (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : true))) { + ((pos.y > threshold * 2 || pos.y < threshold * -3) && + (FXSYS_fabs(pos.y) < 1 ? FXSYS_fabs(pos.x) < FXSYS_fabs(pos.y) + : true))) { bNewline = true; if (nItem > 1) { CPDF_TextObjectItem tempItem; m_pPreTextObj->GetItemInfo(0, &tempItem); CFX_Matrix m = m_pPreTextObj->GetTextMatrix(); - if (PrevItem.m_OriginX > tempItem.m_OriginX && + if (PrevItem.m_Origin.x > tempItem.m_Origin.x && m_DisplayMatrix.a > 0.9 && m_DisplayMatrix.b < 0.1 && m_DisplayMatrix.c < 0.1 && m_DisplayMatrix.d < -0.9 && m.b < 0.1 && m.c < 0.1) { CFX_FloatRect re(0, m_pPreTextObj->m_Bottom, 1000, m_pPreTextObj->m_Top); - if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) { + if (re.Contains(pObj->GetPos())) { bNewline = false; } else { CFX_FloatRect rect(0, pObj->m_Bottom, 1000, pObj->m_Top); - if (rect.Contains(m_pPreTextObj->GetPosX(), - m_pPreTextObj->GetPosY())) { + if (rect.Contains(m_pPreTextObj->GetPos())) bNewline = false; - } } } } @@ -1415,19 +1406,17 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( (threshold < 1.39001 && threshold > 1.38999)) { threshold *= 1.5; } - if (FXSYS_fabs(last_pos + last_width - x) > threshold && curChar != L' ' && - preChar != L' ') { - if (curChar != L' ' && preChar != L' ') { - if ((x - last_pos - last_width) > threshold || - (last_pos - x - last_width) > threshold) { - return GenerateCharacter::Space; - } - if (x < 0 && (last_pos - x - last_width) > threshold) - return GenerateCharacter::Space; - if ((x - last_pos - last_width) > this_width || - (x - last_pos - this_width) > last_width) { - return GenerateCharacter::Space; - } + if (FXSYS_fabs(last_pos + last_width - pos.x) > threshold && + curChar != L' ' && preChar != L' ') { + if ((pos.x - last_pos - last_width) > threshold || + (last_pos - pos.x - last_width) > threshold) { + return GenerateCharacter::Space; + } + if (pos.x < 0 && (last_pos - pos.x - last_width) > threshold) + return GenerateCharacter::Space; + if ((pos.x - last_pos - last_width) > this_width || + (pos.x - last_pos - this_width) > last_width) { + return GenerateCharacter::Space; } } return GenerateCharacter::None; @@ -1437,10 +1426,8 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, CPDF_TextObject* pTextObj2) { if (!pTextObj1 || !pTextObj2) return false; - CFX_FloatRect rcPreObj(pTextObj2->m_Left, pTextObj2->m_Bottom, - pTextObj2->m_Right, pTextObj2->m_Top); - CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom, - pTextObj1->m_Right, pTextObj1->m_Top); + CFX_FloatRect rcPreObj = pTextObj2->GetRect(); + CFX_FloatRect rcCurObj = pTextObj1->GetRect(); if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); size_t nCount = m_CharList.size(); @@ -1470,24 +1457,25 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, if (!nPreCount) return true; - CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f}; - CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f}; + CPDF_TextObjectItem itemPer; + CPDF_TextObjectItem itemCur; for (int i = 0; i < nPreCount; i++) { pTextObj2->GetItemInfo(i, &itemPer); pTextObj1->GetItemInfo(i, &itemCur); if (itemCur.m_CharCode != itemPer.m_CharCode) return false; } - if (FXSYS_fabs(pTextObj1->GetPosX() - pTextObj2->GetPosX()) > - GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * - pTextObj2->GetFontSize() / 1000 * 0.9 || - FXSYS_fabs(pTextObj1->GetPosY() - pTextObj2->GetPosY()) > - std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), - pTextObj2->GetFontSize()) / - 8) { - return false; - } - return true; + + CFX_PointF pos1 = pTextObj1->GetPos(); + CFX_PointF pos2 = pTextObj2->GetPos(); + + return FXSYS_fabs(pos1.x - pos2.x) <= + GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()) * + pTextObj2->GetFontSize() / 1000 * 0.9 && + FXSYS_fabs(pos1.y - pos2.y) <= + std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), + pTextObj2->GetFontSize()) / + 8.0; } bool CPDF_TextPage::IsSameAsPreTextObject( @@ -1531,10 +1519,10 @@ bool CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { if (!fFontSize) fFontSize = kDefaultFontSize; - info.m_OriginX = preChar->m_OriginX + preWidth * (fFontSize) / 1000; - info.m_OriginY = preChar->m_OriginY; - info.m_CharBox = CFX_FloatRect(info.m_OriginX, info.m_OriginY, info.m_OriginX, - info.m_OriginY); + info.m_Origin = CFX_PointF(preChar->m_Origin.x + preWidth * fFontSize / 1000, + preChar->m_Origin.y); + info.m_CharBox = CFX_FloatRect(info.m_Origin.x, info.m_Origin.y, + info.m_Origin.x, info.m_Origin.y); return true; } diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h index 85ee7058b6..d22cba3e40 100644 --- a/core/fpdftext/cpdf_textpage.h +++ b/core/fpdftext/cpdf_textpage.h @@ -44,13 +44,16 @@ enum class FPDFText_MarkedContent { Pass = 0, Done, Delay }; enum class FPDFText_Direction { Left = -1, Right = 1 }; -struct FPDF_CHAR_INFO { +class FPDF_CHAR_INFO { + public: + FPDF_CHAR_INFO(); + ~FPDF_CHAR_INFO(); + FX_WCHAR m_Unicode; FX_WCHAR m_Charcode; int32_t m_Flag; FX_FLOAT m_FontSize; - FX_FLOAT m_OriginX; - FX_FLOAT m_OriginY; + CFX_PointF m_Origin; CFX_FloatRect m_CharBox; CPDF_TextObject* m_pTextObj; CFX_Matrix m_Matrix; @@ -61,11 +64,15 @@ struct FPDF_SEGMENT { int m_nCount; }; -struct PAGECHAR_INFO { +class PAGECHAR_INFO { + public: + PAGECHAR_INFO(); + PAGECHAR_INFO(const PAGECHAR_INFO&); + ~PAGECHAR_INFO(); + int m_CharCode; FX_WCHAR m_Unicode; - FX_FLOAT m_OriginX; - FX_FLOAT m_OriginY; + CFX_PointF m_Origin; int32_t m_Flag; CFX_FloatRect m_CharBox; CPDF_TextObject* m_pTextObj; diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp index e8abace53d..c5ee4048a2 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -197,6 +197,14 @@ FX_RECT CFX_FloatRect::GetClosestRect() const { return rect; } +bool CFX_FloatRect::Contains(const CFX_FloatPoint& point) const { + return Contains(point.x, point.y); +} + +bool CFX_FloatRect::Contains(const CFX_PointF& point) const { + return Contains(point.x, point.y); +} + bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { CFX_FloatRect n1(*this); CFX_FloatRect n2(other_rect); @@ -377,6 +385,13 @@ void CFX_Matrix::TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const { y = fy; } +CFX_PointF CFX_Matrix::Transform(const CFX_PointF& p) const { + FX_FLOAT x = p.x; + FX_FLOAT y = p.y; + TransformPoint(x, y); + return CFX_PointF(x, y); +} + void CFX_Matrix::TransformRect(CFX_RectF& rect) const { FX_FLOAT right = rect.right(), bottom = rect.bottom(); TransformRect(rect.left, right, bottom, rect.top); diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index c9e5433226..172d794e97 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -495,6 +495,8 @@ class CFX_FloatRect { } bool IsEmpty() const { return left >= right || bottom >= top; } + bool Contains(const CFX_FloatPoint& point) const; + bool Contains(const CFX_PointF& point) const; bool Contains(const CFX_FloatRect& other_rect) const; bool Contains(FX_FLOAT x, FX_FLOAT y) const; @@ -669,6 +671,7 @@ class CFX_Matrix { FX_FLOAT TransformDistance(FX_FLOAT distance) const; void TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const; + CFX_PointF Transform(const CFX_PointF& p) const; void TransformRect(CFX_RectF& rect) const; void TransformRect(FX_FLOAT& left, diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index d6867384e6..3713450377 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -39,9 +39,7 @@ bool CGDrawGlyphRun(CGContextRef pContext, if (bNegSize) font_size = -font_size; - FX_FLOAT ori_x = pCharPos[0].m_OriginX, ori_y = pCharPos[0].m_OriginY; CFX_Matrix new_matrix; - new_matrix.TransformPoint(ori_x, ori_y); if (pObject2Device) new_matrix.Concat(*pObject2Device); @@ -57,17 +55,20 @@ bool CGDrawGlyphRun(CGContextRef pContext, if (!pFont->GetPlatformFont()) return false; } + CFX_FixedBufGrow glyph_indices(nChars); CFX_FixedBufGrow glyph_positions(nChars); for (int i = 0; i < nChars; i++) { glyph_indices[i] = pCharPos[i].m_ExtGID ? pCharPos[i].m_ExtGID : pCharPos[i].m_GlyphIndex; + if (bNegSize) - glyph_positions[i].x = -pCharPos[i].m_OriginX; + glyph_positions[i].x = -pCharPos[i].m_Origin.x; else - glyph_positions[i].x = pCharPos[i].m_OriginX; - glyph_positions[i].y = pCharPos[i].m_OriginY; + glyph_positions[i].x = pCharPos[i].m_Origin.x; + glyph_positions[i].y = pCharPos[i].m_Origin.y; } + if (bNegSize) { new_matrix.a = -new_matrix.a; new_matrix.c = -new_matrix.c; diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 2144206e19..2e9abf9963 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -62,10 +62,14 @@ class IFX_RenderDeviceDriver; enum class FXPT_TYPE : uint8_t { LineTo, BezierTo, MoveTo }; -struct FXTEXT_CHARPOS { +class FXTEXT_CHARPOS { + public: + FXTEXT_CHARPOS(); + FXTEXT_CHARPOS(const FXTEXT_CHARPOS&); + ~FXTEXT_CHARPOS(); + FX_FLOAT m_AdjustMatrix[4]; - FX_FLOAT m_OriginX; - FX_FLOAT m_OriginY; + CFX_PointF m_Origin; uint32_t m_GlyphIndex; int32_t m_FontCharWidth; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 224720fbc3..3c095d1976 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -222,12 +222,15 @@ class CFX_GlyphBitmap { CFX_DIBitmap m_Bitmap; }; -struct FXTEXT_GLYPHPOS { +class FXTEXT_GLYPHPOS { + public: + FXTEXT_GLYPHPOS(); + FXTEXT_GLYPHPOS(const FXTEXT_GLYPHPOS&); + ~FXTEXT_GLYPHPOS(); + const CFX_GlyphBitmap* m_pGlyph; - int m_OriginX; - int m_OriginY; - FX_FLOAT m_fOriginX; - FX_FLOAT m_fOriginY; + CFX_Point m_Origin; + CFX_PointF m_fOrigin; }; FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 12a3dd480d..40a7b53a16 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -27,19 +27,19 @@ namespace { void AdjustGlyphSpace(std::vector* pGlyphAndPos) { ASSERT(pGlyphAndPos->size() > 1); std::vector& glyphs = *pGlyphAndPos; - bool bVertical = glyphs.back().m_OriginX == glyphs.front().m_OriginX; - if (!bVertical && (glyphs.back().m_OriginY != glyphs.front().m_OriginY)) + bool bVertical = glyphs.back().m_Origin.x == glyphs.front().m_Origin.x; + if (!bVertical && (glyphs.back().m_Origin.y != glyphs.front().m_Origin.y)) return; for (size_t i = glyphs.size() - 1; i > 1; --i) { FXTEXT_GLYPHPOS& next = glyphs[i]; - int next_origin = bVertical ? next.m_OriginY : next.m_OriginX; - FX_FLOAT next_origin_f = bVertical ? next.m_fOriginY : next.m_fOriginX; + int next_origin = bVertical ? next.m_Origin.y : next.m_Origin.x; + FX_FLOAT next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x; FXTEXT_GLYPHPOS& current = glyphs[i - 1]; - int& current_origin = bVertical ? current.m_OriginY : current.m_OriginX; + int& current_origin = bVertical ? current.m_Origin.y : current.m_Origin.x; FX_FLOAT current_origin_f = - bVertical ? current.m_fOriginY : current.m_fOriginX; + bVertical ? current.m_fOrigin.y : current.m_fOrigin.x; int space = next_origin - current_origin; FX_FLOAT space_f = next_origin_f - current_origin_f; @@ -346,6 +346,21 @@ bool ShouldDrawDeviceText(const CFX_Font* pFont, uint32_t text_flags) { } // namespace +FXTEXT_CHARPOS::FXTEXT_CHARPOS() + : m_GlyphIndex(0), + m_FontCharWidth(0), +#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + m_ExtGID(0), +#endif + m_FallbackFontPosition(0), + m_bGlyphAdjust(false), + m_bFontStyle(false) { +} + +FXTEXT_CHARPOS::FXTEXT_CHARPOS(const FXTEXT_CHARPOS&) = default; + +FXTEXT_CHARPOS::~FXTEXT_CHARPOS(){}; + CFX_RenderDevice::CFX_RenderDevice() : m_pBitmap(nullptr), m_Width(0), @@ -908,14 +923,13 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, for (size_t i = 0; i < glyphs.size(); ++i) { FXTEXT_GLYPHPOS& glyph = glyphs[i]; const FXTEXT_CHARPOS& charpos = pCharPos[i]; - glyph.m_fOriginX = charpos.m_OriginX; - glyph.m_fOriginY = charpos.m_OriginY; - text2Device.TransformPoint(glyph.m_fOriginX, glyph.m_fOriginY); + + glyph.m_fOrigin = text2Device.Transform(charpos.m_Origin); if (anti_alias < FXFT_RENDER_MODE_LCD) - glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX); + glyph.m_Origin.x = FXSYS_round(glyph.m_fOrigin.x); else - glyph.m_OriginX = (int)FXSYS_floor(glyph.m_fOriginX); - glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); + glyph.m_Origin.x = static_cast(FXSYS_floor(glyph.m_fOrigin.x)); + glyph.m_Origin.y = FXSYS_round(glyph.m_fOrigin.y); if (charpos.m_bGlyphAdjust) { CFX_Matrix new_matrix( charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], @@ -961,8 +975,8 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, continue; const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; bitmap.TransferBitmap( - glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left, - glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top, + glyph.m_Origin.x + glyph.m_pGlyph->m_Left - pixel_left, + glyph.m_Origin.y - glyph.m_pGlyph->m_Top - pixel_top, pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0); } return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); @@ -996,13 +1010,13 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, if (!glyph.m_pGlyph) continue; - pdfium::base::CheckedNumeric left = glyph.m_OriginX; + pdfium::base::CheckedNumeric left = glyph.m_Origin.x; left += glyph.m_pGlyph->m_Left; left -= pixel_left; if (!left.IsValid()) return false; - pdfium::base::CheckedNumeric top = glyph.m_OriginY; + pdfium::base::CheckedNumeric top = glyph.m_Origin.y; top -= glyph.m_pGlyph->m_Top; top -= pixel_top; if (!top.IsValid()) @@ -1022,7 +1036,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, } bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); ncols /= 3; - int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; + int x_subpixel = static_cast(glyph.m_fOrigin.x * 3) % 3; int start_col = pdfium::base::ValueOrDieForType(pdfium::base::CheckMax(left, 0)); pdfium::base::CheckedNumeric end_col_safe = left; @@ -1065,8 +1079,8 @@ bool CFX_RenderDevice::DrawTextPath(int nChars, 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)); const CFX_PathData* pPath = pFont->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth); if (!pPath) diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index cc7ef7c6d7..669969db0b 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -28,6 +28,12 @@ void ResetTransform(FT_Face face) { } // namespace +FXTEXT_GLYPHPOS::FXTEXT_GLYPHPOS() : m_pGlyph(nullptr) {} + +FXTEXT_GLYPHPOS::FXTEXT_GLYPHPOS(const FXTEXT_GLYPHPOS&) = default; + +FXTEXT_GLYPHPOS::~FXTEXT_GLYPHPOS(){}; + ScopedFontTransform::ScopedFontTransform(FT_Face face, FXFT_Matrix* matrix) : m_Face(face) { FXFT_Set_Transform(m_Face, matrix, 0); @@ -48,7 +54,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, if (!pGlyph) continue; - FX_SAFE_INT32 char_left = glyph.m_OriginX; + FX_SAFE_INT32 char_left = glyph.m_Origin.x; char_left += pGlyph->m_Left; if (!char_left.IsValid()) continue; @@ -64,7 +70,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, if (!char_right.IsValid()) continue; - FX_SAFE_INT32 char_top = glyph.m_OriginY; + FX_SAFE_INT32 char_top = glyph.m_Origin.y; char_top -= pGlyph->m_Top; if (!char_top.IsValid()) continue; diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h index 6a5b63ba32..fd35149e42 100644 --- a/core/fxge/ifx_renderdevicedriver.h +++ b/core/fxge/ifx_renderdevicedriver.h @@ -16,8 +16,8 @@ class CFX_GraphStateData; class CFX_Matrix; class CFX_PathData; class CPDF_ShadingPattern; +class FXTEXT_CHARPOS; class IFX_Pause; -struct FXTEXT_CHARPOS; struct FX_RECT; class IFX_RenderDeviceDriver { diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 40bd321f56..3a7e22bb93 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -809,7 +809,8 @@ class SkiaState { vFlip *= -1; for (int index = 0; index < nChars; ++index) { const FXTEXT_CHARPOS& cp = pCharPos[index]; - m_positions[index + count] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip}; + m_positions[index + count] = {cp.m_Origin.x * flip, + cp.m_Origin.y * vFlip}; m_glyphs[index + count] = (uint16_t)cp.m_GlyphIndex; } SkPoint delta; @@ -1297,7 +1298,7 @@ bool CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, glyphs.setCount(nChars); for (int index = 0; index < nChars; ++index) { const FXTEXT_CHARPOS& cp = pCharPos[index]; - positions[index] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip}; + positions[index] = {cp.m_Origin.x * flip, cp.m_Origin.y * vFlip}; glyphs[index] = (uint16_t)cp.m_GlyphIndex; } #ifdef _SKIA_SUPPORT_PATHS_ diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index ff81daef46..ecb1104518 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -13,13 +13,13 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/ifx_renderdevicedriver.h" +class FXTEXT_CHARPOS; class SkCanvas; class SkMatrix; class SkPaint; class SkPath; class SkPictureRecorder; class SkiaState; -struct FXTEXT_CHARPOS; struct SkIRect; class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 7fc47b9a46..1cbfb6ad9a 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -661,7 +661,7 @@ bool CFX_PSRenderer::DrawText(int nChars, buf << "/X" << ps_fontnum << " Ff " << font_size << " Fs Sf "; last_fontnum = ps_fontnum; } - buf << pCharPos[i].m_OriginX << " " << pCharPos[i].m_OriginY << " m"; + buf << pCharPos[i].m_Origin.x << " " << pCharPos[i].m_Origin.y << " m"; CFX_ByteString hex; hex.Format("<%02X>", ps_glyphindex); buf << hex.AsStringC() << "Tj\n"; diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index e941739f44..163c6180af 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h @@ -22,7 +22,7 @@ class CFX_FontCache; class CFX_Matrix; class CFX_PathData; class CPSFont; -struct FXTEXT_CHARPOS; +class FXTEXT_CHARPOS; class CFX_PSRenderer { public: diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index a2ea82a94e..fd9bc70e0e 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -296,11 +296,11 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, ASSERT(charpos.m_AdjustMatrix[1] == 0); ASSERT(charpos.m_AdjustMatrix[2] == 0); ASSERT(charpos.m_AdjustMatrix[3] == 0); - ASSERT(charpos.m_OriginY == 0); + ASSERT(charpos.m_Origin.y == 0); // Round the spacing to the nearest integer, but keep track of the rounding // error for calculating the next spacing value. - FX_FLOAT fOriginX = charpos.m_OriginX * kScaleFactor; + FX_FLOAT fOriginX = charpos.m_Origin.x * kScaleFactor; FX_FLOAT fPixelSpacing = fOriginX - fPreviousOriginX; spacing[i] = FXSYS_round(fPixelSpacing); fPreviousOriginX = fOriginX - (fPixelSpacing - spacing[i]); diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 974a1200e6..f8eae87308 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -17,7 +17,7 @@ #include "core/fxge/win32/cpsoutput.h" #include "core/fxge/win32/dwrite_int.h" -struct FXTEXT_CHARPOS; +class FXTEXT_CHARPOS; struct WINDIB_Open_Args_; typedef HANDLE(__stdcall* FuncType_GdiAddFontMemResourceEx)(PVOID pbFont, diff --git a/xfa/fde/fde_visualset.h b/xfa/fde/fde_visualset.h index 0c6341fead..3260caee79 100644 --- a/xfa/fde/fde_visualset.h +++ b/xfa/fde/fde_visualset.h @@ -17,7 +17,7 @@ #include "xfa/fde/fde_object.h" #include "xfa/fgas/font/cfgas_fontmgr.h" -struct FXTEXT_CHARPOS; +class FXTEXT_CHARPOS; enum FDE_VISUALOBJTYPE { FDE_VISUALOBJ_Canvas = 0x00, diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 62e33fe9c2..293bbc6f5b 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -1307,8 +1307,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; } } - pCharPos->m_OriginX = fX + ptOffset.x; - pCharPos->m_OriginY = fY - ptOffset.y; + pCharPos->m_Origin = CFX_PointF(fX + ptOffset.x, fY - ptOffset.y); } if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { if (bVerticalDoc) { @@ -1325,28 +1324,28 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent * iVerScale / 100.0f; + pCharPos->m_Origin.y += fAscent * iVerScale / 100.0f; } else if (iCharRotation == 1) { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = -1; pCharPos->m_AdjustMatrix[2] = -1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= + pCharPos->m_Origin.x -= fDescent + fAscent * iVerScale / 100.0f - fAscent; } else if (iCharRotation == 2) { pCharPos->m_AdjustMatrix[0] = 1; pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY += fAscent; + pCharPos->m_Origin.x += fCharWidth; + pCharPos->m_Origin.y += fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; - pCharPos->m_OriginY += fCharWidth; + pCharPos->m_Origin.x += fAscent; + pCharPos->m_Origin.y += fCharWidth; } } else { if (iCharRotation == 0) { @@ -1354,27 +1353,27 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent * iVerScale / 100.0f - fAscent; + pCharPos->m_Origin.y += fAscent * iVerScale / 100.0f - fAscent; } else if (iCharRotation == 1) { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = -1; pCharPos->m_AdjustMatrix[2] = -1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; - pCharPos->m_OriginY -= fAscent + fDescent; + pCharPos->m_Origin.x -= fDescent; + pCharPos->m_Origin.y -= fAscent + fDescent; } else if (iCharRotation == 2) { pCharPos->m_AdjustMatrix[0] = 1; pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY -= fAscent; + pCharPos->m_Origin.x += fCharWidth; + pCharPos->m_Origin.y -= fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent * iVerScale / 100.0f; + pCharPos->m_Origin.x += fAscent * iVerScale / 100.0f; } } if (iHorScale != 100 || iVerScale != 100) { diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 69773f8eb0..b8893b99ae 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -1447,22 +1447,21 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } } if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { - pCharPos->m_OriginX = fX; - pCharPos->m_OriginY = fY; + pCharPos->m_Origin = CFX_PointF(fX, fY); if ((dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0) { int32_t iFormWidth = iCharWidth; pFont->GetCharWidth(wForm, iFormWidth, false); FX_FLOAT fOffset = fFontSize * (iCharWidth - iFormWidth) / 2000.0f; if (bVerticalDoc) { - pCharPos->m_OriginY += fOffset; + pCharPos->m_Origin.y += fOffset; } else { - pCharPos->m_OriginX += fOffset; + pCharPos->m_Origin.x += fOffset; } } if (chartype == FX_CHARTYPE_Combination) { CFX_Rect rtBBox; if (pFont->GetCharBBox(wForm, &rtBBox, false)) { - pCharPos->m_OriginY = + pCharPos->m_Origin.y = fYBase + fFontSize - fFontSize * (FX_FLOAT)rtBBox.height / (FX_FLOAT)iMaxHeight; } @@ -1472,7 +1471,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, FX_CHARTYPE_Combination) { CFX_Rect rtBox; if (pFont->GetCharBBox(wLast, &rtBox, false)) { - pCharPos->m_OriginY -= fFontSize * rtBox.height / iMaxHeight; + pCharPos->m_Origin.y -= fFontSize * rtBox.height / iMaxHeight; } } } @@ -1490,8 +1489,8 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, ptOffset.y = fFontSize * (iAscent - rtBBox.top - 150) / iMaxHeight; } } - pCharPos->m_OriginX += ptOffset.x; - pCharPos->m_OriginY -= ptOffset.y; + pCharPos->m_Origin.x += ptOffset.x; + pCharPos->m_Origin.y -= ptOffset.y; } if (!bRTLPiece && chartype != FX_CHARTYPE_Combination) { if (bVerticalDoc) { @@ -1508,26 +1507,26 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = 1; - pCharPos->m_OriginY += fAscent; + pCharPos->m_Origin.y += fAscent; } else if (iCharRotation == 1) { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = -1; pCharPos->m_AdjustMatrix[2] = -1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; + pCharPos->m_Origin.x -= fDescent; } else if (iCharRotation == 2) { pCharPos->m_AdjustMatrix[0] = 1; pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY += fAscent; + pCharPos->m_Origin.x += fCharWidth; + pCharPos->m_Origin.y += fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; + pCharPos->m_Origin.x += fAscent; } } else { if (iCharRotation == 0) { @@ -1540,21 +1539,21 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, pCharPos->m_AdjustMatrix[1] = -1; pCharPos->m_AdjustMatrix[2] = -1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX -= fDescent; - pCharPos->m_OriginY -= fAscent + fDescent; + pCharPos->m_Origin.x -= fDescent; + pCharPos->m_Origin.y -= fAscent + fDescent; } else if (iCharRotation == 2) { pCharPos->m_AdjustMatrix[0] = 1; pCharPos->m_AdjustMatrix[1] = 0; pCharPos->m_AdjustMatrix[2] = 0; pCharPos->m_AdjustMatrix[3] = -1; - pCharPos->m_OriginX += fCharWidth; - pCharPos->m_OriginY -= fAscent; + pCharPos->m_Origin.x += fCharWidth; + pCharPos->m_Origin.y -= fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_OriginX += fAscent; + pCharPos->m_Origin.x += fAscent; } } if (iHorScale != 100 || iVerScale != 100) { diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index 93a53a88a1..bc0d61fd25 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -177,8 +177,7 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, (FX_FLOAT)FXSYS_abs(cFont->GetDescent()) * (FX_FLOAT)fontSize / 1000.0f; FX_FLOAT left = leftPositon; FX_FLOAT top = 0.0; - charPos[0].m_OriginX = penX + left; - charPos[0].m_OriginY = penY + top; + charPos[0].m_Origin = CFX_PointF(penX + left, penY + top); charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[0]); charPos[0].m_FontCharWidth = cFont->GetGlyphWidth(charPos[0].m_GlyphIndex); #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ @@ -186,8 +185,7 @@ void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, #endif penX += (FX_FLOAT)(charPos[0].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; for (int32_t i = 1; i < length; i++) { - charPos[i].m_OriginX = penX + left; - charPos[i].m_OriginY = penY + top; + charPos[i].m_Origin = CFX_PointF(penX + left, penY + top); charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index ad0fc057e2..17aa1a40ab 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -1187,11 +1187,11 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, int32_t iChars = GetDisplayPos(pPiece, pCharPos); if (iChars > 0) { CFX_PointF pt1, pt2; - FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; + FX_FLOAT fEndY = pCharPos[0].m_Origin.y + 1.05f; if (pPiece->iPeriod == XFA_ATTRIBUTEENUM_Word) { for (int32_t i = 0; i < pPiece->iUnderline; i++) { for (int32_t j = 0; j < iChars; j++) { - pt1.x = pCharPos[j].m_OriginX; + pt1.x = pCharPos[j].m_Origin.x; pt2.x = pt1.x + pCharPos[j].m_FontCharWidth * pPiece->fFontSize / 1000.0f; pt1.y = pt2.y = fEndY; @@ -1200,9 +1200,9 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, fEndY += 2.0f; } } else { - pt1.x = pCharPos[0].m_OriginX; + pt1.x = pCharPos[0].m_Origin.x; pt2.x = - pCharPos[iChars - 1].m_OriginX + + pCharPos[iChars - 1].m_Origin.x + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; for (int32_t i = 0; i < pPiece->iUnderline; i++) { pt1.y = pt2.y = fEndY; @@ -1210,9 +1210,9 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, fEndY += 2.0f; } } - fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; - pt1.x = pCharPos[0].m_OriginX; - pt2.x = pCharPos[iChars - 1].m_OriginX + + fEndY = pCharPos[0].m_Origin.y - pPiece->rtPiece.height * 0.25f; + pt1.x = pCharPos[0].m_Origin.x; + pt2.x = pCharPos[iChars - 1].m_Origin.x + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; for (int32_t i = 0; i < pPiece->iLineThrough; i++) { pt1.y = pt2.y = fEndY; @@ -1253,23 +1253,23 @@ void CXFA_TextLayout::RenderPath(CFDE_RenderDevice* pDevice, if (iChars < 1) return; - fOrgX = pCharPos[iChars - 1].m_OriginX + + fOrgX = pCharPos[iChars - 1].m_Origin.x + pCharPos[iChars - 1].m_FontCharWidth * pPiece->fFontSize / 1000.0f; pPiece = pPieceLine->m_textPieces[iPieceNext].get(); iChars = GetDisplayPos(pPiece, pCharPos); if (iChars < 1) return; - fEndX = pCharPos[0].m_OriginX; + fEndX = pCharPos[0].m_Origin.x; CFX_PointF pt1, pt2; pt1.x = fOrgX, pt2.x = fEndX; - FX_FLOAT fEndY = pCharPos[0].m_OriginY + 1.05f; + FX_FLOAT fEndY = pCharPos[0].m_Origin.y + 1.05f; for (int32_t i = 0; i < pPiece->iUnderline; i++) { pt1.y = pt2.y = fEndY; pPath->AddLine(pt1, pt2); fEndY += 2.0f; } - fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; + fEndY = pCharPos[0].m_Origin.y - pPiece->rtPiece.height * 0.25f; for (int32_t i = 0; i < pPiece->iLineThrough; i++) { pt1.y = pt2.y = fEndY; pPath->AddLine(pt1, pt2); diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index f1abfb7cb5..2b8bd17aad 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -1484,8 +1484,7 @@ FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, FX_FLOAT left = (FX_FLOAT)(0); FX_FLOAT top = (FX_FLOAT)(0); charCodes[0] = text.GetAt(0); - charPos[0].m_OriginX = penX + left; - charPos[0].m_OriginY = penY + top; + charPos[0].m_Origin = CFX_PointF(penX + left, penY + top); charPos[0].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[0]); charPos[0].m_FontCharWidth = FXSYS_round( m_info.font->GetGlyphWidth(charPos[0].m_GlyphIndex) * m_info.fontHScale); @@ -1498,8 +1497,7 @@ FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text, m_info.fontSpacing; for (int32_t i = 1; i < length; i++) { charCodes[i] = text.GetAt(i); - charPos[i].m_OriginX = penX + left; - charPos[i].m_OriginY = penY + top; + charPos[i].m_Origin = CFX_PointF(penX + left, penY + top); charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(charCodes[i]); charPos[i].m_FontCharWidth = FXSYS_round(m_info.font->GetGlyphWidth(charPos[i].m_GlyphIndex) * -- cgit v1.2.3