summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/CMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dviware/dvisvgm/src/CMap.cpp')
-rw-r--r--dviware/dvisvgm/src/CMap.cpp28
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))