Skip to content

Commit 94ead2b

Browse files
committed
tectonic/XeTeXLayoutInterface.cpp: merge contents of hz.cpp
The file hz.cpp was tiny and had a weird name, so I think it's nicer to just merge it into a bigger file. XeTeXLayoutInterface.cpp works.
1 parent e9ce276 commit 94ead2b

File tree

5 files changed

+56
-82
lines changed

5 files changed

+56
-82
lines changed

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ fn main() {
256256
cppcfg
257257
.cpp(true)
258258
.file("tectonic/Engine.cpp")
259-
.file("tectonic/hz.cpp")
260259
.file("tectonic/XeTeXFontInst.cpp")
261260
.file("tectonic/XeTeXFontMgr.cpp")
262261
.file("tectonic/XeTeXLayoutInterface.cpp")

tectonic/XeTeXLayoutInterface.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,60 @@ cacheGlyphBBox(uint16_t fontID, uint16_t glyphID, const GlyphBBox* bbox)
9797
uint32_t key = ((uint32_t)fontID << 16) + glyphID;
9898
sGlyphBoxes[key] = *bbox;
9999
}
100+
101+
/* The following code used to be in a file called "hz.cpp" and there's no
102+
* particular reason for it to be here, but it was a tiny file with a weird
103+
* name so I wanted to get rid of it. The functions are invoked from the C
104+
* code. */
105+
106+
typedef std::pair<int, unsigned int> GlyphId;
107+
typedef std::map<GlyphId, int> ProtrusionFactor;
108+
ProtrusionFactor leftProt, rightProt;
109+
110+
void
111+
set_cp_code(int fontNum, unsigned int code, int side, int value)
112+
{
113+
GlyphId id(fontNum, code);
114+
115+
switch (side) {
116+
case LEFT_SIDE:
117+
leftProt[id] = value;
118+
break;
119+
case RIGHT_SIDE:
120+
rightProt[id] = value;
121+
break;
122+
default:
123+
assert(0); // we should not reach here
124+
}
125+
}
126+
127+
128+
int
129+
get_cp_code(int fontNum, unsigned int code, int side)
130+
{
131+
GlyphId id(fontNum, code);
132+
ProtrusionFactor *container;
133+
134+
switch (side) {
135+
case LEFT_SIDE:
136+
container = &leftProt;
137+
break;
138+
case RIGHT_SIDE:
139+
container = &rightProt;
140+
break;
141+
default:
142+
assert(0); // we should not reach here
143+
}
144+
145+
ProtrusionFactor::iterator it = container->find(id);
146+
if (it == container->end())
147+
return 0;
148+
149+
return it->second;
150+
}
151+
152+
153+
100154
/*******************************************************************/
101155

102156
void

tectonic/XeTeX_ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ int find_pic_file(char** path, real_rect* bounds, int pdfBoxType, int page);
161161

162162
void terminate_font_manager(void);
163163
int maketexstring(const char* s);
164-
void set_cp_code(int fontNum, unsigned int code, int side, int value);
165-
int get_cp_code(int fontNum, unsigned int code, int side);
164+
extern void set_cp_code(int fontNum, unsigned int code, int side, int value);
165+
extern int get_cp_code(int fontNum, unsigned int code, int side);
166166
double Fix2D(Fixed f);
167167
Fixed D2Fix(double d);
168168

tectonic/XeTeX_web.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ extern void print_char(int c);
4646
extern void begin_diagnostic(void);
4747
extern void end_diagnostic(int nl);
4848
extern int get_tracing_fonts_state(void);
49-
extern void set_cp_code(int, unsigned int, int, int);
50-
extern int get_cp_code(int, unsigned int, int);
5149

5250
extern Fixed loaded_font_design_size;
5351
extern void **font_layout_engine;

tectonic/hz.cpp

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)