38 lines
963 B
C++
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
|