From ffb4572104b2a166649430302ab0010c89e09ede Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 23 Dec 2013 11:59:35 +0000 Subject: [PATCH] Fix for DPI of win32 fonts sizes when specified in points. --- .../juce_graphics/native/juce_win32_DirectWriteTypeface.cpp | 3 ++- modules/juce_graphics/native/juce_win32_Fonts.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp index 3d92634479..3f42e7c5d5 100644 --- a/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp +++ b/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp @@ -178,7 +178,8 @@ public: unitsToHeightScaleFactor = designUnitsPerEm / totalSize; HDC tempDC = GetDC (0); - heightToPointsFactor = (72.0f / GetDeviceCaps (tempDC, LOGPIXELSY)) * unitsToHeightScaleFactor; + float dpi = (GetDeviceCaps (tempDC, LOGPIXELSX) + GetDeviceCaps (tempDC, LOGPIXELSY)) / 2.0f; + heightToPointsFactor = (dpi / GetDeviceCaps (tempDC, LOGPIXELSY)) * unitsToHeightScaleFactor; ReleaseDC (0, tempDC); const float pathAscent = (1024.0f * dwFontMetrics.ascent) / designUnitsPerEm; diff --git a/modules/juce_graphics/native/juce_win32_Fonts.cpp b/modules/juce_graphics/native/juce_win32_Fonts.cpp index 59a6032758..ce8a6a8214 100644 --- a/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -533,7 +533,8 @@ private: if (GetTextMetrics (dc, &tm)) { - heightToPointsFactor = (72.0f / GetDeviceCaps (dc, LOGPIXELSY)) * heightInPoints / (float) tm.tmHeight; + float dpi = (GetDeviceCaps (dc, LOGPIXELSX) + GetDeviceCaps (dc, LOGPIXELSY)) / 2.0f; + heightToPointsFactor = (dpi / GetDeviceCaps (dc, LOGPIXELSY)) * heightInPoints / (float) tm.tmHeight; ascent = tm.tmAscent / (float) tm.tmHeight; defaultGlyph = getGlyphForChar (dc, tm.tmDefaultChar); createKerningPairs (dc, (float) tm.tmHeight);