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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "../../../include/fpdfapi/fpdf_render.h" | 8 #include "../../../include/fpdfapi/fpdf_render.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../fpdf_page/pageint.h" | 10 #include "../fpdf_page/pageint.h" |
11 #include "render_int.h" | 11 #include "render_int.h" |
12 extern FX_BOOL IsAvailableMatrix(const CFX_AffineMatrix& matrix); | 12 extern bool IsAvailableMatrix(const CFX_AffineMatrix& matrix); |
13 CPDF_Type3Cache::~CPDF_Type3Cache() | 13 CPDF_Type3Cache::~CPDF_Type3Cache() |
14 { | 14 { |
15 FX_POSITION pos = m_SizeMap.GetStartPosition(); | 15 FX_POSITION pos = m_SizeMap.GetStartPosition(); |
16 CFX_ByteString Key; | 16 CFX_ByteString Key; |
17 CPDF_Type3Glyphs* pSizeCache = NULL; | 17 CPDF_Type3Glyphs* pSizeCache = NULL; |
18 while(pos) { | 18 while(pos) { |
19 pSizeCache = (CPDF_Type3Glyphs*)m_SizeMap.GetNextValue(pos); | 19 pSizeCache = (CPDF_Type3Glyphs*)m_SizeMap.GetNextValue(pos); |
20 delete pSizeCache; | 20 delete pSizeCache; |
21 } | 21 } |
22 m_SizeMap.RemoveAll(); | 22 m_SizeMap.RemoveAll(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return new_pos; | 69 return new_pos; |
70 } | 70 } |
71 blues[count++] = new_pos; | 71 blues[count++] = new_pos; |
72 return new_pos; | 72 return new_pos; |
73 } | 73 } |
74 void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top, FX_FLOAT bottom, int& top_line,
int& bottom_line) | 74 void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top, FX_FLOAT bottom, int& top_line,
int& bottom_line) |
75 { | 75 { |
76 top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); | 76 top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); |
77 bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue); | 77 bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue); |
78 } | 78 } |
79 static FX_BOOL _IsScanLine1bpp(uint8_t* pBuf, int width) | 79 static bool _IsScanLine1bpp(uint8_t* pBuf, int width) |
80 { | 80 { |
81 int size = width / 8; | 81 int size = width / 8; |
82 for (int i = 0; i < size; i ++) | 82 for (int i = 0; i < size; i ++) |
83 if (pBuf[i]) { | 83 if (pBuf[i]) { |
84 return TRUE; | 84 return true; |
85 } | 85 } |
86 if (width % 8) | 86 if (width % 8) |
87 if (pBuf[width / 8] & (0xff << (8 - width % 8))) { | 87 if (pBuf[width / 8] & (0xff << (8 - width % 8))) { |
88 return TRUE; | 88 return true; |
89 } | 89 } |
90 return FALSE; | 90 return false; |
91 } | 91 } |
92 static FX_BOOL _IsScanLine8bpp(uint8_t* pBuf, int width) | 92 static bool _IsScanLine8bpp(uint8_t* pBuf, int width) |
93 { | 93 { |
94 for (int i = 0; i < width; i ++) | 94 for (int i = 0; i < width; i ++) |
95 if (pBuf[i] > 0x40) { | 95 if (pBuf[i] > 0x40) { |
96 return TRUE; | 96 return true; |
97 } | 97 } |
98 return FALSE; | 98 return false; |
99 } | 99 } |
100 static int _DetectFirstLastScan(const CFX_DIBitmap* pBitmap, FX_BOOL bFirst) | 100 static int _DetectFirstLastScan(const CFX_DIBitmap* pBitmap, bool bFirst) |
101 { | 101 { |
102 int height = pBitmap->GetHeight(), pitch = pBitmap->GetPitch(), width = pBit
map->GetWidth(); | 102 int height = pBitmap->GetHeight(), pitch = pBitmap->GetPitch(), width = pBit
map->GetWidth(); |
103 int bpp = pBitmap->GetBPP(); | 103 int bpp = pBitmap->GetBPP(); |
104 if (bpp > 8) { | 104 if (bpp > 8) { |
105 width *= bpp / 8; | 105 width *= bpp / 8; |
106 } | 106 } |
107 uint8_t* pBuf = pBitmap->GetBuffer(); | 107 uint8_t* pBuf = pBitmap->GetBuffer(); |
108 int line = bFirst ? 0 : height - 1; | 108 int line = bFirst ? 0 : height - 1; |
109 int line_step = bFirst ? 1 : -1; | 109 int line_step = bFirst ? 1 : -1; |
110 int line_end = bFirst ? height : -1; | 110 int line_end = bFirst ? height : -1; |
(...skipping 19 matching lines...) Expand all Loading... |
130 } | 130 } |
131 CFX_DIBitmap* pBitmap = pChar->m_pBitmap; | 131 CFX_DIBitmap* pBitmap = pChar->m_pBitmap; |
132 CFX_AffineMatrix image_matrix, text_matrix; | 132 CFX_AffineMatrix image_matrix, text_matrix; |
133 image_matrix = pChar->m_ImageMatrix; | 133 image_matrix = pChar->m_ImageMatrix; |
134 text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0); | 134 text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0); |
135 image_matrix.Concat(text_matrix); | 135 image_matrix.Concat(text_matrix); |
136 CFX_DIBitmap* pResBitmap = NULL; | 136 CFX_DIBitmap* pResBitmap = NULL; |
137 int left, top; | 137 int left, top; |
138 if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 && FXSYS_f
abs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) { | 138 if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 && FXSYS_f
abs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) { |
139 int top_line, bottom_line; | 139 int top_line, bottom_line; |
140 top_line = _DetectFirstLastScan(pBitmap, TRUE); | 140 top_line = _DetectFirstLastScan(pBitmap, true); |
141 bottom_line = _DetectFirstLastScan(pBitmap, FALSE); | 141 bottom_line = _DetectFirstLastScan(pBitmap, false); |
142 if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) { | 142 if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) { |
143 FX_FLOAT top_y = image_matrix.d + image_matrix.f; | 143 FX_FLOAT top_y = image_matrix.d + image_matrix.f; |
144 FX_FLOAT bottom_y = image_matrix.f; | 144 FX_FLOAT bottom_y = image_matrix.f; |
145 FX_BOOL bFlipped = top_y > bottom_y; | 145 bool bFlipped = top_y > bottom_y; |
146 if (bFlipped) { | 146 if (bFlipped) { |
147 FX_FLOAT temp = top_y; | 147 FX_FLOAT temp = top_y; |
148 top_y = bottom_y; | 148 top_y = bottom_y; |
149 bottom_y = temp; | 149 bottom_y = temp; |
150 } | 150 } |
151 pSize->AdjustBlue(top_y, bottom_y, top_line, bottom_line); | 151 pSize->AdjustBlue(top_y, bottom_y, top_line, bottom_line); |
152 pResBitmap = pBitmap->StretchTo((int)(FXSYS_round(image_matrix.a) *
retinaScaleX), (int)((bFlipped ? top_line - bottom_line : bottom_line - top_line
) * retinaScaleY)); | 152 pResBitmap = pBitmap->StretchTo((int)(FXSYS_round(image_matrix.a) *
retinaScaleX), (int)((bFlipped ? top_line - bottom_line : bottom_line - top_line
) * retinaScaleY)); |
153 top = top_line; | 153 top = top_line; |
154 if (image_matrix.a < 0) { | 154 if (image_matrix.a < 0) { |
155 image_matrix.Scale(retinaScaleX, retinaScaleY); | 155 image_matrix.Scale(retinaScaleX, retinaScaleY); |
(...skipping 22 matching lines...) Expand all Loading... |
178 { | 178 { |
179 va_list argList; | 179 va_list argList; |
180 va_start(argList, count); | 180 va_start(argList, count); |
181 for (int i = 0; i < count; i ++) { | 181 for (int i = 0; i < count; i ++) { |
182 int p = va_arg(argList, int); | 182 int p = va_arg(argList, int); |
183 ((FX_DWORD*)m_Key)[i] = p; | 183 ((FX_DWORD*)m_Key)[i] = p; |
184 } | 184 } |
185 va_end(argList); | 185 va_end(argList); |
186 m_KeyLen = count * sizeof(FX_DWORD); | 186 m_KeyLen = count * sizeof(FX_DWORD); |
187 } | 187 } |
188 FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, const CFX
_AffineMatrix* pObj2Device, CFX_PathData* pClippingPath) | 188 bool CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, const CFX_Af
fineMatrix* pObj2Device, CFX_PathData* pClippingPath) |
189 { | 189 { |
190 if(textobj->m_nChars == 0) { | 190 if(textobj->m_nChars == 0) { |
191 return TRUE; | 191 return true; |
192 } | 192 } |
193 int text_render_mode = textobj->m_TextState.GetObject()->m_TextMode; | 193 int text_render_mode = textobj->m_TextState.GetObject()->m_TextMode; |
194 if (text_render_mode == 3) { | 194 if (text_render_mode == 3) { |
195 return TRUE; | 195 return true; |
196 } | 196 } |
197 CPDF_Font* pFont = textobj->m_TextState.GetFont(); | 197 CPDF_Font* pFont = textobj->m_TextState.GetFont(); |
198 if (pFont->GetFontType() == PDFFONT_TYPE3) { | 198 if (pFont->GetFontType() == PDFFONT_TYPE3) { |
199 return ProcessType3Text(textobj, pObj2Device); | 199 return ProcessType3Text(textobj, pObj2Device); |
200 } | 200 } |
201 FX_BOOL bFill = FALSE, bStroke = FALSE, bClip = FALSE; | 201 bool bFill = false, bStroke = false, bClip = false; |
202 if (pClippingPath) { | 202 if (pClippingPath) { |
203 bClip = TRUE; | 203 bClip = true; |
204 } else { | 204 } else { |
205 switch (text_render_mode) { | 205 switch (text_render_mode) { |
206 case 0: | 206 case 0: |
207 case 4: | 207 case 4: |
208 bFill = TRUE; | 208 bFill = true; |
209 break; | 209 break; |
210 case 1: | 210 case 1: |
211 case 5: | 211 case 5: |
212 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_Subst
Flags & FXFONT_SUBST_GLYPHPATH)) { | 212 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_Subst
Flags & FXFONT_SUBST_GLYPHPATH)) { |
213 bFill = TRUE; | 213 bFill = true; |
214 } else { | 214 } else { |
215 bStroke = TRUE; | 215 bStroke = true; |
216 } | 216 } |
217 break; | 217 break; |
218 case 2: | 218 case 2: |
219 case 6: | 219 case 6: |
220 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_Subst
Flags & FXFONT_SUBST_GLYPHPATH)) { | 220 if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_Subst
Flags & FXFONT_SUBST_GLYPHPATH)) { |
221 bFill = TRUE; | 221 bFill = true; |
222 } else { | 222 } else { |
223 bFill = bStroke = TRUE; | 223 bFill = bStroke = true; |
224 } | 224 } |
225 break; | 225 break; |
226 case 3: | 226 case 3: |
227 case 7: | 227 case 7: |
228 return TRUE; | 228 return true; |
229 default: | 229 default: |
230 bFill = TRUE; | 230 bFill = true; |
231 } | 231 } |
232 } | 232 } |
233 FX_ARGB stroke_argb = 0, fill_argb = 0; | 233 FX_ARGB stroke_argb = 0, fill_argb = 0; |
234 FX_BOOL bPattern = FALSE; | 234 bool bPattern = false; |
235 if (bStroke) { | 235 if (bStroke) { |
236 if (textobj->m_ColorState.GetStrokeColor()->IsPattern()) { | 236 if (textobj->m_ColorState.GetStrokeColor()->IsPattern()) { |
237 bPattern = TRUE; | 237 bPattern = true; |
238 } else { | 238 } else { |
239 stroke_argb = GetStrokeArgb(textobj); | 239 stroke_argb = GetStrokeArgb(textobj); |
240 } | 240 } |
241 } | 241 } |
242 if (bFill) { | 242 if (bFill) { |
243 if (textobj->m_ColorState.GetFillColor()->IsPattern()) { | 243 if (textobj->m_ColorState.GetFillColor()->IsPattern()) { |
244 bPattern = TRUE; | 244 bPattern = true; |
245 } else { | 245 } else { |
246 fill_argb = GetFillArgb(textobj); | 246 fill_argb = GetFillArgb(textobj); |
247 } | 247 } |
248 } | 248 } |
249 CFX_AffineMatrix text_matrix; | 249 CFX_AffineMatrix text_matrix; |
250 textobj->GetTextMatrix(&text_matrix); | 250 textobj->GetTextMatrix(&text_matrix); |
251 if(IsAvailableMatrix(text_matrix) == FALSE) { | 251 if(IsAvailableMatrix(text_matrix) == false) { |
252 return TRUE; | 252 return true; |
253 } | 253 } |
254 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); | 254 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); |
255 if (bPattern) { | 255 if (bPattern) { |
256 DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_ma
trix, bFill, bStroke); | 256 DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_ma
trix, bFill, bStroke); |
257 return TRUE; | 257 return true; |
258 } | 258 } |
259 if (bClip || bStroke) { | 259 if (bClip || bStroke) { |
260 const CFX_AffineMatrix* pDeviceMatrix = pObj2Device; | 260 const CFX_AffineMatrix* pDeviceMatrix = pObj2Device; |
261 CFX_AffineMatrix device_matrix; | 261 CFX_AffineMatrix device_matrix; |
262 if (bStroke) { | 262 if (bStroke) { |
263 const FX_FLOAT* pCTM = textobj->m_TextState.GetObject()->m_CTM; | 263 const FX_FLOAT* pCTM = textobj->m_TextState.GetObject()->m_CTM; |
264 if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) { | 264 if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) { |
265 CFX_AffineMatrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0); | 265 CFX_AffineMatrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0); |
266 text_matrix.ConcatInverse(ctm); | 266 text_matrix.ConcatInverse(ctm); |
267 device_matrix.Copy(ctm); | 267 device_matrix.Copy(ctm); |
(...skipping 18 matching lines...) Expand all Loading... |
286 } | 286 } |
287 text_matrix.Concat(*pObj2Device); | 287 text_matrix.Concat(*pObj2Device); |
288 return CPDF_TextRenderer::DrawNormalText(m_pDevice, textobj->m_nChars, texto
bj->m_pCharCodes, textobj->m_pCharPos, pFont, font_size, | 288 return CPDF_TextRenderer::DrawNormalText(m_pDevice, textobj->m_nChars, texto
bj->m_pCharCodes, textobj->m_pCharPos, pFont, font_size, |
289 &text_matrix, fill_argb, &m_Options); | 289 &text_matrix, fill_argb, &m_Options); |
290 } | 290 } |
291 CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) | 291 CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) |
292 { | 292 { |
293 if (pFont->m_pDocument == NULL) { | 293 if (pFont->m_pDocument == NULL) { |
294 return NULL; | 294 return NULL; |
295 } | 295 } |
296 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE); | 296 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), false); |
297 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); | 297 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); |
298 } | 298 } |
299 static void ReleaseCachedType3(CPDF_Type3Font* pFont) | 299 static void ReleaseCachedType3(CPDF_Type3Font* pFont) |
300 { | 300 { |
301 if (pFont->m_pDocument == NULL) { | 301 if (pFont->m_pDocument == NULL) { |
302 return; | 302 return; |
303 } | 303 } |
304 pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont); | 304 pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont); |
305 pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); | 305 pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); |
306 } | 306 } |
307 FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) | 307 bool CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) |
308 { | 308 { |
309 if (m_pBitmap != NULL || m_pForm == NULL) { | 309 if (m_pBitmap != NULL || m_pForm == NULL) { |
310 return TRUE; | 310 return true; |
311 } | 311 } |
312 if (m_pForm->CountObjects() == 1 && !m_bColored) { | 312 if (m_pForm->CountObjects() == 1 && !m_bColored) { |
313 CPDF_PageObject *pPageObj = m_pForm->GetObjectAt(m_pForm->GetFirstObject
Position()); | 313 CPDF_PageObject *pPageObj = m_pForm->GetObjectAt(m_pForm->GetFirstObject
Position()); |
314 if (pPageObj->m_Type == PDFPAGE_IMAGE) { | 314 if (pPageObj->m_Type == PDFPAGE_IMAGE) { |
315 CPDF_ImageObject* pImage = (CPDF_ImageObject*)pPageObj; | 315 CPDF_ImageObject* pImage = (CPDF_ImageObject*)pPageObj; |
316 m_ImageMatrix = pImage->m_Matrix; | 316 m_ImageMatrix = pImage->m_Matrix; |
317 const CFX_DIBSource* pSource = pImage->m_pImage->LoadDIBSource(); | 317 const CFX_DIBSource* pSource = pImage->m_pImage->LoadDIBSource(); |
318 if (pSource) { | 318 if (pSource) { |
319 m_pBitmap = pSource->Clone(); | 319 m_pBitmap = pSource->Clone(); |
320 delete pSource; | 320 delete pSource; |
321 } | 321 } |
322 delete m_pForm; | 322 delete m_pForm; |
323 m_pForm = NULL; | 323 m_pForm = NULL; |
324 return TRUE; | 324 return true; |
325 } | 325 } |
326 } | 326 } |
327 return FALSE; | 327 return false; |
328 } | 328 } |
329 class CPDF_RefType3Cache | 329 class CPDF_RefType3Cache |
330 { | 330 { |
331 public: | 331 public: |
332 CPDF_RefType3Cache(CPDF_Type3Font* pType3Font) | 332 CPDF_RefType3Cache(CPDF_Type3Font* pType3Font) |
333 { | 333 { |
334 m_dwCount = 0; | 334 m_dwCount = 0; |
335 m_pType3Font = pType3Font; | 335 m_pType3Font = pType3Font; |
336 } | 336 } |
337 ~CPDF_RefType3Cache() | 337 ~CPDF_RefType3Cache() |
338 { | 338 { |
339 while(m_dwCount--) { | 339 while(m_dwCount--) { |
340 ReleaseCachedType3(m_pType3Font); | 340 ReleaseCachedType3(m_pType3Font); |
341 } | 341 } |
342 } | 342 } |
343 FX_DWORD m_dwCount; | 343 FX_DWORD m_dwCount; |
344 CPDF_Type3Font* m_pType3Font; | 344 CPDF_Type3Font* m_pType3Font; |
345 }; | 345 }; |
346 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, cons
t CFX_AffineMatrix* pObj2Device) | 346 bool CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, const C
FX_AffineMatrix* pObj2Device) |
347 { | 347 { |
348 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->GetType3Font(); | 348 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->GetType3Font(); |
349 for (int j = 0; j < m_Type3FontCache.GetSize(); j++) | 349 for (int j = 0; j < m_Type3FontCache.GetSize(); j++) |
350 if ((CPDF_Type3Font*)m_Type3FontCache.GetAt(j) == pType3Font) { | 350 if ((CPDF_Type3Font*)m_Type3FontCache.GetAt(j) == pType3Font) { |
351 return TRUE; | 351 return true; |
352 } | 352 } |
353 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 353 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
354 FX_FLOAT sa = FXSYS_fabs(dCTM.a); | 354 FX_FLOAT sa = FXSYS_fabs(dCTM.a); |
355 FX_FLOAT sd = FXSYS_fabs(dCTM.d); | 355 FX_FLOAT sd = FXSYS_fabs(dCTM.d); |
356 CFX_AffineMatrix text_matrix; | 356 CFX_AffineMatrix text_matrix; |
357 textobj->GetTextMatrix(&text_matrix); | 357 textobj->GetTextMatrix(&text_matrix); |
358 CFX_AffineMatrix char_matrix = pType3Font->GetFontMatrix(); | 358 CFX_AffineMatrix char_matrix = pType3Font->GetFontMatrix(); |
359 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); | 359 FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); |
360 char_matrix.Scale(font_size, font_size); | 360 char_matrix.Scale(font_size, font_size); |
361 FX_ARGB fill_argb = GetFillArgb(textobj, TRUE); | 361 FX_ARGB fill_argb = GetFillArgb(textobj, true); |
362 int fill_alpha = FXARGB_A(fill_argb); | 362 int fill_alpha = FXARGB_A(fill_argb); |
363 int device_class = m_pDevice->GetDeviceClass(); | 363 int device_class = m_pDevice->GetDeviceClass(); |
364 FXTEXT_GLYPHPOS* pGlyphAndPos = NULL; | 364 FXTEXT_GLYPHPOS* pGlyphAndPos = NULL; |
365 if (device_class == FXDC_DISPLAY) { | 365 if (device_class == FXDC_DISPLAY) { |
366 pGlyphAndPos = FX_Alloc(FXTEXT_GLYPHPOS, textobj->m_nChars); | 366 pGlyphAndPos = FX_Alloc(FXTEXT_GLYPHPOS, textobj->m_nChars); |
367 } else if (fill_alpha < 255) { | 367 } else if (fill_alpha < 255) { |
368 return FALSE; | 368 return false; |
369 } | 369 } |
370 CPDF_RefType3Cache refTypeCache(pType3Font); | 370 CPDF_RefType3Cache refTypeCache(pType3Font); |
371 FX_DWORD *pChars = textobj->m_pCharCodes; | 371 FX_DWORD *pChars = textobj->m_pCharCodes; |
372 if (textobj->m_nChars == 1) { | 372 if (textobj->m_nChars == 1) { |
373 pChars = (FX_DWORD*)(&textobj->m_pCharCodes); | 373 pChars = (FX_DWORD*)(&textobj->m_pCharCodes); |
374 } | 374 } |
375 for (int iChar = 0; iChar < textobj->m_nChars; iChar ++) { | 375 for (int iChar = 0; iChar < textobj->m_nChars; iChar ++) { |
376 FX_DWORD charcode = pChars[iChar]; | 376 FX_DWORD charcode = pChars[iChar]; |
377 if (charcode == (FX_DWORD) - 1) { | 377 if (charcode == (FX_DWORD) - 1) { |
378 continue; | 378 continue; |
(...skipping 13 matching lines...) Expand all Loading... |
392 if (glyph.m_pGlyph == NULL) { | 392 if (glyph.m_pGlyph == NULL) { |
393 continue; | 393 continue; |
394 } | 394 } |
395 m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap, | 395 m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap, |
396 glyph.m_OriginX + glyph.m_pGlyph->m_Le
ft, | 396 glyph.m_OriginX + glyph.m_pGlyph->m_Le
ft, |
397 glyph.m_OriginY - glyph.m_pGlyph->m_To
p, fill_argb); | 397 glyph.m_OriginY - glyph.m_pGlyph->m_To
p, fill_argb); |
398 } | 398 } |
399 FX_Free(pGlyphAndPos); | 399 FX_Free(pGlyphAndPos); |
400 pGlyphAndPos = NULL; | 400 pGlyphAndPos = NULL; |
401 } | 401 } |
402 CPDF_GraphicStates* pStates = CloneObjStates(textobj, FALSE); | 402 CPDF_GraphicStates* pStates = CloneObjStates(textobj, false); |
403 CPDF_RenderOptions Options = m_Options; | 403 CPDF_RenderOptions Options = m_Options; |
404 Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; | 404 Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; |
405 Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; | 405 Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; |
406 CPDF_Dictionary* pFormResource = NULL; | 406 CPDF_Dictionary* pFormResource = NULL; |
407 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { | 407 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { |
408 pFormResource = pType3Char->m_pForm->m_pFormDict->GetDict(FX_BST
RC("Resources")); | 408 pFormResource = pType3Char->m_pForm->m_pFormDict->GetDict(FX_BST
RC("Resources")); |
409 } | 409 } |
410 if (fill_alpha == 255) { | 410 if (fill_alpha == 255) { |
411 CPDF_RenderStatus status; | 411 CPDF_RenderStatus status; |
412 status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStat
es, &Options, | 412 status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStat
es, &Options, |
413 pType3Char->m_pForm->m_Transparency, m_bDropOb
jects, pFormResource, FALSE, pType3Char, fill_argb); | 413 pType3Char->m_pForm->m_Transparency, m_bDropOb
jects, pFormResource, false, pType3Char, fill_argb); |
414 status.m_Type3FontCache.Append(m_Type3FontCache); | 414 status.m_Type3FontCache.Append(m_Type3FontCache); |
415 status.m_Type3FontCache.Add(pType3Font); | 415 status.m_Type3FontCache.Add(pType3Font); |
416 m_pDevice->SaveState(); | 416 m_pDevice->SaveState(); |
417 status.RenderObjectList(pType3Char->m_pForm, &matrix); | 417 status.RenderObjectList(pType3Char->m_pForm, &matrix); |
418 m_pDevice->RestoreState(); | 418 m_pDevice->RestoreState(); |
419 } else { | 419 } else { |
420 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); | 420 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); |
421 rect_f.Transform(&matrix); | 421 rect_f.Transform(&matrix); |
422 FX_RECT rect = rect_f.GetOutterRect(); | 422 FX_RECT rect = rect_f.GetOutterRect(); |
423 CFX_FxgeDevice bitmap_device; | 423 CFX_FxgeDevice bitmap_device; |
424 if (!bitmap_device.Create((int)(rect.Width() * sa), (int)(rect.H
eight() * sd), FXDIB_Argb)) { | 424 if (!bitmap_device.Create((int)(rect.Width() * sa), (int)(rect.H
eight() * sd), FXDIB_Argb)) { |
425 return TRUE; | 425 return true; |
426 } | 426 } |
427 bitmap_device.GetBitmap()->Clear(0); | 427 bitmap_device.GetBitmap()->Clear(0); |
428 CPDF_RenderStatus status; | 428 CPDF_RenderStatus status; |
429 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, this,
pStates, &Options, | 429 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, this,
pStates, &Options, |
430 pType3Char->m_pForm->m_Transparency, m_bDropOb
jects, pFormResource, FALSE, pType3Char, fill_argb); | 430 pType3Char->m_pForm->m_Transparency, m_bDropOb
jects, pFormResource, false, pType3Char, fill_argb); |
431 status.m_Type3FontCache.Append(m_Type3FontCache); | 431 status.m_Type3FontCache.Append(m_Type3FontCache); |
432 status.m_Type3FontCache.Add(pType3Font); | 432 status.m_Type3FontCache.Add(pType3Font); |
433 matrix.TranslateI(-rect.left, -rect.top); | 433 matrix.TranslateI(-rect.left, -rect.top); |
434 matrix.Scale(sa, sd); | 434 matrix.Scale(sa, sd); |
435 status.RenderObjectList(pType3Char->m_pForm, &matrix); | 435 status.RenderObjectList(pType3Char->m_pForm, &matrix); |
436 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.
top); | 436 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.
top); |
437 } | 437 } |
438 delete pStates; | 438 delete pStates; |
439 } else if (pType3Char->m_pBitmap) { | 439 } else if (pType3Char->m_pBitmap) { |
440 if (device_class == FXDC_DISPLAY) { | 440 if (device_class == FXDC_DISPLAY) { |
441 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); | 441 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); |
442 refTypeCache.m_dwCount++; | 442 refTypeCache.m_dwCount++; |
443 CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix,
sa, sd); | 443 CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix,
sa, sd); |
444 if (pBitmap == NULL) { | 444 if (pBitmap == NULL) { |
445 continue; | 445 continue; |
446 } | 446 } |
447 int origin_x = FXSYS_round(matrix.e); | 447 int origin_x = FXSYS_round(matrix.e); |
448 int origin_y = FXSYS_round(matrix.f); | 448 int origin_y = FXSYS_round(matrix.f); |
449 if (pGlyphAndPos) { | 449 if (pGlyphAndPos) { |
450 pGlyphAndPos[iChar].m_pGlyph = pBitmap; | 450 pGlyphAndPos[iChar].m_pGlyph = pBitmap; |
451 pGlyphAndPos[iChar].m_OriginX = origin_x; | 451 pGlyphAndPos[iChar].m_OriginX = origin_x; |
452 pGlyphAndPos[iChar].m_OriginY = origin_y; | 452 pGlyphAndPos[iChar].m_OriginY = origin_y; |
453 } else { | 453 } else { |
454 m_pDevice->SetBitMask(&pBitmap->m_Bitmap, origin_x + pBitmap
->m_Left, origin_y - pBitmap->m_Top, fill_argb); | 454 m_pDevice->SetBitMask(&pBitmap->m_Bitmap, origin_x + pBitmap
->m_Left, origin_y - pBitmap->m_Top, fill_argb); |
455 } | 455 } |
456 } else { | 456 } else { |
457 CFX_AffineMatrix image_matrix = pType3Char->m_ImageMatrix; | 457 CFX_AffineMatrix image_matrix = pType3Char->m_ImageMatrix; |
458 image_matrix.Concat(matrix); | 458 image_matrix.Concat(matrix); |
459 CPDF_ImageRenderer renderer; | 459 CPDF_ImageRenderer renderer; |
460 if (renderer.Start(this, pType3Char->m_pBitmap, fill_argb, 255,
&image_matrix, 0, FALSE)) { | 460 if (renderer.Start(this, pType3Char->m_pBitmap, fill_argb, 255,
&image_matrix, 0, false)) { |
461 renderer.Continue(NULL); | 461 renderer.Continue(NULL); |
462 } | 462 } |
463 if (!renderer.m_Result) { | 463 if (!renderer.m_Result) { |
464 return FALSE; | 464 return false; |
465 } | 465 } |
466 } | 466 } |
467 } | 467 } |
468 } | 468 } |
469 if (pGlyphAndPos) { | 469 if (pGlyphAndPos) { |
470 FX_RECT rect = FXGE_GetGlyphsBBox(pGlyphAndPos, textobj->m_nChars, 0, sa
, sd); | 470 FX_RECT rect = FXGE_GetGlyphsBBox(pGlyphAndPos, textobj->m_nChars, 0, sa
, sd); |
471 CFX_DIBitmap bitmap; | 471 CFX_DIBitmap bitmap; |
472 if (!bitmap.Create((int)(rect.Width() * sa), (int)(rect.Height() * sd),
FXDIB_8bppMask)) { | 472 if (!bitmap.Create((int)(rect.Width() * sa), (int)(rect.Height() * sd),
FXDIB_8bppMask)) { |
473 FX_Free(pGlyphAndPos); | 473 FX_Free(pGlyphAndPos); |
474 return TRUE; | 474 return true; |
475 } | 475 } |
476 bitmap.Clear(0); | 476 bitmap.Clear(0); |
477 for (int iChar = 0; iChar < textobj->m_nChars; iChar ++) { | 477 for (int iChar = 0; iChar < textobj->m_nChars; iChar ++) { |
478 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; | 478 FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar]; |
479 if (glyph.m_pGlyph == NULL) { | 479 if (glyph.m_pGlyph == NULL) { |
480 continue; | 480 continue; |
481 } | 481 } |
482 bitmap.TransferBitmap((int)((glyph.m_OriginX + glyph.m_pGlyph->m_Lef
t - rect.left) * sa), | 482 bitmap.TransferBitmap((int)((glyph.m_OriginX + glyph.m_pGlyph->m_Lef
t - rect.left) * sa), |
483 (int)((glyph.m_OriginY - glyph.m_pGlyph->m_Top
- rect.top) * sd), | 483 (int)((glyph.m_OriginY - glyph.m_pGlyph->m_Top
- rect.top) * sd), |
484 glyph.m_pGlyph->m_Bitmap.GetWidth(), glyph.m_p
Glyph->m_Bitmap.GetHeight(), | 484 glyph.m_pGlyph->m_Bitmap.GetWidth(), glyph.m_p
Glyph->m_Bitmap.GetHeight(), |
485 &glyph.m_pGlyph->m_Bitmap, 0, 0); | 485 &glyph.m_pGlyph->m_Bitmap, 0, 0); |
486 } | 486 } |
487 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); | 487 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); |
488 FX_Free(pGlyphAndPos); | 488 FX_Free(pGlyphAndPos); |
489 } | 489 } |
490 return TRUE; | 490 return true; |
491 } | 491 } |
492 class CPDF_CharPosList | 492 class CPDF_CharPosList |
493 { | 493 { |
494 public: | 494 public: |
495 CPDF_CharPosList(); | 495 CPDF_CharPosList(); |
496 ~CPDF_CharPosList(); | 496 ~CPDF_CharPosList(); |
497 void Load(int nChars, FX_DWORD* pCharCodes, F
X_FLOAT* pCharPos, CPDF_Font* pFont, FX_FLOAT font_size); | 497 void Load(int nChars, FX_DWORD* pCharCodes, F
X_FLOAT* pCharPos, CPDF_Font* pFont, FX_FLOAT font_size); |
498 FXTEXT_CHARPOS* m_pCharPos; | 498 FXTEXT_CHARPOS* m_pCharPos; |
499 FX_DWORD m_nChars; | 499 FX_DWORD m_nChars; |
500 }; | 500 }; |
501 FX_FLOAT _CIDTransformToFloat(uint8_t ch); | 501 FX_FLOAT _CIDTransformToFloat(uint8_t ch); |
502 CPDF_CharPosList::CPDF_CharPosList() | 502 CPDF_CharPosList::CPDF_CharPosList() |
503 { | 503 { |
504 m_pCharPos = NULL; | 504 m_pCharPos = NULL; |
505 } | 505 } |
506 CPDF_CharPosList::~CPDF_CharPosList() | 506 CPDF_CharPosList::~CPDF_CharPosList() |
507 { | 507 { |
508 if (m_pCharPos) { | 508 if (m_pCharPos) { |
509 FX_Free(m_pCharPos); | 509 FX_Free(m_pCharPos); |
510 } | 510 } |
511 } | 511 } |
512 void CPDF_CharPosList::Load(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos
, CPDF_Font* pFont, | 512 void CPDF_CharPosList::Load(int nChars, FX_DWORD* pCharCodes, FX_FLOAT* pCharPos
, CPDF_Font* pFont, |
513 FX_FLOAT FontSize) | 513 FX_FLOAT FontSize) |
514 { | 514 { |
515 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); | 515 m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); |
516 m_nChars = 0; | 516 m_nChars = 0; |
517 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); | 517 CPDF_CIDFont* pCIDFont = pFont->GetCIDFont(); |
518 FX_BOOL bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); | 518 bool bVertWriting = pCIDFont && pCIDFont->IsVertWriting(); |
519 for (int iChar = 0; iChar < nChars; iChar ++) { | 519 for (int iChar = 0; iChar < nChars; iChar ++) { |
520 FX_DWORD CharCode = nChars == 1 ? (FX_DWORD)(uintptr_t)pCharCodes : pCha
rCodes[iChar]; | 520 FX_DWORD CharCode = nChars == 1 ? (FX_DWORD)(uintptr_t)pCharCodes : pCha
rCodes[iChar]; |
521 if (CharCode == (FX_DWORD) - 1) { | 521 if (CharCode == (FX_DWORD) - 1) { |
522 continue; | 522 continue; |
523 } | 523 } |
524 FX_BOOL bVert = FALSE; | 524 bool bVert = false; |
525 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; | 525 FXTEXT_CHARPOS& charpos = m_pCharPos[m_nChars++]; |
526 if (pCIDFont) { | 526 if (pCIDFont) { |
527 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); | 527 charpos.m_bFontStyle = pCIDFont->IsFontStyleFromCharCode(CharCode); |
528 } | 528 } |
529 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); | 529 charpos.m_GlyphIndex = pFont->GlyphFromCharCode(CharCode, &bVert); |
530 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 530 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
531 charpos.m_ExtGID = pFont->GlyphFromCharCodeExt(CharCode); | 531 charpos.m_ExtGID = pFont->GlyphFromCharCodeExt(CharCode); |
532 #endif | 532 #endif |
533 if (!pFont->IsEmbedded() && pFont->GetFontType() != PDFFONT_CIDFONT) { | 533 if (!pFont->IsEmbedded() && pFont->GetFontType() != PDFFONT_CIDFONT) { |
534 charpos.m_FontCharWidth = pFont->GetCharWidthF(CharCode); | 534 charpos.m_FontCharWidth = pFont->GetCharWidthF(CharCode); |
535 } else { | 535 } else { |
536 charpos.m_FontCharWidth = 0; | 536 charpos.m_FontCharWidth = 0; |
537 } | 537 } |
538 charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; | 538 charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0; |
539 charpos.m_OriginY = 0; | 539 charpos.m_OriginY = 0; |
540 charpos.m_bGlyphAdjust = FALSE; | 540 charpos.m_bGlyphAdjust = false; |
541 if (pCIDFont == NULL) { | 541 if (pCIDFont == NULL) { |
542 continue; | 542 continue; |
543 } | 543 } |
544 FX_WORD CID = pCIDFont->CIDFromCharCode(CharCode); | 544 FX_WORD CID = pCIDFont->CIDFromCharCode(CharCode); |
545 if (bVertWriting) { | 545 if (bVertWriting) { |
546 charpos.m_OriginY = charpos.m_OriginX; | 546 charpos.m_OriginY = charpos.m_OriginX; |
547 charpos.m_OriginX = 0; | 547 charpos.m_OriginX = 0; |
548 short vx, vy; | 548 short vx, vy; |
549 pCIDFont->GetVertOrigin(CID, vx, vy); | 549 pCIDFont->GetVertOrigin(CID, vx, vy); |
550 charpos.m_OriginX -= FontSize * vx / 1000; | 550 charpos.m_OriginX -= FontSize * vx / 1000; |
551 charpos.m_OriginY -= FontSize * vy / 1000; | 551 charpos.m_OriginY -= FontSize * vy / 1000; |
552 } | 552 } |
553 const uint8_t* pTransform = pCIDFont->GetCIDTransform(CID); | 553 const uint8_t* pTransform = pCIDFont->GetCIDTransform(CID); |
554 if (pTransform && !bVert) { | 554 if (pTransform && !bVert) { |
555 charpos.m_AdjustMatrix[0] = _CIDTransformToFloat(pTransform[0]); | 555 charpos.m_AdjustMatrix[0] = _CIDTransformToFloat(pTransform[0]); |
556 charpos.m_AdjustMatrix[2] = _CIDTransformToFloat(pTransform[2]); | 556 charpos.m_AdjustMatrix[2] = _CIDTransformToFloat(pTransform[2]); |
557 charpos.m_AdjustMatrix[1] = _CIDTransformToFloat(pTransform[1]); | 557 charpos.m_AdjustMatrix[1] = _CIDTransformToFloat(pTransform[1]); |
558 charpos.m_AdjustMatrix[3] = _CIDTransformToFloat(pTransform[3]); | 558 charpos.m_AdjustMatrix[3] = _CIDTransformToFloat(pTransform[3]); |
559 charpos.m_OriginX += _CIDTransformToFloat(pTransform[4]) * FontSize; | 559 charpos.m_OriginX += _CIDTransformToFloat(pTransform[4]) * FontSize; |
560 charpos.m_OriginY += _CIDTransformToFloat(pTransform[5]) * FontSize; | 560 charpos.m_OriginY += _CIDTransformToFloat(pTransform[5]) * FontSize; |
561 charpos.m_bGlyphAdjust = TRUE; | 561 charpos.m_bGlyphAdjust = true; |
562 } | 562 } |
563 } | 563 } |
564 } | 564 } |
565 FX_BOOL CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, int nChars, F
X_DWORD* pCharCodes, FX_FLOAT* pCharPos, | 565 bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, int nChars, FX_D
WORD* pCharCodes, FX_FLOAT* pCharPos, |
566 CPDF_Font* pFont, FX_FLOAT font_size, | 566 CPDF_Font* pFont, FX_FLOAT font_size, |
567 const CFX_AffineMatrix* pText2User, cons
t CFX_AffineMatrix* pUser2Device, | 567 const CFX_AffineMatrix* pText2User, cons
t CFX_AffineMatrix* pUser2Device, |
568 const CFX_GraphStateData* pGraphState, | 568 const CFX_GraphStateData* pGraphState, |
569 FX_ARGB fill_argb, FX_ARGB stroke_argb,
CFX_PathData* pClippingPath, int nFlag) | 569 FX_ARGB fill_argb, FX_ARGB stroke_argb,
CFX_PathData* pClippingPath, int nFlag) |
570 { | 570 { |
571 CFX_FontCache* pCache = pFont->m_pDocument ? pFont->m_pDocument->GetRenderDa
ta()->GetFontCache() : NULL; | 571 CFX_FontCache* pCache = pFont->m_pDocument ? pFont->m_pDocument->GetRenderDa
ta()->GetFontCache() : NULL; |
572 CPDF_CharPosList CharPosList; | 572 CPDF_CharPosList CharPosList; |
573 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); | 573 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); |
574 return pDevice->DrawTextPath(CharPosList.m_nChars, CharPosList.m_pCharPos, | 574 return pDevice->DrawTextPath(CharPosList.m_nChars, CharPosList.m_pCharPos, |
575 &pFont->m_Font, pCache, font_size, pText2User,
pUser2Device, | 575 &pFont->m_Font, pCache, font_size, pText2User,
pUser2Device, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 else if (stroke_argb == 0) { | 625 else if (stroke_argb == 0) { |
626 DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
&matrix, fill_argb, pOptions); | 626 DrawNormalText(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size,
&matrix, fill_argb, pOptions); |
627 } else | 627 } else |
628 DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &m
atrix, NULL, pGraphState, | 628 DrawTextPath(pDevice, nChars, pCharCodes, pCharPos, pFont, font_size, &m
atrix, NULL, pGraphState, |
629 fill_argb, stroke_argb, NULL); | 629 fill_argb, stroke_argb, NULL); |
630 if (nChars > 1) { | 630 if (nChars > 1) { |
631 FX_Free(pCharCodes); | 631 FX_Free(pCharCodes); |
632 FX_Free(pCharPos); | 632 FX_Free(pCharPos); |
633 } | 633 } |
634 } | 634 } |
635 FX_BOOL CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, int nChars,
FX_DWORD* pCharCodes, FX_FLOAT* pCharPos, | 635 bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, int nChars, FX
_DWORD* pCharCodes, FX_FLOAT* pCharPos, |
636 CPDF_Font* pFont, FX_FLOAT font_size, | 636 CPDF_Font* pFont, FX_FLOAT font_size, |
637 const CFX_AffineMatrix* pText2Device, | 637 const CFX_AffineMatrix* pText2Device, |
638 FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions) | 638 FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions) |
639 { | 639 { |
640 CFX_FontCache* pCache = pFont->m_pDocument ? pFont->m_pDocument->GetRenderDa
ta()->GetFontCache() : NULL; | 640 CFX_FontCache* pCache = pFont->m_pDocument ? pFont->m_pDocument->GetRenderDa
ta()->GetFontCache() : NULL; |
641 CPDF_CharPosList CharPosList; | 641 CPDF_CharPosList CharPosList; |
642 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); | 642 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); |
643 int FXGE_flags = 0; | 643 int FXGE_flags = 0; |
644 if (pOptions) { | 644 if (pOptions) { |
645 FX_DWORD dwFlags = pOptions->m_Flags; | 645 FX_DWORD dwFlags = pOptions->m_Flags; |
(...skipping 18 matching lines...) Expand all Loading... |
664 } else { | 664 } else { |
665 FXGE_flags = FXTEXT_CLEARTYPE; | 665 FXGE_flags = FXTEXT_CLEARTYPE; |
666 } | 666 } |
667 if (pFont->GetFontType() & PDFFONT_CIDFONT) { | 667 if (pFont->GetFontType() & PDFFONT_CIDFONT) { |
668 FXGE_flags |= FXFONT_CIDFONT; | 668 FXGE_flags |= FXFONT_CIDFONT; |
669 } | 669 } |
670 return pDevice->DrawNormalText(CharPosList.m_nChars, CharPosList.m_pCharPos,
&pFont->m_Font, pCache, font_size, pText2Device, fill_argb, FXGE_flags); | 670 return pDevice->DrawNormalText(CharPosList.m_nChars, CharPosList.m_pCharPos,
&pFont->m_Font, pCache, font_size, pText2Device, fill_argb, FXGE_flags); |
671 } | 671 } |
672 void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
const CFX_AffineMatrix* pObj2Device, | 672 void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
const CFX_AffineMatrix* pObj2Device, |
673 CPDF_Font* pFont, FX_FLOAT font_size, | 673 CPDF_Font* pFont, FX_FLOAT font_size, |
674 const CFX_AffineMatrix* pTextMatrix, FX_BOOL bFill, FX_BOOL bStroke) | 674 const CFX_AffineMatrix* pTextMatrix, bool bFill, bool bStroke) |
675 { | 675 { |
676 if (!bStroke) { | 676 if (!bStroke) { |
677 CPDF_PathObject path; | 677 CPDF_PathObject path; |
678 CPDF_TextObject* pCopy = new CPDF_TextObject; | 678 CPDF_TextObject* pCopy = new CPDF_TextObject; |
679 pCopy->Copy(textobj); | 679 pCopy->Copy(textobj); |
680 path.m_bStroke = FALSE; | 680 path.m_bStroke = false; |
681 path.m_FillType = FXFILL_WINDING; | 681 path.m_FillType = FXFILL_WINDING; |
682 path.m_ClipPath.AppendTexts(&pCopy, 1); | 682 path.m_ClipPath.AppendTexts(&pCopy, 1); |
683 path.m_ColorState = textobj->m_ColorState; | 683 path.m_ColorState = textobj->m_ColorState; |
684 path.m_Path.New()->AppendRect(textobj->m_Left, textobj->m_Bottom, textob
j->m_Right, textobj->m_Top); | 684 path.m_Path.New()->AppendRect(textobj->m_Left, textobj->m_Bottom, textob
j->m_Right, textobj->m_Top); |
685 path.m_Left = textobj->m_Left; | 685 path.m_Left = textobj->m_Left; |
686 path.m_Bottom = textobj->m_Bottom; | 686 path.m_Bottom = textobj->m_Bottom; |
687 path.m_Right = textobj->m_Right; | 687 path.m_Right = textobj->m_Right; |
688 path.m_Top = textobj->m_Top; | 688 path.m_Top = textobj->m_Top; |
689 RenderSingleObject(&path, pObj2Device); | 689 RenderSingleObject(&path, pObj2Device); |
690 return; | 690 return; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 723 } |
724 } | 724 } |
725 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) | 725 CFX_PathData* CPDF_Font::LoadGlyphPath(FX_DWORD charcode, int dest_width) |
726 { | 726 { |
727 int glyph_index = GlyphFromCharCode(charcode); | 727 int glyph_index = GlyphFromCharCode(charcode); |
728 if (m_Font.m_Face == NULL) { | 728 if (m_Font.m_Face == NULL) { |
729 return NULL; | 729 return NULL; |
730 } | 730 } |
731 return m_Font.LoadGlyphPath(glyph_index, dest_width); | 731 return m_Font.LoadGlyphPath(glyph_index, dest_width); |
732 } | 732 } |
OLD | NEW |