Fix printing with OS X platform plugin
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Tue, 4 Sep 2012 11:54:07 +0000 (13:54 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 10 Sep 2012 12:09:45 +0000 (14:09 +0200)
commitb625ff4c7b68505b6d299d688734c9c1d448cb80
treeaef733892e8fa7c811db277e137c286f5b3592f7
parent7f8ca0fc4c29deee5eed5697ed4999b9a86f44c1
Fix printing with OS X platform plugin

Since we do not pass in the destination dpi to CoreText when making
the font, we need to pass in a point size which is scaled to include
the dpi change. The default dpi for the screen is 72, thus the
scale factor is destinationDpi/72. Since pixelSize = pointSize / 72 * dpi,
the pixelSize is actually the scaled point size for the destination
dpi, thus we pass in that instead.

Note that this only works because the default screen dpi on Mac is 72.
You can look at the CoreText font database in Qt 4.8 to verify that the
same trick is used there.

When 96 dpi is explicitly set (specifically for autotests), we need to
fall back to the old behavior, since the OSX platform plugin will then
use 72 for some fonts and 96 for others making it impossible to detect
the DPI in a consistent way. The correct fix would be to pass in the
dpi to the function, but until that fix can be made, we just use the
old code to keep the autotests passing.

Task-number: QTBUG-25555
Change-Id: Id20a273549c3abf3db56ef1c48553c0958c48d61
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm