Commit 95726346 authored by Kristian Høgsberg's avatar Kristian Høgsberg
Browse files

2005-08-05 Kristian Høgsberg <krh@redhat.com>

        * poppler/TextOutputDev.cc (visitLine): Round selection
        coordinates in device space, so selection isn't fuzzy.

        * poppler/GfxState.cc:
        * poppler/GfxState.h: Add simple Matrix class.
parent 8d12fb2e
2005-08-05 Kristian Høgsberg <krh@redhat.com>
* poppler/TextOutputDev.cc (visitLine): Round selection
coordinates in device space, so selection isn't fuzzy.
* poppler/GfxState.cc:
* poppler/GfxState.h: Add simple Matrix class.
2005-08-05 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-page.cc:
* glib/poppler-page.h:
* poppler/TextOutputDev.cc:
......
......@@ -228,6 +228,10 @@ void CairoOutputDev::updateFont(GfxState *state) {
m11 *= state->getHorizScaling();
m12 *= state->getHorizScaling();
w = currentFont->getSubstitutionCorrection(state->getFont());
m12 *= w;
m22 *= w;
LOG(printf ("font matrix: %f %f %f %f\n", m11, m12, m21, m22));
font_face = currentFont->getFontFace();
......@@ -260,14 +264,14 @@ void CairoOutputDev::doPath(GfxState *state, GfxPath *path,
j = 1;
while (j < subpath->getNumPoints()) {
if (subpath->getCurve(j)) {
state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2);
state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3);
if (snapToGrid) {
x1 = round (x1); y1 = round (y1);
x2 = round (x2); y2 = round (y2);
x3 = round (x3); y3 = round (y3);
}
state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2);
state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3);
cairo_curve_to (cairo,
x1, y1,
x2, y2,
......
......@@ -28,6 +28,32 @@ static inline double clip01(double x) {
return (x < 0) ? 0 : ((x > 1) ? 1 : x);
}
GBool Matrix::invertTo(Matrix *other)
{
double det;
det = 1 / (m[0] * m[3] - m[1] * m[2]);
other->m[0] = m[3] * det;
other->m[1] = -m[1] * det;
other->m[2] = -m[2] * det;
other->m[3] = m[0] * det;
other->m[4] = (m[2] * m[5] - m[3] * m[4]) * det;
other->m[5] = (m[1] * m[4] - m[0] * m[5]) * det;
return gTrue;
}
void Matrix::transform(double x, double y, double *tx, double *ty)
{
double temp_x, temp_y;
temp_x = m[0] * x + m[2] * y + m[4];
temp_y = m[1] * x + m[3] * y + m[5];
*tx = temp_x;
*ty = temp_y;
}
//------------------------------------------------------------------------
static char *gfxColorSpaceModeNames[] = {
......
......@@ -22,6 +22,15 @@ class GfxFont;
class PDFRectangle;
class GfxShading;
class Matrix {
public:
double m[6];
GBool invertTo(Matrix *other);
void transform(double x, double y, double *tx, double *ty);
};
//------------------------------------------------------------------------
// GfxColor
//------------------------------------------------------------------------
......@@ -878,6 +887,7 @@ public:
// Accessors.
double *getCTM() { return ctm; }
void getCTM(Matrix *m) { memcpy (m->m, ctm, sizeof m->m); }
double getX1() { return px1; }
double getY1() { return py1; }
double getX2() { return px2; }
......
......@@ -3254,6 +3254,7 @@ void TextSelectionPainter::visitLine (TextLine *line,
{
double x1, y1, x2, y2, margin;
int i;
Matrix ctm, ictm;
state->setFillColor(box_color);
out->updateFillColor(state);
......@@ -3264,6 +3265,19 @@ void TextSelectionPainter::visitLine (TextLine *line,
x2 = ceil (line->edge[edge_end]);
y2 = ceil (line->yMax + margin);
state->getCTM (&ctm);
ctm.transform(line->edge[edge_begin], line->yMin - margin, &x1, &y1);
ctm.transform(line->edge[edge_end], line->yMax + margin, &x2, &y2);
x1 = floor (x1);
y1 = floor (y1);
x2 = ceil (x2);
y2 = ceil (y2);
ctm.invertTo (&ictm);
ictm.transform(x1, y1, &x1, &y1);
ictm.transform(x2, y2, &x2, &y2);
state->moveTo(x1, y1);
state->lineTo(x2, y1);
state->lineTo(x2, y2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment