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

Side by Side Diff: xfa/src/fxbarcode/oned/BC_OneDimWriter.cpp

Issue 1297083002: Merge to XFA: Cleanup CFX_UnicodeEncoding and remove IFX_FontEncoding. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 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 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2011 ZXing authors 8 * Copyright 2011 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 color ^= 1; 122 color ^= 1;
123 } 123 }
124 return numAdded; 124 return numAdded;
125 } 125 }
126 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, 126 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
127 FXTEXT_CHARPOS* charPos, 127 FXTEXT_CHARPOS* charPos,
128 CFX_Font* cFont, 128 CFX_Font* cFont,
129 FX_FLOAT geWidth, 129 FX_FLOAT geWidth,
130 int32_t fontSize, 130 int32_t fontSize,
131 FX_FLOAT& charsLen) { 131 FX_FLOAT& charsLen) {
132 #ifdef FXFM_ENCODING_NONE 132 CFX_UnicodeEncodingEx* encoding = FX_CreateFontEncodingEx(cFont);
Tom Sepez 2015/08/17 23:49:29 nit: unique_ptr?
Lei Zhang 2015/08/18 01:36:39 Done.
133 IFX_FontEncodingEx* encoding = FX_CreateFontEncodingEx(cFont);
134 #else
135 IFX_FontEncoding* encoding = FXGE_CreateUnicodeEncoding(cFont);
136 #endif
137 int32_t length = text.GetLength(); 133 int32_t length = text.GetLength();
138 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength()); 134 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength());
139 FX_FLOAT charWidth = 0; 135 FX_FLOAT charWidth = 0;
140 for (int32_t j = 0; j < text.GetLength(); j++) { 136 for (int32_t j = 0; j < text.GetLength(); j++) {
141 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); 137 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]);
142 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); 138 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]);
143 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); 139 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code);
144 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0); 140 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0);
145 charWidth += temp; 141 charWidth += temp;
146 } 142 }
(...skipping 21 matching lines...) Expand all
168 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); 164 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]);
169 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); 165 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex);
170 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 166 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
171 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex; 167 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex;
172 #endif 168 #endif
173 penX += 169 penX +=
174 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; 170 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
175 } 171 }
176 FX_Free(pCharCode); 172 FX_Free(pCharCode);
177 delete encoding; 173 delete encoding;
178 encoding = NULL; 174 encoding = NULL;
Tom Sepez 2015/08/17 23:49:29 nit: pointless assignment.
Lei Zhang 2015/08/18 01:36:39 Done.
179 } 175 }
180 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, 176 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
181 const CFX_Matrix* matrix, 177 const CFX_Matrix* matrix,
182 const CFX_ByteString str, 178 const CFX_ByteString str,
183 FX_FLOAT geWidth, 179 FX_FLOAT geWidth,
184 FXTEXT_CHARPOS* pCharPos, 180 FXTEXT_CHARPOS* pCharPos,
185 FX_FLOAT locX, 181 FX_FLOAT locX,
186 FX_FLOAT locY, 182 FX_FLOAT locY,
187 int32_t barWidth) { 183 int32_t barWidth) {
188 int32_t iFontSize = (int32_t)fabs(m_fFontSize); 184 int32_t iFontSize = (int32_t)fabs(m_fFontSize);
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { 431 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) {
436 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); 432 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e);
437 break; 433 break;
438 } 434 }
439 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); 435 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e);
440 BC_EXCEPTION_CHECK_ReturnVoid(e); 436 BC_EXCEPTION_CHECK_ReturnVoid(e);
441 } 437 }
442 outputX += m_multiple; 438 outputX += m_multiple;
443 } 439 }
444 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698