#include "wx/tokenzr.h"
+// If 1, use the screen resolution to calculate font sizes.
+// This is OK for screen fonts but might have implications when the
+// same font is used for printing.
+// If 0, assume 96 DPI.
+#define wxUSE_SCREEN_DPI 1
+
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// convert to/from the string representation: format is
-// facename[;charset]
+// encodingid;facename[;charset]
bool wxNativeEncodingInfo::FromString(const wxString& s)
{
wxStringTokenizer tokenizer(s, _T(";"));
+ wxString encid = tokenizer.GetNextToken();
+ long enc;
+ if ( !encid.ToLong(&enc) )
+ return FALSE;
+ encoding = (wxFontEncoding)enc;
+
facename = tokenizer.GetNextToken();
if ( !facename )
return FALSE;
wxString wxNativeEncodingInfo::ToString() const
{
- wxString s(facename);
+ wxString s;
+
+ s << (long)encoding << _T(';') << facename;
if ( charset != ANSI_CHARSET )
{
- s << _T(';') << charset;
+ s << _T(';') << charset;
}
return s;
return FALSE;
}
+ info->encoding = encoding;
+
return TRUE;
}
break;
}
-#if 0
+#if wxUSE_SCREEN_DPI
HDC dc = ::GetDC(NULL);
- int ppInch = ::GetDeviceCaps(dc, LOGPIXELSY);
+ static const int ppInch = ::GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(NULL, dc);
#else
// New behaviour: apparently ppInch varies according to Large/Small Fonts
int nHeight = (font->GetPointSize()*ppInch/72);
#else
// Correct for Windows compatibility
- int nHeight = - (font->GetPointSize()*ppInch/72);
+// int nHeight = - (font->GetPointSize()*ppInch/72);
+ int nHeight = - (int) ( (font->GetPointSize()*((double)ppInch)/72.0) + 0.5);
#endif
wxString facename = font->GetFaceName();
wxString fontFace = logFont->lfFaceName;
- // font size
- HDC dc = ::GetDC(NULL);
-
// remember that 1pt = 1/72inch
int height = abs(logFont->lfHeight);
- int fontPoints = (72*height)/GetDeviceCaps(dc, LOGPIXELSY);
+#if wxUSE_SCREEN_DPI
+ HDC dc = ::GetDC(NULL);
+ static const int ppInch = GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(NULL, dc);
+#else
+ static const int ppInch = 96;
+#endif
+ int fontPoints = (int) (((72.0*((double)height))/(double) ppInch) + 0.5);
wxFontEncoding fontEncoding;
switch ( logFont->lfCharSet )