[Interest] QSvgRenderer has a strange coordinate system

John Weeks john at wavemetrics.com
Wed Mar 11 22:02:17 CET 2015


Sizing in QSvgRenderer class is set by the function convertToPixels() in qsvghandler.cpp, which I have pasted below. That function always converts to units of 1/90 inch.

I wonder why; it seems from the name that it should be converting to screen resolution, or whatever the resolution is of the paint device it renders to. This not only affects the internal coordinate system, it affects the size of the image returned by QSvgRenderer::defaultSize(), where the coordinates are perversely not documented.

Does anyone know why this is? It seems like a bug to me.

-John Weeks


-------------------------------
 static qreal convertToPixels(qreal len, bool , QSvgHandler::LengthType type)
{

    switch (type) {
    case QSvgHandler::LT_PERCENT:
        break;
    case QSvgHandler::LT_PX:
        break;
    case QSvgHandler::LT_PC:
        break;
    case QSvgHandler::LT_PT:
        return len * 1.25;
        break;
    case QSvgHandler::LT_MM:
        return len * 3.543307;
        break;
    case QSvgHandler::LT_CM:
        return len * 35.43307;
        break;
    case QSvgHandler::LT_IN:
        return len * 90;
        break;
    case QSvgHandler::LT_OTHER:
        break;
    default:
        break;
    }
    return len;
}
----------------------------------


More information about the Interest mailing list