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

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: nits 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
« no previous file with comments | « xfa/src/fgas/src/font/fx_gefont.cpp ('k') | xfa/src/fxgraphics/src/fx_graphics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
11 * you may not use this file except in compliance with the License. 11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at 12 * You may obtain a copy of the License at
13 * 13 *
14 * http://www.apache.org/licenses/LICENSE-2.0 14 * http://www.apache.org/licenses/LICENSE-2.0
15 * 15 *
16 * Unless required by applicable law or agreed to in writing, software 16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS, 17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and 19 * See the License for the specific language governing permissions and
20 * limitations under the License. 20 * limitations under the License.
21 */ 21 */
22 22
23 #include "../../../../third_party/base/nonstd_unique_ptr.h"
23 #include "../barcode.h" 24 #include "../barcode.h"
24 #include "../BC_Writer.h" 25 #include "../BC_Writer.h"
25 #include "../common/BC_CommonBitMatrix.h" 26 #include "../common/BC_CommonBitMatrix.h"
26 #include "BC_OneDimWriter.h" 27 #include "BC_OneDimWriter.h"
27 CBC_OneDimWriter::CBC_OneDimWriter() { 28 CBC_OneDimWriter::CBC_OneDimWriter() {
28 m_locTextLoc = BC_TEXT_LOC_BELOWEMBED; 29 m_locTextLoc = BC_TEXT_LOC_BELOWEMBED;
29 m_bPrintChecksum = TRUE; 30 m_bPrintChecksum = TRUE;
30 m_iDataLenth = 0; 31 m_iDataLenth = 0;
31 m_bCalcChecksum = FALSE; 32 m_bCalcChecksum = FALSE;
32 m_pFont = NULL; 33 m_pFont = NULL;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 color ^= 1; 123 color ^= 1;
123 } 124 }
124 return numAdded; 125 return numAdded;
125 } 126 }
126 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, 127 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
127 FXTEXT_CHARPOS* charPos, 128 FXTEXT_CHARPOS* charPos,
128 CFX_Font* cFont, 129 CFX_Font* cFont,
129 FX_FLOAT geWidth, 130 FX_FLOAT geWidth,
130 int32_t fontSize, 131 int32_t fontSize,
131 FX_FLOAT& charsLen) { 132 FX_FLOAT& charsLen) {
132 #ifdef FXFM_ENCODING_NONE 133 nonstd::unique_ptr<CFX_UnicodeEncodingEx> encoding(
133 IFX_FontEncodingEx* encoding = FX_CreateFontEncodingEx(cFont); 134 FX_CreateFontEncodingEx(cFont));
134 #else 135
135 IFX_FontEncoding* encoding = FXGE_CreateUnicodeEncoding(cFont);
136 #endif
137 int32_t length = text.GetLength(); 136 int32_t length = text.GetLength();
138 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength()); 137 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength());
139 FX_FLOAT charWidth = 0; 138 FX_FLOAT charWidth = 0;
140 for (int32_t j = 0; j < text.GetLength(); j++) { 139 for (int32_t j = 0; j < text.GetLength(); j++) {
141 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); 140 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]);
142 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); 141 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]);
143 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); 142 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code);
144 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0); 143 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0);
145 charWidth += temp; 144 charWidth += temp;
146 } 145 }
(...skipping 20 matching lines...) Expand all
167 charPos[i].m_OriginY = penY + top; 166 charPos[i].m_OriginY = penY + top;
168 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); 167 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]);
169 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); 168 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex);
170 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 169 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
171 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex; 170 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex;
172 #endif 171 #endif
173 penX += 172 penX +=
174 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; 173 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
175 } 174 }
176 FX_Free(pCharCode); 175 FX_Free(pCharCode);
177 delete encoding;
178 encoding = NULL;
179 } 176 }
180 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, 177 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
181 const CFX_Matrix* matrix, 178 const CFX_Matrix* matrix,
182 const CFX_ByteString str, 179 const CFX_ByteString str,
183 FX_FLOAT geWidth, 180 FX_FLOAT geWidth,
184 FXTEXT_CHARPOS* pCharPos, 181 FXTEXT_CHARPOS* pCharPos,
185 FX_FLOAT locX, 182 FX_FLOAT locX,
186 FX_FLOAT locY, 183 FX_FLOAT locY,
187 int32_t barWidth) { 184 int32_t barWidth) {
188 int32_t iFontSize = (int32_t)fabs(m_fFontSize); 185 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) { 432 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) {
436 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); 433 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e);
437 break; 434 break;
438 } 435 }
439 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); 436 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e);
440 BC_EXCEPTION_CHECK_ReturnVoid(e); 437 BC_EXCEPTION_CHECK_ReturnVoid(e);
441 } 438 }
442 outputX += m_multiple; 439 outputX += m_multiple;
443 } 440 }
444 } 441 }
OLDNEW
« no previous file with comments | « xfa/src/fgas/src/font/fx_gefont.cpp ('k') | xfa/src/fxgraphics/src/fx_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698