-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplashMod.h
61 lines (55 loc) · 2.09 KB
/
SplashMod.h
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
#ifndef SPLASH_OUTPUT_DEV_MOD
#define SPLASH_OUTPUT_DEV_MOD
#include <splash/SplashFont.h>
#include <splash/SplashGlyphBitmap.h>
#include <splash/Splash.h>
#include <splash/SplashMath.h>
void notifyDraw(int c, int x, int y, int w, int h, int fx, int fy);
class SplashOutputDev_mod: public SplashOutputDev {
public:
virtual ~SplashOutputDev_mod(){}
// Constructor.
SplashOutputDev_mod(SplashColorMode colorModeA, int bitmapRowPadA,
bool reverseVideoA, SplashColorPtr paperColorA,
bool bitmapTopDownA = true)
:SplashOutputDev(colorModeA, bitmapRowPadA, reverseVideoA, paperColorA,
bitmapTopDownA){}
// Transform a point from user space to device space.
inline void transform(SplashCoord *matrix,
SplashCoord xi, SplashCoord yi,
SplashCoord *xo, SplashCoord *yo) {
// [ m[0] m[1] 0 ]
// [xo yo 1] = [xi yi 1] * [ m[2] m[3] 0 ]
// [ m[4] m[5] 1 ]
*xo = xi * matrix[0] + yi * matrix[2] + matrix[4];
*yo = xi * matrix[1] + yi * matrix[3] + matrix[5];
}
void fillChar(SplashCoord*matrix, SplashCoord x, SplashCoord y,
int c, SplashFont *font) {
SplashGlyphBitmap glyph;
SplashCoord xt, yt;
int x0, y0, xFrac, yFrac;
SplashClipResult clipRes;
transform(matrix, x, y, &xt, &yt);
x0 = splashFloor(xt);
xFrac = splashFloor((xt - x0) * splashFontFraction);
y0 = splashFloor(yt);
yFrac = splashFloor((yt - y0) * splashFontFraction);
if (font->getGlyph(c, xFrac, yFrac, &glyph, x0, y0, getSplash()->getClip(), &clipRes)) {
notifyDraw(c, x0, y0, glyph.w, glyph.h, glyph.x, glyph.y);
}
}
void drawChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
CharCode code, int nBytes,
Unicode *u, int uLen) {
SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes,u,uLen);
SplashFont* font=getCurrentFont();
if(state->getRender()!=3 && font && !state->getFillColorSpace()->isNonMarking())
{
fillChar(getSplash()->getMatrix(), (SplashCoord)(x-originX), (SplashCoord)(y-originY), code, font);
}
}
};
#endif