Files
pdf/engine/src/fonts/pdf_fonts/font_extraction_service.hpp
T
2026-08-06 14:58:44 +05:30

38 lines
963 B
C++

#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
#include <memory>
#include <mutex>
#include <optional>
#include <expected>
#include "font_extraction_types.hpp"
#include <pdfengine/pdf_document.hpp>
namespace pdfengine::fonts::pdf_fonts {
class FontExtractionService {
public:
static FontExtractionService& getInstance() {
static FontExtractionService instance;
return instance;
}
std::expected<std::shared_ptr<EmbeddedFontProgram>, EngineError>
getFontProgram(const std::string& internalFontId,
const std::string& baseFontName,
const std::vector<uint8_t>& documentBuffer,
const std::vector<uint8_t>& pdfiumRawBytes);
private:
FontExtractionService() = default;
std::mutex cacheMutex_;
std::unordered_map<std::string, std::shared_ptr<EmbeddedFontProgram>> cache_;
};
} // namespace pdfengine::fonts::pdf_fonts