From d8b01ca3bd9c21e76443004907ea1bc02fb57b6e Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 14 Feb 2017 10:08:55 -0500 Subject: Revert "Convert Origins to points" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit da83d3a5cc09c4056310b3cf299dbbccd5c70d11. Reason for revert: Reverting chain to see if fixes Chrome roll. Original change's description: > Convert Origins to points > > 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 > TBR=tsepez@chromium.org,dsinclair@chromium.org,npm@chromium.org,pdfium-reviews@googlegroups.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG= Change-Id: I949fb4ec712e2587e7d0ef0191c34db198b61dcc Reviewed-on: https://pdfium-review.googlesource.com/2696 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_textobject.cpp | 34 ++--- 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, 265 insertions(+), 308 deletions(-) diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 74ea6ebc7d..2ca996b2d4 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -13,10 +13,6 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -CPDF_TextObjectItem::CPDF_TextObjectItem() : m_CharCode(0) {} - -CPDF_TextObjectItem::~CPDF_TextObjectItem() {} - CPDF_TextObject::CPDF_TextObject() {} CPDF_TextObject::~CPDF_TextObject() { @@ -28,26 +24,26 @@ int CPDF_TextObject::CountItems() const { void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { pInfo->m_CharCode = m_CharCodes[index]; - pInfo->m_Origin = CFX_PointF(index ? m_CharPos[index - 1] : 0, 0); + pInfo->m_OriginX = index ? m_CharPos[index - 1] : 0; + pInfo->m_OriginY = 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_Origin = CFX_PointF(0, pInfo->m_Origin.x); - - short vx; - short vy; + pInfo->m_OriginY = pInfo->m_OriginX; + pInfo->m_OriginX = 0; + short vx, vy; pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); - FX_FLOAT fontsize = m_TextState.GetFontSize(); - pInfo->m_Origin.x -= fontsize * vx / 1000; - pInfo->m_Origin.y -= fontsize * vy / 1000; + pInfo->m_OriginX -= fontsize * vx / 1000; + pInfo->m_OriginY -= fontsize * vy / 1000; } int CPDF_TextObject::CountChars() const { @@ -181,12 +177,12 @@ FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const { return pCIDFont->GetVertWidth(CID) * fontsize; } -CFX_FloatRect CPDF_TextObject::GetRect() const { - return CFX_FloatRect(m_Left, m_Bottom, m_Right, m_Top); +FX_FLOAT CPDF_TextObject::GetPosX() const { + return m_Pos.x; } -CFX_PointF CPDF_TextObject::GetPos() const { - return CFX_PointF(m_Pos.x, m_Pos.y); +FX_FLOAT CPDF_TextObject::GetPosY() const { + return m_Pos.y; } CPDF_Font* CPDF_TextObject::GetFont() const { diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index 9e763a164e..bef1b1ebc4 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -14,13 +14,10 @@ #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" -class CPDF_TextObjectItem { - public: - CPDF_TextObjectItem(); - ~CPDF_TextObjectItem(); - +struct CPDF_TextObjectItem { uint32_t m_CharCode; - CFX_PointF m_Origin; + FX_FLOAT m_OriginX; + FX_FLOAT m_OriginY; }; class CPDF_TextObject : public CPDF_PageObject { @@ -42,9 +39,8 @@ 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; - - CFX_FloatRect GetRect() const; - CFX_PointF GetPos() const; + FX_FLOAT GetPosX() const; + FX_FLOAT GetPosY() 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 d7f566d5e7..64176fb054 100644 --- a/core/fpdfapi/render/cpdf_charposlist.cpp +++ b/core/fpdfapi/render/cpdf_charposlist.cpp @@ -54,20 +54,20 @@ void CPDF_CharPosList::Load(const std::vector& charCodes, } else { charpos.m_FontCharWidth = 0; } - charpos.m_Origin = CFX_PointF(iChar ? charPos[iChar - 1] : 0, 0); + charpos.m_OriginX = iChar ? charPos[iChar - 1] : 0; + charpos.m_OriginY = 0; charpos.m_bGlyphAdjust = false; if (!pCIDFont) { continue; } uint16_t CID = pCIDFont->CIDFromCharCode(CharCode); if (bVertWriting) { - charpos.m_Origin = CFX_PointF(0, charpos.m_Origin.x); - - short vx; - short vy; + charpos.m_OriginY = charpos.m_OriginX; + charpos.m_OriginX = 0; + short vx, vy; pCIDFont->GetVertOrigin(CID, vx, vy); - charpos.m_Origin.x -= FontSize * vx / 1000; - charpos.m_Origin.y -= FontSize * vy / 1000; + charpos.m_OriginX -= FontSize * vx / 1000; + charpos.m_OriginY -= FontSize * vy / 1000; } const uint8_t* pTransform = pCIDFont->GetCIDTransform(CID); if (pTransform && !bVert) { @@ -75,9 +75,9 @@ void CPDF_CharPosList::Load(const std::vector& charCodes, 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_Origin.x += + charpos.m_OriginX += pCIDFont->CIDTransformToFloat(pTransform[4]) * FontSize; - charpos.m_Origin.y += + charpos.m_OriginY += 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 197a244e0b..60b7a49858 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1828,8 +1828,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, continue; m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap, - glyph.m_Origin.x + glyph.m_pGlyph->m_Left, - glyph.m_Origin.y - glyph.m_pGlyph->m_Top, + glyph.m_OriginX + glyph.m_pGlyph->m_Left, + glyph.m_OriginY - glyph.m_pGlyph->m_Top, fill_argb); } glyphs.clear(); @@ -1894,7 +1894,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, origin_y - pBitmap->m_Top, fill_argb); } else { glyphs[iChar].m_pGlyph = pBitmap; - glyphs[iChar].m_Origin = CFX_Point(origin_x, origin_y); + glyphs[iChar].m_OriginX = origin_x; + glyphs[iChar].m_OriginY = origin_y; } } else { CFX_Matrix image_matrix = pType3Char->m_ImageMatrix; @@ -1924,14 +1925,14 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, if (!glyph.m_pGlyph) continue; - pdfium::base::CheckedNumeric left = glyph.m_Origin.x; + pdfium::base::CheckedNumeric left = glyph.m_OriginX; left += glyph.m_pGlyph->m_Left; left -= rect.left; left *= sa; if (!left.IsValid()) continue; - pdfium::base::CheckedNumeric top = glyph.m_Origin.y; + pdfium::base::CheckedNumeric top = glyph.m_OriginY; top -= glyph.m_pGlyph->m_Top; top -= rect.top; top *= sd; @@ -1995,8 +1996,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_Origin.x, - charpos.m_Origin.y)); + matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX, + charpos.m_OriginY)); 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 bd068a596b..55551dcfa0 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_Origin.x / 1000; + FX_FLOAT kerning = -fontsize_h * item.m_OriginX / 1000; baseSpace = std::min(baseSpace, kerning + spacing); bAllChar = false; } @@ -108,22 +108,6 @@ 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), @@ -255,30 +239,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); - CFX_PointF origin = matrix_reverse.Transform(info_curchar.m_Origin); - + matrix_reverse.TransformPoint(orgX, orgY); rect.left = info_curchar.m_CharBox.left; rect.right = info_curchar.m_CharBox.right; if (pCurObj->GetFont()->GetTypeDescent()) { - rect.bottom = origin.y + + rect.bottom = orgY + pCurObj->GetFont()->GetTypeDescent() * pCurObj->GetFontSize() / 1000; - FX_FLOAT xPosTemp = origin.x; + FX_FLOAT xPosTemp = orgX; matrix.TransformPoint(xPosTemp, rect.bottom); } else { rect.bottom = info_curchar.m_CharBox.bottom; } if (pCurObj->GetFont()->GetTypeAscent()) { rect.top = - origin.y + + orgY + pCurObj->GetFont()->GetTypeAscent() * pCurObj->GetFontSize() / 1000; FX_FLOAT xPosTemp = - origin.x + + orgX + GetCharWidth(info_curchar.m_CharCode, pCurObj->GetFont()) * pCurObj->GetFontSize() / 1000; matrix.TransformPoint(xPosTemp, rect.top); @@ -313,7 +297,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)) + if (charrect.Contains(point.x, point.y)) break; if (xTolerance > 0 || yTolerance > 0) { CFX_FloatRect charRectExt; @@ -322,7 +306,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)) { + if (charRectExt.Contains(point.x, point.y)) { double curXdif, curYdif; curXdif = FXSYS_fabs(point.x - charrect.left) < FXSYS_fabs(point.x - charrect.right) @@ -354,9 +338,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_Origin.y) > 0 && !IsContainPreChar && + if (FXSYS_fabs(posy - charinfo.m_OriginY) > 0 && !IsContainPreChar && IsAddLineFeed) { - posy = charinfo.m_Origin.y; + posy = charinfo.m_OriginY; if (!strText.IsEmpty()) strText += L"\r\n"; } @@ -395,7 +379,8 @@ 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_Origin = charinfo.m_Origin; + info->m_OriginX = charinfo.m_OriginX; + info->m_OriginY = charinfo.m_OriginY; info->m_Unicode = charinfo.m_Unicode; info->m_Flag = charinfo.m_Flag; info->m_CharBox = charinfo.m_CharBox; @@ -753,9 +738,10 @@ 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; @@ -766,7 +752,6 @@ 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(); @@ -791,28 +776,28 @@ void CPDF_TextPage::ProcessTextObject( FX_FLOAT threshold = prev_width > this_width ? prev_width / 4 : this_width / 4; - 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) { + 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) { 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]; - 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) { + 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) { m_LineObj.insert(m_LineObj.begin() + i, Obj); break; } @@ -908,7 +893,14 @@ 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)) @@ -917,13 +909,17 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) { continue; PAGECHAR_INFO charinfo; - charinfo.m_Origin = pTextObj->GetPos(); + charinfo.m_OriginX = fPosX; + charinfo.m_OriginY = fPosY; 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 = pTextObj->GetRect(); + 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_Matrix = matrix; m_TempTextBuf.AppendChar(wChar); m_TempCharList.push_back(charinfo); @@ -993,11 +989,15 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { GenerateCharacter result = GenerateCharacter::None; if (m_pPreTextObj) { result = ProcessInsertObject(pTextObj, formMatrix); - if (result == GenerateCharacter::LineBreak) - m_CurlineRect = Obj.m_pTextObj->GetRect(); - else - m_CurlineRect.Union(Obj.m_pTextObj->GetRect()); - + 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)); + } switch (result) { case GenerateCharacter::None: break; @@ -1044,9 +1044,10 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { break; } } else { - m_CurlineRect = Obj.m_pTextObj->GetRect(); + m_CurlineRect = + CFX_FloatRect(Obj.m_pTextObj->m_Left, Obj.m_pTextObj->m_Bottom, + Obj.m_pTextObj->m_Right, Obj.m_pTextObj->m_Top); } - if (ePreMKC == FPDFText_MarkedContent::Delay) { ProcessMarkedContent(Obj); m_pPreTextObj = pTextObj; @@ -1069,6 +1070,8 @@ 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(); @@ -1078,7 +1081,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { continue; FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); - spacing = -fontsize_h * item.m_Origin.x / 1000; + spacing = -fontsize_h * item.m_OriginX / 1000; continue; } FX_FLOAT charSpace = pTextObj->m_TextState.GetCharSpace(); @@ -1115,10 +1118,12 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_CharCode = CPDF_Font::kInvalidCharCode; charinfo.m_Matrix = formMatrix; - charinfo.m_Origin = matrix.Transform(item.m_Origin); + charinfo.m_OriginX = item.m_OriginX; + charinfo.m_OriginY = item.m_OriginY; + matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY); charinfo.m_CharBox = - CFX_FloatRect(charinfo.m_Origin.x, charinfo.m_Origin.y, - charinfo.m_Origin.x, charinfo.m_Origin.y); + CFX_FloatRect(charinfo.m_OriginX, charinfo.m_OriginY, + charinfo.m_OriginX, charinfo.m_OriginY); m_TempCharList.push_back(charinfo); } if (item.m_CharCode == CPDF_Font::kInvalidCharCode) @@ -1139,18 +1144,20 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL; charinfo.m_pTextObj = pTextObj; - charinfo.m_Origin = matrix.Transform(item.m_Origin); + charinfo.m_OriginX = item.m_OriginX; + charinfo.m_OriginY = item.m_OriginY; + matrix.TransformPoint(charinfo.m_OriginX, charinfo.m_OriginY); FX_RECT rect = charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode); charinfo.m_CharBox.top = - rect.top * pTextObj->GetFontSize() / 1000 + item.m_Origin.y; + rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY; charinfo.m_CharBox.left = - rect.left * pTextObj->GetFontSize() / 1000 + item.m_Origin.x; + rect.left * pTextObj->GetFontSize() / 1000 + item.m_OriginX; charinfo.m_CharBox.right = - rect.right * pTextObj->GetFontSize() / 1000 + item.m_Origin.x; + rect.right * pTextObj->GetFontSize() / 1000 + item.m_OriginX; charinfo.m_CharBox.bottom = - rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_Origin.y; + rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_OriginY; if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) < 0.01f) { charinfo.m_CharBox.top = charinfo.m_CharBox.bottom + pTextObj->GetFontSize(); @@ -1178,10 +1185,8 @@ 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_Origin.x - charinfo.m_Origin.x) < - threshold && - FXSYS_fabs(charinfo1.m_Origin.y - charinfo.m_Origin.y) < - threshold) { + FXSYS_fabs(charinfo1.m_OriginX - charinfo.m_OriginX) < threshold && + FXSYS_fabs(charinfo1.m_OriginY - charinfo.m_OriginY) < threshold) { bDel = true; break; } @@ -1222,11 +1227,10 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( pTextObj->GetCharInfo(nChars - 1, &last); CFX_Matrix textMatrix = pTextObj->GetTextMatrix(); - 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); + 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); if (dX <= 0.0001f && dY <= 0.0001f) return TextOrientation::Unknown; @@ -1283,8 +1287,10 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( if (WritingMode == TextOrientation::Unknown) WritingMode = GetTextObjectWritingMode(m_pPreTextObj); - CFX_FloatRect this_rect = pObj->GetRect(); - CFX_FloatRect prev_rect = m_pPreTextObj->GetRect(); + 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); CPDF_TextObjectItem PrevItem, item; int nItem = m_pPreTextObj->CountItems(); m_pPreTextObj->GetItemInfo(nItem - 1, &PrevItem); @@ -1319,7 +1325,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( } } } - FX_FLOAT last_pos = PrevItem.m_Origin.x; + FX_FLOAT last_pos = PrevItem.m_OriginX; int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont()); FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000; last_width = FXSYS_fabs(last_width); @@ -1334,39 +1340,42 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( CFX_Matrix prev_reverse; prev_reverse.SetReverse(prev_matrix); - - CFX_PointF pos = pObj->GetPos(); - formMatrix.Transform(pos); - prev_reverse.Transform(pos); + FX_FLOAT x = pObj->GetPosX(); + FX_FLOAT y = pObj->GetPosY(); + formMatrix.TransformPoint(x, y); + prev_reverse.TransformPoint(x, y); if (last_width < this_width) threshold = prev_reverse.TransformDistance(threshold); bool bNewline = false; if (WritingMode == TextOrientation::Horizontal) { - CFX_FloatRect rect1 = m_pPreTextObj->GetRect(); - CFX_FloatRect rect2 = m_pPreTextObj->GetRect(); + 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 rect3 = rect1; rect1.Intersect(rect2); if ((rect1.IsEmpty() && rect2.Height() > 5 && rect3.Height() > 5) || - ((pos.y > threshold * 2 || pos.y < threshold * -3) && - (FXSYS_fabs(pos.y) < 1 ? FXSYS_fabs(pos.x) < FXSYS_fabs(pos.y) - : true))) { + ((y > threshold * 2 || y < threshold * -3) && + (FXSYS_fabs(y) < 1 ? FXSYS_fabs(x) < FXSYS_fabs(y) : true))) { bNewline = true; if (nItem > 1) { CPDF_TextObjectItem tempItem; m_pPreTextObj->GetItemInfo(0, &tempItem); CFX_Matrix m = m_pPreTextObj->GetTextMatrix(); - if (PrevItem.m_Origin.x > tempItem.m_Origin.x && + if (PrevItem.m_OriginX > tempItem.m_OriginX && 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->GetPos())) { + if (re.Contains(pObj->GetPosX(), pObj->GetPosY())) { bNewline = false; } else { CFX_FloatRect rect(0, pObj->m_Bottom, 1000, pObj->m_Top); - if (rect.Contains(m_pPreTextObj->GetPos())) + if (rect.Contains(m_pPreTextObj->GetPosX(), + m_pPreTextObj->GetPosY())) { bNewline = false; + } } } } @@ -1406,17 +1415,19 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( (threshold < 1.39001 && threshold > 1.38999)) { threshold *= 1.5; } - 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; + 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; + } } } return GenerateCharacter::None; @@ -1426,8 +1437,10 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, CPDF_TextObject* pTextObj2) { if (!pTextObj1 || !pTextObj2) return false; - CFX_FloatRect rcPreObj = pTextObj2->GetRect(); - CFX_FloatRect rcCurObj = pTextObj1->GetRect(); + 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); if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); size_t nCount = m_CharList.size(); @@ -1457,25 +1470,24 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, if (!nPreCount) return true; - CPDF_TextObjectItem itemPer; - CPDF_TextObjectItem itemCur; + CPDF_TextObjectItem itemPer = {0, 0.0f, 0.0f}; + CPDF_TextObjectItem itemCur = {0, 0.0f, 0.0f}; for (int i = 0; i < nPreCount; i++) { pTextObj2->GetItemInfo(i, &itemPer); pTextObj1->GetItemInfo(i, &itemCur); if (itemCur.m_CharCode != itemPer.m_CharCode) return false; } - - 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; + 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; } bool CPDF_TextPage::IsSameAsPreTextObject( @@ -1519,10 +1531,10 @@ bool CPDF_TextPage::GenerateCharInfo(FX_WCHAR unicode, PAGECHAR_INFO& info) { if (!fFontSize) fFontSize = kDefaultFontSize; - 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); + 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); return true; } diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h index d22cba3e40..85ee7058b6 100644 --- a/core/fpdftext/cpdf_textpage.h +++ b/core/fpdftext/cpdf_textpage.h @@ -44,16 +44,13 @@ enum class FPDFText_MarkedContent { Pass = 0, Done, Delay }; enum class FPDFText_Direction { Left = -1, Right = 1 }; -class FPDF_CHAR_INFO { - public: - FPDF_CHAR_INFO(); - ~FPDF_CHAR_INFO(); - +struct FPDF_CHAR_INFO { FX_WCHAR m_Unicode; FX_WCHAR m_Charcode; int32_t m_Flag; FX_FLOAT m_FontSize; - CFX_PointF m_Origin; + FX_FLOAT m_OriginX; + FX_FLOAT m_OriginY; CFX_FloatRect m_CharBox; CPDF_TextObject* m_pTextObj; CFX_Matrix m_Matrix; @@ -64,15 +61,11 @@ struct FPDF_SEGMENT { int m_nCount; }; -class PAGECHAR_INFO { - public: - PAGECHAR_INFO(); - PAGECHAR_INFO(const PAGECHAR_INFO&); - ~PAGECHAR_INFO(); - +struct PAGECHAR_INFO { int m_CharCode; FX_WCHAR m_Unicode; - CFX_PointF m_Origin; + FX_FLOAT m_OriginX; + FX_FLOAT m_OriginY; 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 c5ee4048a2..e8abace53d 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -197,14 +197,6 @@ 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); @@ -385,13 +377,6 @@ 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 172d794e97..c9e5433226 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -495,8 +495,6 @@ 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; @@ -671,7 +669,6 @@ 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 3713450377..d6867384e6 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -39,7 +39,9 @@ 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); @@ -55,20 +57,17 @@ 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_Origin.x; + glyph_positions[i].x = -pCharPos[i].m_OriginX; else - glyph_positions[i].x = pCharPos[i].m_Origin.x; - glyph_positions[i].y = pCharPos[i].m_Origin.y; + glyph_positions[i].x = pCharPos[i].m_OriginX; + glyph_positions[i].y = pCharPos[i].m_OriginY; } - 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 2e9abf9963..2144206e19 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -62,14 +62,10 @@ class IFX_RenderDeviceDriver; enum class FXPT_TYPE : uint8_t { LineTo, BezierTo, MoveTo }; -class FXTEXT_CHARPOS { - public: - FXTEXT_CHARPOS(); - FXTEXT_CHARPOS(const FXTEXT_CHARPOS&); - ~FXTEXT_CHARPOS(); - +struct FXTEXT_CHARPOS { FX_FLOAT m_AdjustMatrix[4]; - CFX_PointF m_Origin; + FX_FLOAT m_OriginX; + FX_FLOAT m_OriginY; 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 3c095d1976..224720fbc3 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -222,15 +222,12 @@ class CFX_GlyphBitmap { CFX_DIBitmap m_Bitmap; }; -class FXTEXT_GLYPHPOS { - public: - FXTEXT_GLYPHPOS(); - FXTEXT_GLYPHPOS(const FXTEXT_GLYPHPOS&); - ~FXTEXT_GLYPHPOS(); - +struct FXTEXT_GLYPHPOS { const CFX_GlyphBitmap* m_pGlyph; - CFX_Point m_Origin; - CFX_PointF m_fOrigin; + int m_OriginX; + int m_OriginY; + FX_FLOAT m_fOriginX; + FX_FLOAT m_fOriginY; }; 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 40a7b53a16..12a3dd480d 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_Origin.x == glyphs.front().m_Origin.x; - if (!bVertical && (glyphs.back().m_Origin.y != glyphs.front().m_Origin.y)) + bool bVertical = glyphs.back().m_OriginX == glyphs.front().m_OriginX; + if (!bVertical && (glyphs.back().m_OriginY != glyphs.front().m_OriginY)) return; for (size_t i = glyphs.size() - 1; i > 1; --i) { FXTEXT_GLYPHPOS& next = glyphs[i]; - 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; + int next_origin = bVertical ? next.m_OriginY : next.m_OriginX; + FX_FLOAT next_origin_f = bVertical ? next.m_fOriginY : next.m_fOriginX; FXTEXT_GLYPHPOS& current = glyphs[i - 1]; - int& current_origin = bVertical ? current.m_Origin.y : current.m_Origin.x; + int& current_origin = bVertical ? current.m_OriginY : current.m_OriginX; FX_FLOAT current_origin_f = - bVertical ? current.m_fOrigin.y : current.m_fOrigin.x; + bVertical ? current.m_fOriginY : current.m_fOriginX; int space = next_origin - current_origin; FX_FLOAT space_f = next_origin_f - current_origin_f; @@ -346,21 +346,6 @@ 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), @@ -923,13 +908,14 @@ 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_fOrigin = text2Device.Transform(charpos.m_Origin); + glyph.m_fOriginX = charpos.m_OriginX; + glyph.m_fOriginY = charpos.m_OriginY; + text2Device.TransformPoint(glyph.m_fOriginX, glyph.m_fOriginY); if (anti_alias < FXFT_RENDER_MODE_LCD) - glyph.m_Origin.x = FXSYS_round(glyph.m_fOrigin.x); + glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX); else - glyph.m_Origin.x = static_cast(FXSYS_floor(glyph.m_fOrigin.x)); - glyph.m_Origin.y = FXSYS_round(glyph.m_fOrigin.y); + glyph.m_OriginX = (int)FXSYS_floor(glyph.m_fOriginX); + glyph.m_OriginY = FXSYS_round(glyph.m_fOriginY); if (charpos.m_bGlyphAdjust) { CFX_Matrix new_matrix( charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], @@ -975,8 +961,8 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, continue; const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; bitmap.TransferBitmap( - glyph.m_Origin.x + glyph.m_pGlyph->m_Left - pixel_left, - glyph.m_Origin.y - glyph.m_pGlyph->m_Top - pixel_top, + glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left, + glyph.m_OriginY - 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); @@ -1010,13 +996,13 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, if (!glyph.m_pGlyph) continue; - pdfium::base::CheckedNumeric left = glyph.m_Origin.x; + pdfium::base::CheckedNumeric left = glyph.m_OriginX; left += glyph.m_pGlyph->m_Left; left -= pixel_left; if (!left.IsValid()) return false; - pdfium::base::CheckedNumeric top = glyph.m_Origin.y; + pdfium::base::CheckedNumeric top = glyph.m_OriginY; top -= glyph.m_pGlyph->m_Top; top -= pixel_top; if (!top.IsValid()) @@ -1036,7 +1022,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, } bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); ncols /= 3; - int x_subpixel = static_cast(glyph.m_fOrigin.x * 3) % 3; + int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; int start_col = pdfium::base::ValueOrDieForType(pdfium::base::CheckMax(left, 0)); pdfium::base::CheckedNumeric end_col_safe = left; @@ -1079,8 +1065,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_Origin.x, - charpos.m_Origin.y)); + matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX, + charpos.m_OriginY)); 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 669969db0b..cc7ef7c6d7 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -28,12 +28,6 @@ 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); @@ -54,7 +48,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, if (!pGlyph) continue; - FX_SAFE_INT32 char_left = glyph.m_Origin.x; + FX_SAFE_INT32 char_left = glyph.m_OriginX; char_left += pGlyph->m_Left; if (!char_left.IsValid()) continue; @@ -70,7 +64,7 @@ FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, if (!char_right.IsValid()) continue; - FX_SAFE_INT32 char_top = glyph.m_Origin.y; + FX_SAFE_INT32 char_top = glyph.m_OriginY; 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 fd35149e42..6a5b63ba32 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 3a7e22bb93..40bd321f56 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -809,8 +809,7 @@ class SkiaState { vFlip *= -1; for (int index = 0; index < nChars; ++index) { const FXTEXT_CHARPOS& cp = pCharPos[index]; - m_positions[index + count] = {cp.m_Origin.x * flip, - cp.m_Origin.y * vFlip}; + m_positions[index + count] = {cp.m_OriginX * flip, cp.m_OriginY * vFlip}; m_glyphs[index + count] = (uint16_t)cp.m_GlyphIndex; } SkPoint delta; @@ -1298,7 +1297,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_Origin.x * flip, cp.m_Origin.y * vFlip}; + positions[index] = {cp.m_OriginX * flip, cp.m_OriginY * 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 ecb1104518..ff81daef46 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 1cbfb6ad9a..7fc47b9a46 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_Origin.x << " " << pCharPos[i].m_Origin.y << " m"; + buf << pCharPos[i].m_OriginX << " " << pCharPos[i].m_OriginY << " 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 163c6180af..e941739f44 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; -class FXTEXT_CHARPOS; +struct 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 fd9bc70e0e..a2ea82a94e 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_Origin.y == 0); + ASSERT(charpos.m_OriginY == 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_Origin.x * kScaleFactor; + FX_FLOAT fOriginX = charpos.m_OriginX * 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 f8eae87308..974a1200e6 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" -class FXTEXT_CHARPOS; +struct 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 3260caee79..0c6341fead 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" -class FXTEXT_CHARPOS; +struct 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 293bbc6f5b..62e33fe9c2 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -1307,7 +1307,8 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; } } - pCharPos->m_Origin = CFX_PointF(fX + ptOffset.x, fY - ptOffset.y); + pCharPos->m_OriginX = fX + ptOffset.x; + pCharPos->m_OriginY = fY - ptOffset.y; } if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { if (bVerticalDoc) { @@ -1324,28 +1325,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_Origin.y += fAscent * iVerScale / 100.0f; + pCharPos->m_OriginY += 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_Origin.x -= + pCharPos->m_OriginX -= 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_Origin.x += fCharWidth; - pCharPos->m_Origin.y += fAscent; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY += fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x += fAscent; - pCharPos->m_Origin.y += fCharWidth; + pCharPos->m_OriginX += fAscent; + pCharPos->m_OriginY += fCharWidth; } } else { if (iCharRotation == 0) { @@ -1353,27 +1354,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_Origin.y += fAscent * iVerScale / 100.0f - fAscent; + pCharPos->m_OriginY += 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_Origin.x -= fDescent; - pCharPos->m_Origin.y -= fAscent + fDescent; + pCharPos->m_OriginX -= fDescent; + pCharPos->m_OriginY -= 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_Origin.x += fCharWidth; - pCharPos->m_Origin.y -= fAscent; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY -= fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x += fAscent * iVerScale / 100.0f; + pCharPos->m_OriginX += 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 b8893b99ae..69773f8eb0 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -1447,21 +1447,22 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } } if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { - pCharPos->m_Origin = CFX_PointF(fX, fY); + pCharPos->m_OriginX = fX; + pCharPos->m_OriginY = 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_Origin.y += fOffset; + pCharPos->m_OriginY += fOffset; } else { - pCharPos->m_Origin.x += fOffset; + pCharPos->m_OriginX += fOffset; } } if (chartype == FX_CHARTYPE_Combination) { CFX_Rect rtBBox; if (pFont->GetCharBBox(wForm, &rtBBox, false)) { - pCharPos->m_Origin.y = + pCharPos->m_OriginY = fYBase + fFontSize - fFontSize * (FX_FLOAT)rtBBox.height / (FX_FLOAT)iMaxHeight; } @@ -1471,7 +1472,7 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, FX_CHARTYPE_Combination) { CFX_Rect rtBox; if (pFont->GetCharBBox(wLast, &rtBox, false)) { - pCharPos->m_Origin.y -= fFontSize * rtBox.height / iMaxHeight; + pCharPos->m_OriginY -= fFontSize * rtBox.height / iMaxHeight; } } } @@ -1489,8 +1490,8 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, ptOffset.y = fFontSize * (iAscent - rtBBox.top - 150) / iMaxHeight; } } - pCharPos->m_Origin.x += ptOffset.x; - pCharPos->m_Origin.y -= ptOffset.y; + pCharPos->m_OriginX += ptOffset.x; + pCharPos->m_OriginY -= ptOffset.y; } if (!bRTLPiece && chartype != FX_CHARTYPE_Combination) { if (bVerticalDoc) { @@ -1507,26 +1508,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_Origin.y += fAscent; + pCharPos->m_OriginY += 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_Origin.x -= fDescent; + pCharPos->m_OriginX -= 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_Origin.x += fCharWidth; - pCharPos->m_Origin.y += fAscent; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY += fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x += fAscent; + pCharPos->m_OriginX += fAscent; } } else { if (iCharRotation == 0) { @@ -1539,21 +1540,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_Origin.x -= fDescent; - pCharPos->m_Origin.y -= fAscent + fDescent; + pCharPos->m_OriginX -= fDescent; + pCharPos->m_OriginY -= 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_Origin.x += fCharWidth; - pCharPos->m_Origin.y -= fAscent; + pCharPos->m_OriginX += fCharWidth; + pCharPos->m_OriginY -= fAscent; } else { pCharPos->m_AdjustMatrix[0] = 0; pCharPos->m_AdjustMatrix[1] = 1; pCharPos->m_AdjustMatrix[2] = 1; pCharPos->m_AdjustMatrix[3] = 0; - pCharPos->m_Origin.x += fAscent; + pCharPos->m_OriginX += fAscent; } } if (iHorScale != 100 || iVerScale != 100) { diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp index bc0d61fd25..93a53a88a1 100644 --- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp +++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp @@ -177,7 +177,8 @@ 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_Origin = CFX_PointF(penX + left, penY + top); + charPos[0].m_OriginX = penX + left; + charPos[0].m_OriginY = 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_ @@ -185,7 +186,8 @@ 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_Origin = CFX_PointF(penX + left, penY + top); + charPos[i].m_OriginX = penX + left; + charPos[i].m_OriginY = 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 17aa1a40ab..ad0fc057e2 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_Origin.y + 1.05f; + FX_FLOAT fEndY = pCharPos[0].m_OriginY + 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_Origin.x; + pt1.x = pCharPos[j].m_OriginX; 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_Origin.x; + pt1.x = pCharPos[0].m_OriginX; pt2.x = - pCharPos[iChars - 1].m_Origin.x + + pCharPos[iChars - 1].m_OriginX + 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_Origin.y - pPiece->rtPiece.height * 0.25f; - pt1.x = pCharPos[0].m_Origin.x; - pt2.x = pCharPos[iChars - 1].m_Origin.x + + fEndY = pCharPos[0].m_OriginY - pPiece->rtPiece.height * 0.25f; + pt1.x = pCharPos[0].m_OriginX; + pt2.x = pCharPos[iChars - 1].m_OriginX + 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_Origin.x + + fOrgX = pCharPos[iChars - 1].m_OriginX + 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_Origin.x; + fEndX = pCharPos[0].m_OriginX; CFX_PointF pt1, pt2; pt1.x = fOrgX, pt2.x = fEndX; - FX_FLOAT fEndY = pCharPos[0].m_Origin.y + 1.05f; + FX_FLOAT fEndY = pCharPos[0].m_OriginY + 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_Origin.y - pPiece->rtPiece.height * 0.25f; + fEndY = pCharPos[0].m_OriginY - 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 2b8bd17aad..f1abfb7cb5 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -1484,7 +1484,8 @@ 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_Origin = CFX_PointF(penX + left, penY + top); + charPos[0].m_OriginX = penX + left; + charPos[0].m_OriginY = 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); @@ -1497,7 +1498,8 @@ 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_Origin = CFX_PointF(penX + left, penY + top); + charPos[i].m_OriginX = penX + left; + charPos[i].m_OriginY = 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