Comment 10 for bug 169048

Revision history for this message
Jan David Mol (jjdmol) wrote :

For me, the translation error is (at least) at CairoRenderer::setupDocument, in which the pixel size is rounded up to an integer before it is converted to points. This leads to exactly the difference I see in the point sizes of the source and target. The offending code:

    NRRect d;
    if (pageBoundingBox) {
        d.x0 = d.y0 = 0;
        d.x1 = ceil(sp_document_width(doc));
        d.y1 = ceil(sp_document_height(doc));
    } else {
        sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
    }

    if (ctx->_vector_based_target) {
        // convert from px to pt
        d.x0 *= PT_PER_PX;
        d.x1 *= PT_PER_PX;
        d.y0 *= PT_PER_PX;
        d.y1 *= PT_PER_PX;
    }

(PT_PER_PX is 1.0/1.25)

In gdb at the end of the above lines:

(gdb) print d
$4 = {x0 = 0, y0 = 0, x1 = 842.40000000000009, y1 = 596}

Manual calculations show the desired result without rounding errors:

(gdb) print sp_document_height(doc)
$5 = 744.094482421875
(gdb) print sp_document_width(doc)
$6 = 1052.3621826171875

(gdb) print sp_document_width(doc)/1.25
$10 = 841.88974609374998
(gdb) print sp_document_height(doc)/1.25
$11 = 595.27558593749995