Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1348)

Unified Diff: core/src/fpdftext/fpdf_text_int.cpp

Issue 1745683002: Fixup FX_RECT and FX_SMALL_RECT classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, Dan's comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fpdftext/fpdf_text_int.cpp
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 77b610a7e89f9c90f1955769ab5d4275f234ac9d..4a0aae501c579d0528d3f39aab99b5cb069d3655 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -884,21 +884,18 @@ void CPDF_TextPage::ProcessFormObject(CPDF_FormObject* pFormObj,
}
int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const {
- if (charCode == -1) {
+ if (charCode == -1)
return 0;
- }
- int w = pFont->GetCharWidthF(charCode);
- if (w == 0) {
- CFX_ByteString str;
- pFont->AppendChar(str, charCode);
- w = pFont->GetStringWidth(str, 1);
- if (w == 0) {
- FX_RECT BBox;
- pFont->GetCharBBox(charCode, BBox);
- w = BBox.right - BBox.left;
- }
- }
- return w;
+
+ if (int w = pFont->GetCharWidthF(charCode))
+ return w;
+
+ CFX_ByteString str;
+ pFont->AppendChar(str, charCode);
+ if (int w = pFont->GetStringWidth(str, 1))
+ return w;
+
+ return pFont->GetCharBBox(charCode).Width();
}
void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) {
@@ -1464,9 +1461,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
charinfo.m_OriginX = 0, charinfo.m_OriginY = 0;
matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX,
charinfo.m_OriginY);
- FX_RECT rect(0, 0, 0, 0);
- rect.Intersect(0, 0, 0, 0);
- charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode, rect);
+ FX_RECT rect =
+ charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode);
charinfo.m_CharBox.top =
rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY;
charinfo.m_CharBox.left =

Powered by Google App Engine
This is Rietveld 408576698