OLD | NEW |
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 "xfa/fgas/layout/fgas_rtfbreak.h" | 7 #include "xfa/fgas/layout/fgas_rtfbreak.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fxcrt/include/fx_arabic.h" | 11 #include "core/fxcrt/include/fx_arabic.h" |
12 #include "core/fxcrt/include/fx_arb.h" | 12 #include "core/fxcrt/include/fx_arb.h" |
| 13 #include "xfa/fgas/font/fgas_gefont.h" |
13 #include "xfa/fgas/layout/fgas_linebreak.h" | 14 #include "xfa/fgas/layout/fgas_linebreak.h" |
14 #include "xfa/fgas/layout/fgas_unicode.h" | 15 #include "xfa/fgas/layout/fgas_unicode.h" |
15 | 16 |
16 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) | 17 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) |
17 : m_dwPolicies(dwPolicies), | 18 : m_dwPolicies(dwPolicies), |
18 m_iBoundaryStart(0), | 19 m_iBoundaryStart(0), |
19 m_iBoundaryEnd(2000000), | 20 m_iBoundaryEnd(2000000), |
20 m_dwLayoutStyles(0), | 21 m_dwLayoutStyles(0), |
21 m_bPagination(FALSE), | 22 m_bPagination(FALSE), |
22 m_bVertical(FALSE), | 23 m_bVertical(FALSE), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 SetBreakStatus(); | 80 SetBreakStatus(); |
80 m_dwLayoutStyles = dwLayoutStyles; | 81 m_dwLayoutStyles = dwLayoutStyles; |
81 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; | 82 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; |
82 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 83 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
83 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 84 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
84 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 85 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
85 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 86 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
86 m_iRotation = m_iLineRotation + m_iCharRotation; | 87 m_iRotation = m_iLineRotation + m_iCharRotation; |
87 m_iRotation %= 4; | 88 m_iRotation %= 4; |
88 } | 89 } |
89 void CFX_RTFBreak::SetFont(IFX_Font* pFont) { | 90 void CFX_RTFBreak::SetFont(CFX_GEFont* pFont) { |
90 if (pFont == NULL) { | 91 if (pFont == NULL) { |
91 return; | 92 return; |
92 } | 93 } |
93 if (m_pFont == pFont) { | 94 if (m_pFont == pFont) { |
94 return; | 95 return; |
95 } | 96 } |
96 SetBreakStatus(); | 97 SetBreakStatus(); |
97 m_pFont = pFont; | 98 m_pFont = pFont; |
98 m_iDefChar = 0; | 99 m_iDefChar = 0; |
99 if (m_pFont != NULL) { | 100 if (m_pFont != NULL) { |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 CFX_WideString* pWSForms, | 1179 CFX_WideString* pWSForms, |
1179 FX_AdjustCharDisplayPos pAdjustPos) const { | 1180 FX_AdjustCharDisplayPos pAdjustPos) const { |
1180 if (pText == NULL || pText->iLength < 1) { | 1181 if (pText == NULL || pText->iLength < 1) { |
1181 return 0; | 1182 return 0; |
1182 } | 1183 } |
1183 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1184 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && |
1184 pText->pFont != NULL && pText->pRect != NULL); | 1185 pText->pFont != NULL && pText->pRect != NULL); |
1185 const FX_WCHAR* pStr = pText->pStr; | 1186 const FX_WCHAR* pStr = pText->pStr; |
1186 int32_t* pWidths = pText->pWidths; | 1187 int32_t* pWidths = pText->pWidths; |
1187 int32_t iLength = pText->iLength - 1; | 1188 int32_t iLength = pText->iLength - 1; |
1188 IFX_Font* pFont = pText->pFont; | 1189 CFX_GEFont* pFont = pText->pFont; |
1189 uint32_t dwStyles = pText->dwLayoutStyles; | 1190 uint32_t dwStyles = pText->dwLayoutStyles; |
1190 CFX_RectF rtText(*pText->pRect); | 1191 CFX_RectF rtText(*pText->pRect); |
1191 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1192 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1192 FX_FLOAT fFontSize = pText->fFontSize; | 1193 FX_FLOAT fFontSize = pText->fFontSize; |
1193 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1194 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1194 int32_t iAscent = pFont->GetAscent(); | 1195 int32_t iAscent = pFont->GetAscent(); |
1195 int32_t iDescent = pFont->GetDescent(); | 1196 int32_t iDescent = pFont->GetDescent(); |
1196 int32_t iMaxHeight = iAscent - iDescent; | 1197 int32_t iMaxHeight = iAscent - iDescent; |
1197 FX_FLOAT fFontHeight = fFontSize; | 1198 FX_FLOAT fFontHeight = fFontSize; |
1198 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; | 1199 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1424 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1425 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && |
1425 pText->pFont != NULL && pText->pRect != NULL); | 1426 pText->pFont != NULL && pText->pRect != NULL); |
1426 const FX_WCHAR* pStr = pText->pStr; | 1427 const FX_WCHAR* pStr = pText->pStr; |
1427 int32_t* pWidths = pText->pWidths; | 1428 int32_t* pWidths = pText->pWidths; |
1428 int32_t iLength = pText->iLength; | 1429 int32_t iLength = pText->iLength; |
1429 CFX_RectF rect(*pText->pRect); | 1430 CFX_RectF rect(*pText->pRect); |
1430 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1431 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1431 FX_FLOAT fFontSize = pText->fFontSize; | 1432 FX_FLOAT fFontSize = pText->fFontSize; |
1432 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1433 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1433 FX_FLOAT fScale = fFontSize / 1000.0f; | 1434 FX_FLOAT fScale = fFontSize / 1000.0f; |
1434 IFX_Font* pFont = pText->pFont; | 1435 CFX_GEFont* pFont = pText->pFont; |
1435 if (pFont == NULL) { | 1436 if (pFont == NULL) { |
1436 bCharBBox = FALSE; | 1437 bCharBBox = FALSE; |
1437 } | 1438 } |
1438 CFX_Rect bbox; | 1439 CFX_Rect bbox; |
1439 bbox.Set(0, 0, 0, 0); | 1440 bbox.Set(0, 0, 0, 0); |
1440 if (bCharBBox) { | 1441 if (bCharBBox) { |
1441 bCharBBox = pFont->GetBBox(bbox); | 1442 bCharBBox = pFont->GetBBox(bbox); |
1442 } | 1443 } |
1443 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1444 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1444 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1445 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 rtBBoxF.height = fHeight; | 1514 rtBBoxF.height = fHeight; |
1514 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1515 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
1515 } | 1516 } |
1516 rtArray.SetAt(i, rtBBoxF); | 1517 rtArray.SetAt(i, rtBBoxF); |
1517 continue; | 1518 continue; |
1518 } | 1519 } |
1519 rtArray.SetAt(i, rect); | 1520 rtArray.SetAt(i, rect); |
1520 } | 1521 } |
1521 return iLength; | 1522 return iLength; |
1522 } | 1523 } |
OLD | NEW |