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

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

Issue 2395883002: Use another vector for installed fonts in CFX_FontMapper (Closed)
Patch Set: Fix win 2 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
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(new_name);
352 m_InstalledTTFonts.push_back(new_name); 352 m_IndexForLocalizedFonts.push_back(m_InstalledTTFonts.size());
353 } 353 }
354 m_pFontInfo->DeleteFont(hFont); 354 m_pFontInfo->DeleteFont(hFont);
355 } 355 }
356 m_InstalledTTFonts.push_back(name); 356 m_InstalledTTFonts.push_back(name);
357 m_LastFamily = name; 357 m_LastFamily = name;
358 } 358 }
359 359
360 void CFX_FontMapper::LoadInstalledFonts() { 360 void CFX_FontMapper::LoadInstalledFonts() {
361 if (!m_pFontInfo || m_bListLoaded) 361 if (!m_pFontInfo || m_bListLoaded)
362 return; 362 return;
363 363
364 m_pFontInfo->EnumFontList(this); 364 m_pFontInfo->EnumFontList(this);
365 m_bListLoaded = TRUE; 365 m_bListLoaded = TRUE;
366 } 366 }
367 367
368 CFX_ByteString CFX_FontMapper::MatchInstalledFonts( 368 CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
369 const CFX_ByteString& norm_name) { 369 const CFX_ByteString& norm_name) {
370 LoadInstalledFonts(); 370 LoadInstalledFonts();
371 int i; 371 int i;
372 for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) { 372 for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
373 CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str()); 373 CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
374 if (norm1 == norm_name) 374 if (norm1 == norm_name)
375 break; 375 break;
376 } 376 }
377 if (i < 0) 377 if (i >= 0)
378 return CFX_ByteString(); 378 return m_InstalledTTFonts[i];
379 CFX_ByteString match = m_InstalledTTFonts[i]; 379 for (i = pdfium::CollectionSize<int>(m_LocalizedTTFonts) - 1; i >= 0; i--) {
380 if (match[0] == ' ') 380 CFX_ByteString norm1 = TT_NormalizeName(m_LocalizedTTFonts[i].c_str());
381 match = m_InstalledTTFonts[i + 1]; 381 if (norm1 == norm_name)
382 return match; 382 break;
383 }
384 if (i >= 0)
385 return m_InstalledTTFonts[m_IndexForLocalizedFonts[i]];
386 return CFX_ByteString();
383 } 387 }
384 388
385 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, 389 FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,
386 int iBaseFont, 390 int iBaseFont,
387 int italic_angle, 391 int italic_angle,
388 int weight, 392 int weight,
389 int picthfamily) { 393 int picthfamily) {
390 if (iBaseFont < kExternalFontIndex) { 394 if (iBaseFont < kExternalFontIndex) {
391 if (m_FoxitFaces[iBaseFont]) 395 if (m_FoxitFaces[iBaseFont])
392 return m_FoxitFaces[iBaseFont]; 396 return m_FoxitFaces[iBaseFont];
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 int PDF_GetStandardFontName(CFX_ByteString* name) { 829 int PDF_GetStandardFontName(CFX_ByteString* name) {
826 AltFontName* found = static_cast<AltFontName*>( 830 AltFontName* found = static_cast<AltFontName*>(
827 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames), 831 FXSYS_bsearch(name->c_str(), g_AltFontNames, FX_ArraySize(g_AltFontNames),
828 sizeof(AltFontName), CompareString)); 832 sizeof(AltFontName), CompareString));
829 if (!found) 833 if (!found)
830 return -1; 834 return -1;
831 835
832 *name = g_Base14FontNames[found->m_Index]; 836 *name = g_Base14FontNames[found->m_Index];
833 return found->m_Index; 837 return found->m_Index;
834 } 838 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698