title: How can you calculate the appropriate Font Size if the deployment PC has a different font DPI?
body: <p>I'm trying to figure out the font DPI size on the target Windows machine and modify our app's font so that it appears the same size as it would if the target machine had the same dpi as the dev machine. (So a larger Target DPI would mean we'd make our fonts smaller than at dev time).</p>
  
  <p><strong>I'm wondering if there are any problems with the solution below and specifically whether LOGPIXELSX=88 is correct.</strong> </p>
  
  <p><strong>Background</strong></p>
  
  <p>I resize all controls and fonts on our forms to match the current Windows screen resolution. However, if someone has their Font DPI set higher, we need to account for that and make the font <em>smaller</em> (so it ends up being the right size on the screen). Our fonts are already quite large (especially since we resize them w/ screen res). The extra size from the higher DPI makes the text too large.</p>
  
  <p><strong>My solution so far</strong>
  From what I can tell, if we use the GetDeviceCaps as below and then get the CurrentFontDPI and do this:
  (Ignoring the font size modification due to the new screen resolution):</p>
  
  <p>NewFontSize=CurrentFontSize * (DevelopmentDPI/CurrentFontDPI)</p>
  
  <pre><code> Function CurrentFontDPI
    Dim hwnd, hDC, logPix, r As Long
    Dim  LOGPIXELSX=88
    hwnd = GetDesktopWindow()
    hDC = GetDC(hwnd)
    logPix = GetDeviceCaps(hDC,LOGPIXELSX )
    r = ReleaseDC(hwnd, hDC)
    CurrentFontDPI= logPix
  </code></pre>
  
  <p>end Function</p>
  
  <p>FYI, the above code is part of a larger routine at "a related SO Question][1]. I left out the rest of the code b/c it seemed to at least one error (it had NewFont=OldFont * (NewDPI-OldDPI) which would give you zero height fontsize if the DPI hadn't changed)</p>
  
  <p>[1]: <a href="http://www.BungalowSoftware.com" rel="nofollow noreferrer">http://www.BungalowSoftware.com</a>  test</p>