diff options
author | Norbert Preining <norbert@preining.info> | 2020-12-01 03:01:08 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-12-01 03:01:08 +0000 |
commit | 13dc4c947f3b419fc1b2ed24f10d69c841b0a37b (patch) | |
tree | b70e11ae7d2e2d77221ef406a555d4f7e52fbaf7 /dviware/dvisvgm/src/CMap.cpp | |
parent | cb68d38823870fa7adb5f0c2b68cf59205dd4bec (diff) |
CTAN sync 202012010301
Diffstat (limited to 'dviware/dvisvgm/src/CMap.cpp')
-rw-r--r-- | dviware/dvisvgm/src/CMap.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dviware/dvisvgm/src/CMap.cpp b/dviware/dvisvgm/src/CMap.cpp index 747fb5ad50..193def52fd 100644 --- a/dviware/dvisvgm/src/CMap.cpp +++ b/dviware/dvisvgm/src/CMap.cpp @@ -23,6 +23,7 @@ #include "CMap.hpp" #include "CMapManager.hpp" #include "FileFinder.hpp" +#include "Unicode.hpp" using namespace std; @@ -38,6 +39,22 @@ const FontEncoding* CMap::findCompatibleBaseFontMap (const PhysicalFont *font, C ////////////////////////////////////////////////////////////////////// +void SegmentedCMap::addCIDRange (uint32_t first, uint32_t last, uint32_t cid) { + if (uint32_t cp = Unicode::fromSurrogate(first)) // is 'first' a surrogate? + first = cp; + if (uint32_t cp = Unicode::fromSurrogate(last)) // is 'last' a surrogate? + last = cp; + _cidranges.addRange(first, last, cid); +} + + +void SegmentedCMap::addBFRange (uint32_t first, uint32_t last, uint32_t chrcode) { + if (uint32_t cp = Unicode::fromSurrogate(chrcode)) // is 'chrcode' a surrogate? + chrcode = cp; + _bfranges.addRange(first, last, chrcode); +} + + /** Returns the RO (Registry-Ordering) string of the CMap. */ string SegmentedCMap::getROString() const { if (_registry.empty() || _ordering.empty()) @@ -46,6 +63,17 @@ string SegmentedCMap::getROString() const { } +bool SegmentedCMap::mapsToUnicode () const { + vector<string> encstrings = {"UTF8", "UTF16", "UCS2", "UCS4", "UCS32"}; + for (const string &encstr : encstrings) { + size_t pos = _filename.find(encstr); + if (pos != string::npos && (pos == 0 || _filename[pos-1] == '-')) + return true; + } + return false; +} + + /** Returns the CID for a given character code. */ uint32_t SegmentedCMap::cid (uint32_t c) const { if (_cidranges.valueExists(c)) |