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/fde/fde_gedevice.h" | 7 #include "xfa/fde/fde_gedevice.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 m_pDevice->CancelDIBits(handle); | 104 m_pDevice->CancelDIBits(handle); |
105 return handle != NULL; | 105 return handle != NULL; |
106 } | 106 } |
107 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, | 107 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, |
108 IFGAS_Font* pFont, | 108 IFGAS_Font* pFont, |
109 const FXTEXT_CHARPOS* pCharPos, | 109 const FXTEXT_CHARPOS* pCharPos, |
110 int32_t iCount, | 110 int32_t iCount, |
111 FX_FLOAT fFontSize, | 111 FX_FLOAT fFontSize, |
112 const CFX_Matrix* pMatrix) { | 112 const CFX_Matrix* pMatrix) { |
113 ASSERT(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount > 0); | 113 ASSERT(pBrush && pFont && pCharPos && iCount > 0); |
114 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); | 114 CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); |
115 CFX_Font* pFxFont = (CFX_Font*)pFont->GetDevFont(); | 115 CFX_Font* pFxFont = pFont->GetDevFont(); |
116 | |
117 FX_ARGB argb = pBrush->GetColor(); | 116 FX_ARGB argb = pBrush->GetColor(); |
118 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && | 117 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && |
119 !pFxFont->IsItalic()) { | 118 !pFxFont->IsItalic()) { |
120 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; | 119 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
121 FX_FLOAT* pAM; | 120 FX_FLOAT* pAM; |
122 for (int32_t i = 0; i < iCount; ++i) { | 121 for (int32_t i = 0; i < iCount; ++i) { |
123 static const FX_FLOAT mc = 0.267949f; | 122 static const FX_FLOAT mc = 0.267949f; |
124 pAM = pCP->m_AdjustMatrix; | 123 pAM = pCP->m_AdjustMatrix; |
125 pAM[2] = mc * pAM[0] + pAM[2]; | 124 pAM[2] = mc * pAM[0] + pAM[2]; |
126 pAM[3] = mc * pAM[1] + pAM[3]; | 125 pAM[3] = mc * pAM[1] + pAM[3]; |
(...skipping 15 matching lines...) Expand all Loading... |
142 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; | 141 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; |
143 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; | 142 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; |
144 SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic); | 143 SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic); |
145 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 144 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
146 | 145 |
147 for (int32_t i = 0; i < iCount; ++i) { | 146 for (int32_t i = 0; i < iCount; ++i) { |
148 pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); | 147 pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); |
149 pCP->m_GlyphIndex &= 0x00FFFFFF; | 148 pCP->m_GlyphIndex &= 0x00FFFFFF; |
150 pCP->m_bFontStyle = FALSE; | 149 pCP->m_bFontStyle = FALSE; |
151 if (pCurFont != pSTFont) { | 150 if (pCurFont != pSTFont) { |
152 if (pCurFont != NULL) { | 151 if (pCurFont) { |
153 pFxFont = (CFX_Font*)pCurFont->GetDevFont(); | 152 pFxFont = pCurFont->GetDevFont(); |
154 | |
155 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 153 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
156 FxFont.SetFace(pFxFont->GetFace()); | 154 FxFont.SetFace(pFxFont->GetFace()); |
157 m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache, | 155 m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache, |
158 -fFontSize, (const CFX_Matrix*)pMatrix, argb, | 156 -fFontSize, (const CFX_Matrix*)pMatrix, argb, |
159 FXTEXT_CLEARTYPE); | 157 FXTEXT_CLEARTYPE); |
160 #else | 158 #else |
161 m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, | 159 m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, |
162 -fFontSize, (const CFX_Matrix*)pMatrix, argb, | 160 -fFontSize, (const CFX_Matrix*)pMatrix, argb, |
163 FXTEXT_CLEARTYPE); | 161 FXTEXT_CLEARTYPE); |
164 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 162 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
165 } | 163 } |
166 pCurFont = pSTFont; | 164 pCurFont = pSTFont; |
167 pCurCP = pCP; | 165 pCurCP = pCP; |
168 iCurCount = 1; | 166 iCurCount = 1; |
169 } else { | 167 } else { |
170 iCurCount++; | 168 iCurCount++; |
171 } | 169 } |
172 pCP++; | 170 pCP++; |
173 } | 171 } |
174 if (pCurFont != NULL && iCurCount) { | 172 if (pCurFont && iCurCount) { |
175 pFxFont = (CFX_Font*)pCurFont->GetDevFont(); | 173 pFxFont = pCurFont->GetDevFont(); |
176 | |
177 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 174 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
178 FxFont.SetFace(pFxFont->GetFace()); | 175 FxFont.SetFace(pFxFont->GetFace()); |
179 FX_BOOL bRet = m_pDevice->DrawNormalText( | 176 FX_BOOL bRet = m_pDevice->DrawNormalText( |
180 iCurCount, pCurCP, &FxFont, pCache, -fFontSize, | 177 iCurCount, pCurCP, &FxFont, pCache, -fFontSize, |
181 (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE); | 178 (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE); |
182 FxFont.SetSubstFont(nullptr); | 179 FxFont.SetSubstFont(nullptr); |
183 FxFont.SetFace(nullptr); | 180 FxFont.SetFace(nullptr); |
184 return bRet; | 181 return bRet; |
185 #else | 182 #else |
186 return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, | 183 return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const CFX_Matrix* pMatrix) { | 324 const CFX_Matrix* pMatrix) { |
328 CFDE_Path* pGePath = (CFDE_Path*)pPath; | 325 CFDE_Path* pGePath = (CFDE_Path*)pPath; |
329 if (!pGePath) | 326 if (!pGePath) |
330 return FALSE; | 327 return FALSE; |
331 if (!pBrush) | 328 if (!pBrush) |
332 return FALSE; | 329 return FALSE; |
333 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, | 330 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, |
334 pBrush->GetColor(), 0, FXFILL_WINDING); | 331 pBrush->GetColor(), 0, FXFILL_WINDING); |
335 } | 332 } |
336 | 333 |
OLD | NEW |