1 // Copyright 2021 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "core/fxge/win32/cfx_psfonttracker.h" 6 7 #include "core/fxge/cfx_font.h" 8 #include "third_party/base/check.h" 9 #include "third_party/base/containers/contains.h" 10 11 CFX_PSFontTracker::CFX_PSFontTracker() = default; 12 13 CFX_PSFontTracker::~CFX_PSFontTracker() = default; 14 AddFontObject(const CFX_Font * font)15void CFX_PSFontTracker::AddFontObject(const CFX_Font* font) { 16 uint64_t tag = font->GetObjectTag(); 17 [[maybe_unused]] bool inserted; 18 if (tag != 0) { 19 inserted = seen_font_tags_.insert(tag).second; 20 } else { 21 inserted = seen_font_ptrs_.insert(UnownedPtr<const CFX_Font>(font)).second; 22 } 23 DCHECK(inserted); 24 } 25 SeenFontObject(const CFX_Font * font) const26bool CFX_PSFontTracker::SeenFontObject(const CFX_Font* font) const { 27 uint64_t tag = font->GetObjectTag(); 28 if (tag != 0) 29 return pdfium::Contains(seen_font_tags_, tag); 30 return pdfium::Contains(seen_font_ptrs_, font); 31 } 32