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

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

Issue 2395883002: Use another vector for installed fonts in CFX_FontMapper (Closed)
Patch Set: Nits Created 4 years, 2 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/fxge/cfx_fontmapper.h ('k') | core/fxge/win32/fx_win32_device.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fxge/cfx_fontmapper.h" 7 #include "core/fxge/cfx_fontmapper.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 void* hFont = m_pFontInfo->GetFont(name.c_str()); 340 void* hFont = m_pFontInfo->GetFont(name.c_str());
341 if (!hFont) { 341 if (!hFont) {
342 int iExact; 342 int iExact;
343 hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, 343 hFont = m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0,
344 name.c_str(), iExact); 344 name.c_str(), iExact);
345 if (!hFont) 345 if (!hFont)
346 return; 346 return;
347 } 347 }
348 348
349 CFX_ByteString new_name = GetPSNameFromTT(hFont); 349 CFX_ByteString new_name = GetPSNameFromTT(hFont);
350 if (!new_name.IsEmpty()) { 350 if (!new_name.IsEmpty())
351 new_name.Insert(0, ' '); 351 m_LocalizedTTFonts.push_back(std::make_pair(new_name, name));
352 m_InstalledTTFonts.push_back(new_name);
353 }
354 m_pFontInfo->DeleteFont(hFont); 352 m_pFontInfo->DeleteFont(hFont);
355 } 353 }
356 m_InstalledTTFonts.push_back(name); 354 m_InstalledTTFonts.push_back(name);
357 m_LastFamily = name; 355 m_LastFamily = name;
358 } 356 }
359 357
360 void CFX_FontMapper::LoadInstalledFonts() { 358 void CFX_FontMapper::LoadInstalledFonts() {
361 if (!m_pFontInfo || m_bListLoaded) 359 if (!m_pFontInfo || m_bListLoaded)
362 return; 360 return;
363 361
364 m_pFontInfo->EnumFontList(this); 362 m_pFontInfo->EnumFontList(this);
365 m_bListLoaded = TRUE; 363 m_bListLoaded = TRUE;
366 } 364 }
367 365
368 CFX_ByteString CFX_FontMapper::MatchInstalledFonts( 366 CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
369 const CFX_ByteString& norm_name) { 367 const CFX_ByteString& norm_name) {
370 LoadInstalledFonts(); 368 LoadInstalledFonts();
371 int i; 369 int i;
372 for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) { 370 for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
373 CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str()); 371 CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
374 if (norm1 == norm_name) 372 if (norm1 == norm_name)
375 break; 373 return m_InstalledTTFonts[i];
376 } 374 }
377 if (i < 0) 375 for (i = pdfium::CollectionSize<int>(m_LocalizedTTFonts) - 1; i >= 0; i--) {
378 return CFX_ByteString(); 376 CFX_ByteString norm1 =
379 CFX_ByteString match = m_InstalledTTFonts[i]; 377 TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str());
380 if (match[0] == ' ') 378 if (norm1 == norm_name)
381 match = m_InstalledTTFonts[i + 1]; 379 return m_LocalizedTTFonts[i].second;
382 return match; 380 }
381 return CFX_ByteString();
383 } 382 }
384 383
385 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, 384 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
386 int iBaseFont, 385 int iBaseFont,
387 int italic_angle, 386 int italic_angle,
388 int weight, 387 int weight,
389 int picthfamily) { 388 int picthfamily) {
390 if (iBaseFont < kExternalFontIndex) { 389 if (iBaseFont < kExternalFontIndex) {
391 if (m_FoxitFaces[iBaseFont]) 390 if (m_FoxitFaces[iBaseFont])
392 return m_FoxitFaces[iBaseFont]; 391 return m_FoxitFaces[iBaseFont];
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 int PDF_GetStandardFontName(CFX_ByteString* name) { 824 int PDF_GetStandardFontName(CFX_ByteString* name) {
826 AltFontName* found = static_cast<AltFontName*>( 825 AltFontName* found = static_cast<AltFontName*>(
827 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 826 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
828 sizeof(AltFontName), CompareString)); 827 sizeof(AltFontName), CompareString));
829 if (!found) 828 if (!found)
830 return -1; 829 return -1;
831 830
832 *name = g_Base14FontNames[found->m_Index]; 831 *name = g_Base14FontNames[found->m_Index];
833 return found->m_Index; 832 return found->m_Index;
834 } 833 }
OLDNEW
« no previous file with comments | « core/fxge/cfx_fontmapper.h ('k') | core/fxge/win32/fx_win32_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698