How To Calculate the Point Font Size (264243)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional
  • Microsoft Windows 2000 Driver Development Kit (DDK)
  • Microsoft Windows NT 4.0 Driver Development Kit (DDK)
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows XP Driver Development Kit (DDK)
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Professional

This article was previously published under Q264243

SUMMARY

This article discusses a general procedure for calculating or computing the point font size of TrueType fonts.

MORE INFORMATION

Use the following steps to calculate or compute the point font size of TrueType fonts:
  • Retrieve the notional-to-device transform (XFORMOBJ *pxo) for the specified font (FONTOBJ *pfo), as follows:
    	XFORMOBJ FONTOBJ_pxoGetXform(
    	    IN FONTOBJ  *pfo
    	    );
    
    					
  • Download the associated xform transform (XFORML xform), as follows:
    	ULONG XFORMOBJ_iGetXform(
      	   IN XFORMOBJ  *pxo,
      	   OUT XFORML  *pxform
      	   );
    
    					
  • Compute the the X and Y scale for the general case, as follows:
    	eXScale = sqrt(xform.eM11 * xform.eM11 + xform.eM12 * xform.eM12);
    	eYScale = sqrt(xform.eM22 * xform.eM22 + xform.eM21 * xform.eM21);
    					
  • Find fwdUnitsPerEm (the em-height of the font) from the IFIMETRICS structure, by calling:
    	PIFIMETRICS DrvQueryFont(
    	   IN DHPDEV  dhpdev,
    	   IN ULONG_PTR  iFile,
    	   IN ULONG  iFace,
    	   IN ULONG  *pid
    	   );
    					
  • Find sizLogResPpi, (the resolution of the device for which this font is realized) from the structure FONTOBJ *pfo (iFile and iFace are from the same FONTOBJ structure).
  • Compute the point size by using the following formula:
    	iTmp = (int)(0.5 + eYScale * fwdUnitsPerEm * 72) / sizLogResPpi;
    					

Modification Type:MinorLast Reviewed:8/30/2004
Keywords:kbhowto kbprint KB264243