diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-02-29 11:24:29 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-02-29 11:24:29 -0800 |
commit | d5e7b355b8c4c22ff770547797cbc536bdc95d5b (patch) | |
tree | 4c0607b1701f23753a71b42c02b74764dd4bfd38 /core/src/fpdftext | |
parent | a74e9c9d3b0d98c5d6042d7ca739cd921a4524db (diff) | |
download | pdfium-d5e7b355b8c4c22ff770547797cbc536bdc95d5b.tar.xz |
Fixup FX_RECT and FX_SMALL_RECT classes.
Put these first, so later on more complicated classes can
have constructors that take these as arguments.
Add better constructors, and call appropriately. Also don't
be afraid to return these from methods since RVO.
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1745683002 .
Diffstat (limited to 'core/src/fpdftext')
-rw-r--r-- | core/src/fpdftext/fpdf_text_int.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp index 77b610a7e8..4a0aae501c 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 = |