Add static GetLogFontHeightAtPPI() overload taking point size

This will be useful elsewhere too and makes SetFractionalPointSize()
implementation less fragile as we don't have to be careful about
changing pointSize member before setting lf.lfHeight any more.
This commit is contained in:
Vadim Zeitlin
2018-12-30 23:53:25 +01:00
parent 72a225924d
commit de6d7472a2
2 changed files with 15 additions and 23 deletions

View File

@@ -122,7 +122,16 @@ public:
// MSW-specific: get the height value in pixels using LOGFONT convention
// (i.e. negative) corresponding to the given size in points and DPI.
int GetLogFontHeightAtPPI(int ppi) const;
static int GetLogFontHeightAtPPI(float size, int ppi)
{
return -wxRound(size * ppi / 72.0);
}
// And the same thing for the size of this font.
int GetLogFontHeightAtPPI(int ppi) const
{
return GetLogFontHeightAtPPI(pointSize, ppi);
}
LOGFONT lf;