def _adjustPixelSize(wldWidth, wldHeight, pixWidth, pixHeight):
    """Used by :func:`calcPixelWidth` and :func:`calcPixelHeight`.

    Potentially reduces the given pixel width/height such that the
    display space aspect ratio is maintained.
    """
    if any((pixWidth == 0, pixHeight == 0, wldWidth == 0, wldHeight == 0)):
        return 0, 0
    pixRatio = float(pixWidth) / pixHeight
    wldRatio = float(wldWidth) / wldHeight
    if pixRatio > wldRatio:
        pixWidth = wldWidth * (pixHeight / wldHeight)
    elif pixRatio < wldRatio:
        pixHeight = wldHeight * (pixWidth / wldWidth)
    return pixWidth, pixHeight
