forked from coolwanglu/pdf2htmlEX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextLineBuffer.h
More file actions
90 lines (71 loc) · 2.01 KB
/
Copy pathTextLineBuffer.h
File metadata and controls
90 lines (71 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef TEXTLINEBUFFER_H__
#define TEXTLINEBUFFER_H__
#include <iostream>
#include <vector>
namespace pdf2htmlEX {
/*
* Store a series of
* - Text
* - Shift
* - State change
* within a line
*/
class HTMLRenderer;
class HTMLRenderer::TextLineBuffer
{
public:
TextLineBuffer (HTMLRenderer * renderer) : renderer(renderer) { }
class State {
public:
// before output
void begin(std::ostream & out, const State * prev_state);
// after output
void end(std::ostream & out) const;
// calculate the hash code
void hash(void);
// calculate the difference between another State
int diff(const State & s) const;
enum {
FONT_ID,
FONT_SIZE_ID,
FILL_COLOR_ID,
STROKE_COLOR_ID,
LETTER_SPACE_ID,
WORD_SPACE_ID,
RISE_ID,
ID_COUNT
};
long long ids[ID_COUNT];
double ascent;
double descent;
double draw_font_size;
size_t start_idx; // index of the first Text using this state
// for optimzation
long long hash_value;
bool need_close;
static const char * format_str; // class names for each id
};
class Offset {
public:
size_t start_idx; // should put this Offset right before text[start_idx];
double width;
};
void reset(GfxState * state);
void append_unicodes(const Unicode * u, int l);
void append_offset(double width);
void append_state(void);
void flush(void);
private:
// retrieve state from renderer
void set_state(State & state);
HTMLRenderer * renderer;
double x, y;
long long tm_id;
std::vector<State> states;
std::vector<Offset> offsets;
std::vector<Unicode> text;
// for flush
std::vector<State*> stack;
};
} // namespace pdf2htmlEX
#endif //TEXTLINEBUFFER_H__