-#if 0
- HDC dc = ::GetDC(NULL);
- int ppInch = ::GetDeviceCaps(dc, LOGPIXELSY);
- ::ReleaseDC(NULL, dc);
-#else
- // New behaviour: apparently ppInch varies according to Large/Small Fonts
- // setting in Windows. This messes up fonts. So, set ppInch to a constant
- // 96 dpi.
- static const int ppInch = 96;
-#endif // 0/1
-
-#if wxFONT_SIZE_COMPATIBILITY
- // Incorrect, but compatible with old wxWindows behaviour
- int nHeight = (font->GetPointSize()*ppInch/72);
-#else
- // Correct for Windows compatibility
- int nHeight = - (font->GetPointSize()*ppInch/72);
-#endif
+bool wxTestFontEncoding( const wxNativeEncodingInfo& rInfo )
+{
+ FATTRS vLogFont;
+ HPS hPS;
+
+ hPS = ::WinGetPS(HWND_DESKTOP);
+
+ memset(&vLogFont, '\0', sizeof(FATTRS)); // all default values
+ vLogFont.usRecordLength = sizeof(FATTRS);
+ vLogFont.usCodePage = (USHORT)rInfo.charset;
+ vLogFont.lMaxBaselineExt = 0L; // Outline fonts should use 0
+ vLogFont.lAveCharWidth = 0L; // Outline fonts should use 0
+ vLogFont.fsFontUse = FATTR_FONTUSE_OUTLINE | // only outline fonts allowed
+ FATTR_FONTUSE_TRANSFORMABLE; // may be transformed
+
+ wxStrncpy((wxChar*)vLogFont.szFacename, rInfo.facename.c_str(), WXSIZEOF(vLogFont.szFacename));
+
+ if (!::GpiCreateLogFont( hPS
+ ,NULL
+ ,1L
+ ,&vLogFont
+ ))
+ {
+ ::WinReleasePS(hPS);
+ return FALSE;
+ }
+ ::WinReleasePS(hPS);
+ return true;
+} // end of wxTestFontEncoding
+
+// ----------------------------------------------------------------------------
+// wxFont <-> LOGFONT conversion
+// ----------------------------------------------------------------------------
+
+void wxConvertVectorFontSize(
+ FIXED fxPointSize
+, PFATTRS pFattrs
+)
+{
+ HPS hPS;
+ HDC hDC;
+ LONG lXFontResolution;
+ LONG lYFontResolution;
+ SIZEF vSizef;
+
+ hPS = WinGetScreenPS(HWND_DESKTOP); // Screen presentation space
+
+ //
+ // Query device context for the screen and then query
+ // the resolution of the device for the device context.
+ //
+
+ hDC = GpiQueryDevice(hPS);
+ DevQueryCaps( hDC, CAPS_HORIZONTAL_FONT_RES, (LONG)1, &lXFontResolution);
+ DevQueryCaps( hDC, CAPS_VERTICAL_FONT_RES, (LONG)1, &lYFontResolution);
+
+ //
+ // Calculate the size of the character box, based on the
+ // point size selected and the resolution of the device.
+ // The size parameters are of type FIXED, NOT int.
+ // NOTE: 1 point == 1/72 of an inch.
+ //
+
+ vSizef.cx = (FIXED)(((fxPointSize) / 72 ) * lXFontResolution );
+ vSizef.cy = (FIXED)(((fxPointSize) / 72 ) * lYFontResolution );
+
+ pFattrs->lMaxBaselineExt = MAKELONG( HIUSHORT( vSizef.cy ), 0 );
+ pFattrs->lAveCharWidth = MAKELONG( HIUSHORT( vSizef.cx ), 0 );
+ WinReleasePS(hPS);
+
+} // end of wxConvertVectorPointSize
+
+void wxFillLogFont( LOGFONT* pFattrs, // OS2 GPI FATTRS
+ PFACENAMEDESC pFaceName,
+ HPS* phPS,
+ bool* pbInternalPS,
+ long* pflId,
+ wxString& sFaceName,
+ wxFont* pFont )
+{
+ LONG lNumFonts = 0L; // For system font count
+ ERRORID vError; // For logging API errors
+ LONG lTemp = 0L;
+ bool bInternalPS = false; // if we have to create one
+ PFONTMETRICS pFM = NULL;
+
+ //
+ // Initial house cleaning to free data buffers and ensure we have a
+ // functional PS to work with
+ //
+ if (!*phPS)
+ {
+ *phPS = ::WinGetPS(HWND_DESKTOP);
+ bInternalPS = true;
+ }