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

Side by Side Diff: core/fxge/ge/fx_ge_fontmap.cpp

Issue 1977093002: Make CFX_ByteString(const CFX_ByteStringC&) explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, nit Created 4 years, 7 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 | « core/fxcrt/include/fx_xml.h ('k') | core/fxge/ge/fx_ge_text.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 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 AltFontFamily* found = (AltFontFamily*)FXSYS_bsearch( 310 AltFontFamily* found = (AltFontFamily*)FXSYS_bsearch(
311 fontName.c_str(), g_AltFontFamilies, 311 fontName.c_str(), g_AltFontFamilies,
312 sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily), 312 sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily),
313 CompareFontFamilyString); 313 CompareFontFamilyString);
314 return found ? CFX_ByteString(found->m_pFontFamily) : fontName; 314 return found ? CFX_ByteString(found->m_pFontFamily) : fontName;
315 } 315 }
316 316
317 CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { 317 CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
318 CFX_ByteTextBuf buf; 318 CFX_ByteTextBuf buf;
319 if (!iLen || iLen <= iIndex) { 319 if (!iLen || iLen <= iIndex) {
320 return buf.AsStringC(); 320 return buf.MakeString();
321 } 321 }
322 while (iIndex < iLen) { 322 while (iIndex < iLen) {
323 if (pStyle[iIndex] == ',') { 323 if (pStyle[iIndex] == ',') {
324 break; 324 break;
325 } 325 }
326 buf.AppendChar(pStyle[iIndex]); 326 buf.AppendChar(pStyle[iIndex]);
327 ++iIndex; 327 ++iIndex;
328 } 328 }
329 return buf.AsStringC(); 329 return buf.MakeString();
330 } 330 }
331 331
332 int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { 332 int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) {
333 int32_t iLen = bsStyle.GetLength(); 333 int32_t iLen = bsStyle.GetLength();
334 if (!iLen) { 334 if (!iLen) {
335 return -1; 335 return -1;
336 } 336 }
337 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); 337 int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle);
338 const FX_FontStyle* pStyle = NULL; 338 const FX_FontStyle* pStyle = NULL;
339 for (int i = iSize - 1; i >= 0; --i) { 339 for (int i = iSize - 1; i >= 0; --i) {
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 m_pFontInfo = pFontInfo; 681 m_pFontInfo = pFontInfo;
682 } 682 }
683 683
684 static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, 684 static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr,
685 uint32_t string_ptr_length, 685 uint32_t string_ptr_length,
686 uint16_t offset, 686 uint16_t offset,
687 uint16_t length) { 687 uint16_t length) {
688 if (string_ptr_length < static_cast<uint32_t>(offset + length)) { 688 if (string_ptr_length < static_cast<uint32_t>(offset + length)) {
689 return CFX_ByteString(); 689 return CFX_ByteString();
690 } 690 }
691 return CFX_ByteStringC(string_ptr + offset, length); 691 return CFX_ByteString(string_ptr + offset, length);
692 } 692 }
693 693
694 CFX_ByteString GetNameFromTT(const uint8_t* name_table, 694 CFX_ByteString GetNameFromTT(const uint8_t* name_table,
695 uint32_t name_table_size, 695 uint32_t name_table_size,
696 uint32_t name_id) { 696 uint32_t name_id) {
697 if (!name_table || name_table_size < 6) { 697 if (!name_table || name_table_size < 6) {
698 return CFX_ByteString(); 698 return CFX_ByteString();
699 } 699 }
700 uint32_t name_count = GET_TT_SHORT(name_table + 2); 700 uint32_t name_count = GET_TT_SHORT(name_table + 2);
701 uint32_t string_offset = GET_TT_SHORT(name_table + 4); 701 uint32_t string_offset = GET_TT_SHORT(name_table + 4);
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 return NULL; 1361 return NULL;
1362 } 1362 }
1363 #endif 1363 #endif
1364 1364
1365 CFX_FolderFontInfo::CFX_FolderFontInfo() {} 1365 CFX_FolderFontInfo::CFX_FolderFontInfo() {}
1366 CFX_FolderFontInfo::~CFX_FolderFontInfo() { 1366 CFX_FolderFontInfo::~CFX_FolderFontInfo() {
1367 for (const auto& pair : m_FontList) { 1367 for (const auto& pair : m_FontList) {
1368 delete pair.second; 1368 delete pair.second;
1369 } 1369 }
1370 } 1370 }
1371
1371 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { 1372 void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) {
1372 m_PathList.push_back(path); 1373 m_PathList.push_back(CFX_ByteString(path));
1373 } 1374 }
1375
1374 void CFX_FolderFontInfo::Release() { 1376 void CFX_FolderFontInfo::Release() {
1375 delete this; 1377 delete this;
1376 } 1378 }
1379
1377 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { 1380 FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
1378 m_pMapper = pMapper; 1381 m_pMapper = pMapper;
1379 for (const auto& path : m_PathList) 1382 for (const auto& path : m_PathList)
1380 ScanPath(path); 1383 ScanPath(path);
1381 return TRUE; 1384 return TRUE;
1382 } 1385 }
1383 void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) { 1386 void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
1384 void* handle = FX_OpenFolder(path.c_str()); 1387 void* handle = FX_OpenFolder(path.c_str());
1385 if (!handle) 1388 if (!handle)
1386 return; 1389 return;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 int PDF_GetStandardFontName(CFX_ByteString* name) { 1647 int PDF_GetStandardFontName(CFX_ByteString* name) {
1645 AltFontName* found = static_cast<AltFontName*>( 1648 AltFontName* found = static_cast<AltFontName*>(
1646 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 1649 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
1647 sizeof(AltFontName), CompareString)); 1650 sizeof(AltFontName), CompareString));
1648 if (!found) 1651 if (!found)
1649 return -1; 1652 return -1;
1650 1653
1651 *name = g_Base14FontNames[found->m_Index]; 1654 *name = g_Base14FontNames[found->m_Index];
1652 return found->m_Index; 1655 return found->m_Index;
1653 } 1656 }
OLDNEW
« no previous file with comments | « core/fxcrt/include/fx_xml.h ('k') | core/fxge/ge/fx_ge_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698