|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GLOBALPARAMS_H |
|
#define GLOBALPARAMS_H |
|
|
|
#include <cassert> |
|
#include "poppler-config.h" |
|
#include "poppler_private_export.h" |
|
#include <cstdio> |
|
#include "CharTypes.h" |
|
#include "UnicodeMap.h" |
|
#include "Error.h" |
|
#include <unordered_map> |
|
#include <string> |
|
#include <memory> |
|
#include <mutex> |
|
#include <vector> |
|
|
|
class GooString; |
|
class NameToCharCode; |
|
class CharCodeToUnicode; |
|
class CharCodeToUnicodeCache; |
|
class UnicodeMapCache; |
|
class CMap; |
|
class CMapCache; |
|
class GlobalParams; |
|
class GfxFont; |
|
class Stream; |
|
class SysFontList; |
|
|
|
|
|
|
|
|
|
#ifdef _COMPILING_POPPLER |
|
|
|
|
|
extern __declspec(dllexport) std::unique_ptr<GlobalParams> globalParams; |
|
#else |
|
extern __declspec(dllimport) std::unique_ptr<GlobalParams> globalParams; |
|
#endif |
|
|
|
|
|
|
|
|
|
enum SysFontType |
|
{ |
|
sysFontPFA, |
|
sysFontPFB, |
|
sysFontTTF, |
|
sysFontTTC |
|
}; |
|
|
|
|
|
|
|
struct FamilyStyleFontSearchResult |
|
{ |
|
FamilyStyleFontSearchResult() = default; |
|
|
|
FamilyStyleFontSearchResult(const std::string &filepathA, int faceIndexA) : filepath(filepathA), faceIndex(faceIndexA) { } |
|
|
|
std::string filepath; |
|
int faceIndex = 0; |
|
}; |
|
|
|
|
|
|
|
struct UCharFontSearchResult |
|
{ |
|
UCharFontSearchResult() = default; |
|
|
|
UCharFontSearchResult(const std::string &filepathA, int faceIndexA, const std::string &familyA, const std::string &styleA) : filepath(filepathA), faceIndex(faceIndexA), family(familyA), style(styleA) { } |
|
|
|
const std::string filepath; |
|
const int faceIndex = 0; |
|
const std::string family; |
|
const std::string style; |
|
}; |
|
|
|
|
|
|
|
class POPPLER_PRIVATE_EXPORT GlobalParams |
|
{ |
|
public: |
|
|
|
explicit GlobalParams(const char *customPopplerDataDir = nullptr); |
|
|
|
~GlobalParams(); |
|
|
|
GlobalParams(const GlobalParams &) = delete; |
|
GlobalParams &operator=(const GlobalParams &) = delete; |
|
|
|
void setupBaseFonts(const char *dir); |
|
|
|
|
|
|
|
CharCode getMacRomanCharCode(const char *charName); |
|
|
|
|
|
|
|
Unicode mapNameToUnicodeText(const char *charName); |
|
|
|
|
|
|
|
Unicode mapNameToUnicodeAll(const char *charName); |
|
|
|
UnicodeMap *getResidentUnicodeMap(const std::string &encodingName); |
|
FILE *getUnicodeMapFile(const std::string &encodingName); |
|
FILE *findCMapFile(const GooString *collection, const GooString *cMapName); |
|
FILE *findToUnicodeFile(const GooString *name); |
|
GooString *findFontFile(const std::string &fontName); |
|
GooString *findBase14FontFile(const GooString *base14Name, const GfxFont *font, GooString *substituteFontName = nullptr); |
|
GooString *findSystemFontFile(const GfxFont *font, SysFontType *type, int *fontNum, GooString *substituteFontName = nullptr, const GooString *base14Name = nullptr); |
|
FamilyStyleFontSearchResult findSystemFontFileForFamilyAndStyle(const std::string &fontFamily, const std::string &fontStyle, const std::vector<std::string> &filesToIgnore = {}); |
|
UCharFontSearchResult findSystemFontFileForUChar(Unicode uChar, const GfxFont &fontToEmulate); |
|
std::string getTextEncodingName() const; |
|
bool getPrintCommands(); |
|
bool getProfileCommands(); |
|
bool getErrQuiet(); |
|
|
|
CharCodeToUnicode *getCIDToUnicode(const GooString *collection); |
|
const UnicodeMap *getUnicodeMap(const std::string &encodingName); |
|
std::shared_ptr<CMap> getCMap(const GooString *collection, const GooString *cMapName); |
|
const UnicodeMap *getTextEncoding(); |
|
|
|
const UnicodeMap *getUtf8Map(); |
|
|
|
std::vector<std::string> getEncodingNames(); |
|
|
|
|
|
void addFontFile(const std::string &fontName, const std::string &path); |
|
void setTextEncoding(const char *encodingName); |
|
void setPrintCommands(bool printCommandsA); |
|
void setProfileCommands(bool profileCommandsA); |
|
void setErrQuiet(bool errQuietA); |
|
#ifdef ANDROID |
|
static void setFontDir(const std::string &fontDir); |
|
#endif |
|
static bool parseYesNo2(const char *token, bool *flag); |
|
|
|
private: |
|
void parseNameToUnicode(const GooString *name); |
|
|
|
void scanEncodingDirs(); |
|
void addCIDToUnicode(const GooString *collection, const GooString *fileName); |
|
void addUnicodeMap(const GooString *encodingName, const GooString *fileName); |
|
void addCMapDir(const GooString *collection, const GooString *dir); |
|
|
|
|
|
|
|
NameToCharCode * |
|
macRomanReverseMap; |
|
|
|
|
|
|
|
NameToCharCode * |
|
nameToUnicodeZapfDingbats; |
|
NameToCharCode * |
|
nameToUnicodeText; |
|
|
|
|
|
std::unordered_map<std::string, std::string> cidToUnicodes; |
|
|
|
|
|
std::unordered_map<std::string, UnicodeMap> residentUnicodeMaps; |
|
|
|
|
|
std::unordered_map<std::string, std::string> unicodeMaps; |
|
|
|
std::unordered_multimap<std::string, std::string> cMapDirs; |
|
std::vector<GooString *> toUnicodeDirs; |
|
bool baseFontsInitialized; |
|
#ifdef _WIN32 |
|
|
|
std::unordered_map<std::string, std::string> substFiles; |
|
#endif |
|
|
|
std::unordered_map<std::string, std::string> fontFiles; |
|
SysFontList *sysFonts; |
|
GooString *textEncoding; |
|
|
|
bool printCommands; |
|
bool profileCommands; |
|
bool errQuiet; |
|
|
|
CharCodeToUnicodeCache *cidToUnicodeCache; |
|
CharCodeToUnicodeCache *unicodeToUnicodeCache; |
|
UnicodeMapCache *unicodeMapCache; |
|
CMapCache *cMapCache; |
|
|
|
const UnicodeMap *utf8Map; |
|
|
|
mutable std::recursive_mutex mutex; |
|
mutable std::recursive_mutex unicodeMapCacheMutex; |
|
mutable std::recursive_mutex cMapCacheMutex; |
|
|
|
const char *popplerDataDir; |
|
}; |
|
|
|
class POPPLER_PRIVATE_EXPORT GlobalParamsIniter |
|
{ |
|
public: |
|
explicit GlobalParamsIniter(ErrorCallback errorCallback); |
|
~GlobalParamsIniter(); |
|
|
|
GlobalParamsIniter(const GlobalParamsIniter &) = delete; |
|
GlobalParamsIniter &operator=(const GlobalParamsIniter &) = delete; |
|
|
|
static bool setCustomDataDir(const std::string &dir); |
|
|
|
private: |
|
static std::mutex mutex; |
|
static int count; |
|
|
|
static std::string customDataDir; |
|
}; |
|
|
|
#endif |
|
|