summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/xetexdir/hz.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/xetexdir/hz.cpp')
-rw-r--r--Build/source/texk/web2c/xetexdir/hz.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/xetexdir/hz.cpp b/Build/source/texk/web2c/xetexdir/hz.cpp
new file mode 100644
index 00000000000..badbd5a6981
--- /dev/null
+++ b/Build/source/texk/web2c/xetexdir/hz.cpp
@@ -0,0 +1,51 @@
+#include "XeTeX_ext.h"
+
+#include <map>
+#include <iostream>
+#include <assert.h>
+using namespace std;
+
+typedef pair<int, unsigned int> GlyphId;
+typedef map<GlyphId, int> ProtrusionFactor;
+ProtrusionFactor leftProt, rightProt;
+
+extern "C" {
+
+void set_cp_code(int fontNum, unsigned int code, int side, int value)
+{
+ GlyphId id(fontNum, code);
+ switch (side) {
+ case LEFT_SIDE:
+ leftProt[id] = value;
+ break;
+ case RIGHT_SIDE:
+ rightProt[id] = value;
+ break;
+ default:
+ assert(0); // we should not reach here
+ }
+}
+
+int get_cp_code(int fontNum, unsigned int code, int side)
+{
+ GlyphId id(fontNum, code);
+ ProtrusionFactor* container;
+ switch (side) {
+ case LEFT_SIDE:
+ container = &leftProt;
+ break;
+ case RIGHT_SIDE:
+ container = &rightProt;
+ break;
+ default:
+ assert(0); // we should not reach here
+ }
+ ProtrusionFactor::iterator it = container->find(id);
+ if (it == container->end())
+ return 0;
+ return it->second;
+}
+
+}
+
+