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

Side by Side 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: Make actual changes. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/src/fpdftext/text_int.h" 7 #include "core/src/fpdftext/text_int.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cctype> 10 #include <cctype>
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 if (pPageObj->IsText()) { 877 if (pPageObj->IsText()) {
878 ProcessTextObject(pPageObj->AsText(), curFormMatrix, pObjectList, it); 878 ProcessTextObject(pPageObj->AsText(), curFormMatrix, pObjectList, it);
879 } else if (pPageObj->IsForm()) { 879 } else if (pPageObj->IsForm()) {
880 ProcessFormObject(pPageObj->AsForm(), curFormMatrix); 880 ProcessFormObject(pPageObj->AsForm(), curFormMatrix);
881 } 881 }
882 } 882 }
883 } 883 }
884 } 884 }
885 885
886 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const { 886 int CPDF_TextPage::GetCharWidth(FX_DWORD charCode, CPDF_Font* pFont) const {
887 if (charCode == -1) { 887 if (charCode == -1)
888 return 0; 888 return 0;
889 } 889
890 int w = pFont->GetCharWidthF(charCode); 890 if (int w = pFont->GetCharWidthF(charCode))
891 if (w == 0) { 891 return w;
892 CFX_ByteString str; 892
893 pFont->AppendChar(str, charCode); 893 CFX_ByteString str;
894 w = pFont->GetStringWidth(str, 1); 894 pFont->AppendChar(str, charCode);
895 if (w == 0) { 895 if (int w = pFont->GetStringWidth(str, 1))
896 FX_RECT BBox; 896 return w;
897 pFont->GetCharBBox(charCode, BBox); 897
898 w = BBox.right - BBox.left; 898 return pFont->GetCharBBox(charCode).Width();
899 }
900 }
901 return w;
902 } 899 }
903 900
904 void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) { 901 void CPDF_TextPage::OnPiece(CFX_BidiChar* pBidi, CFX_WideString& str) {
905 CFX_BidiChar::Segment seg = pBidi->GetSegmentInfo(); 902 CFX_BidiChar::Segment seg = pBidi->GetSegmentInfo();
906 if (seg.direction == CFX_BidiChar::RIGHT) { 903 if (seg.direction == CFX_BidiChar::RIGHT) {
907 for (int i = seg.start + seg.count; i > seg.start; i--) { 904 for (int i = seg.start + seg.count; i > seg.start; i--) {
908 m_TextBuf.AppendChar(str.GetAt(i - i)); 905 m_TextBuf.AppendChar(str.GetAt(i - i));
909 m_CharList.push_back(m_TempCharList[i - 1]); 906 m_CharList.push_back(m_TempCharList[i - 1]);
910 } 907 }
911 } else { 908 } else {
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 charinfo.m_CharCode = item.m_CharCode; 1454 charinfo.m_CharCode = item.m_CharCode;
1458 if (bNoUnicode) { 1455 if (bNoUnicode) {
1459 charinfo.m_Flag = FPDFTEXT_CHAR_UNUNICODE; 1456 charinfo.m_Flag = FPDFTEXT_CHAR_UNUNICODE;
1460 } else { 1457 } else {
1461 charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL; 1458 charinfo.m_Flag = FPDFTEXT_CHAR_NORMAL;
1462 } 1459 }
1463 charinfo.m_pTextObj = pTextObj; 1460 charinfo.m_pTextObj = pTextObj;
1464 charinfo.m_OriginX = 0, charinfo.m_OriginY = 0; 1461 charinfo.m_OriginX = 0, charinfo.m_OriginY = 0;
1465 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX, 1462 matrix.Transform(item.m_OriginX, item.m_OriginY, charinfo.m_OriginX,
1466 charinfo.m_OriginY); 1463 charinfo.m_OriginY);
1467 FX_RECT rect(0, 0, 0, 0); 1464 FX_RECT rect =
1468 rect.Intersect(0, 0, 0, 0); 1465 charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode);
1469 charinfo.m_pTextObj->GetFont()->GetCharBBox(charinfo.m_CharCode, rect);
1470 charinfo.m_CharBox.top = 1466 charinfo.m_CharBox.top =
1471 rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY; 1467 rect.top * pTextObj->GetFontSize() / 1000 + item.m_OriginY;
1472 charinfo.m_CharBox.left = 1468 charinfo.m_CharBox.left =
1473 rect.left * pTextObj->GetFontSize() / 1000 + item.m_OriginX; 1469 rect.left * pTextObj->GetFontSize() / 1000 + item.m_OriginX;
1474 charinfo.m_CharBox.right = 1470 charinfo.m_CharBox.right =
1475 rect.right * pTextObj->GetFontSize() / 1000 + item.m_OriginX; 1471 rect.right * pTextObj->GetFontSize() / 1000 + item.m_OriginX;
1476 charinfo.m_CharBox.bottom = 1472 charinfo.m_CharBox.bottom =
1477 rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_OriginY; 1473 rect.bottom * pTextObj->GetFontSize() / 1000 + item.m_OriginY;
1478 if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) < 0.01f) { 1474 if (fabsf(charinfo.m_CharBox.top - charinfo.m_CharBox.bottom) < 0.01f) {
1479 charinfo.m_CharBox.top = 1475 charinfo.m_CharBox.top =
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) { 2489 if (!m_bIsParsed || index < 0 || index >= m_LinkList.GetSize()) {
2494 return; 2490 return;
2495 } 2491 }
2496 CPDF_LinkExt* link = NULL; 2492 CPDF_LinkExt* link = NULL;
2497 link = m_LinkList.GetAt(index); 2493 link = m_LinkList.GetAt(index);
2498 if (!link) { 2494 if (!link) {
2499 return; 2495 return;
2500 } 2496 }
2501 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects); 2497 m_pTextPage->GetRectArray(link->m_Start, link->m_Count, rects);
2502 } 2498 }
OLDNEW
« core/include/fxcrt/fx_coordinates.h ('K') | « core/src/fpdfapi/fpdf_page/fpdf_page.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698