Browse Source

Fix for DPI of win32 fonts sizes when specified in points.

tags/2021-05-28
jules 12 years ago
parent
commit
ffb4572104
2 changed files with 4 additions and 2 deletions
  1. +2
    -1
      modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp
  2. +2
    -1
      modules/juce_graphics/native/juce_win32_Fonts.cpp

+ 2
- 1
modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp View File

@@ -178,7 +178,8 @@ public:
unitsToHeightScaleFactor = designUnitsPerEm / totalSize; unitsToHeightScaleFactor = designUnitsPerEm / totalSize;
HDC tempDC = GetDC (0); 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); ReleaseDC (0, tempDC);
const float pathAscent = (1024.0f * dwFontMetrics.ascent) / designUnitsPerEm; const float pathAscent = (1024.0f * dwFontMetrics.ascent) / designUnitsPerEm;


+ 2
- 1
modules/juce_graphics/native/juce_win32_Fonts.cpp View File

@@ -533,7 +533,8 @@ private:
if (GetTextMetrics (dc, &tm)) 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; ascent = tm.tmAscent / (float) tm.tmHeight;
defaultGlyph = getGlyphForChar (dc, tm.tmDefaultChar); defaultGlyph = getGlyphForChar (dc, tm.tmDefaultChar);
createKerningPairs (dc, (float) tm.tmHeight); createKerningPairs (dc, (float) tm.tmHeight);


Loading…
Cancel
Save