kumarashishg | 826308d | 2023-06-23 13:21:22 +0000 | [diff] [blame] | 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 | #ifndef CORE_FXGE_WIN32_CFX_PSFONTTRACKER_H_ |
| 6 | #define CORE_FXGE_WIN32_CFX_PSFONTTRACKER_H_ |
| 7 | |
| 8 | #include <stdint.h> |
| 9 | |
| 10 | #include <functional> |
| 11 | #include <set> |
| 12 | |
| 13 | #include "core/fxcrt/unowned_ptr.h" |
| 14 | |
| 15 | class CFX_Font; |
| 16 | |
| 17 | class CFX_PSFontTracker { |
| 18 | public: |
| 19 | CFX_PSFontTracker(); |
| 20 | ~CFX_PSFontTracker(); |
| 21 | |
| 22 | void AddFontObject(const CFX_Font* font); |
| 23 | bool SeenFontObject(const CFX_Font* font) const; |
| 24 | |
| 25 | private: |
| 26 | // Tracks font objects via tags, so if two CFX_Font instances are for the same |
| 27 | // PDF object, then they are deduplicated. |
| 28 | std::set<uint64_t> seen_font_tags_; |
| 29 | |
| 30 | // For fonts without valid tags, e.g. ones created in-memory, track them by |
| 31 | // pointer. |
| 32 | std::set<UnownedPtr<const CFX_Font>, std::less<>> seen_font_ptrs_; |
| 33 | }; |
| 34 | |
| 35 | #endif // CORE_FXGE_WIN32_CFX_PSFONTTRACKER_H_ |