wxArt2D
mswfont.cpp
Go to the documentation of this file.
1 /*! \file artbase/src/mswfont.cpp
2  \author Philip Patrick, Hans Dietrich
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: mswfont.cpp,v 1.11 2008/04/11 13:39:51 titato Exp $
9 */
10 
11 // XFont.cpp Version 1.1
12 //
13 // Author: Philip Patrick (GetFontProperties)
14 //
15 // Version 1.0 - Initial release of GetFontProperties()
16 //
17 // Modified by: Hans Dietrich
18 // hdietrich2@hotmail.com
19 //
20 // Version 1.1: - Removed MFC dependency from GetFontProperties()
21 // - Converted CFile file I/O to memory mapped file
22 // - Added Unicode support
23 // - Combined with my GetFontFile() routine
24 //
25 // EW: slightly modified this file for use in wxArt2D:
26 // - Removed TRACE commands
27 // - replaced _ASSERTE with (ANSI) assert
28 // - renamed XFont to mswfont, to avoid confusion with X-windows
29 // - added the wxArt2D header
30 // - replaced KEY_ALL_ACCESS (=r/w) with KEY_QUERY_VALUE (=readonly)
31 
32 ///////////////////////////////////////////////////////////////////////////////
33 
34 #include "a2dprec.h"
35 
36 #if defined(__WXMSW__)
37 
38 #include <wx/platform.h> // to obtain wxwin its unicode settings
39 #include <windows.h>
40 #include <assert.h>
41 #include <tchar.h>
42 #include "wx/artbase/mswfont.h"
43 
44 ///////////////////////////////////////////////////////////////////////////////
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 
48 #if defined(__VISUALC__)
49 #pragma warning(disable : 4127) // conditional expression is constant
50 #endif
51 
52 ///////////////////////////////////////////////////////////////////////////////
53 // private routines
54 static LONG GetNextNameValue( HKEY key, LPCTSTR subkey, LPTSTR szName, LPTSTR szData );
55 static BOOL GetWinVer( LPTSTR lpszVersion, int nVersionSize, int* nVersion );
56 
57 ///////////////////////////////////////////////////////////////////////////////
58 // defines used by GetWinVer()
59 #define WUNKNOWNSTR _T("unknown Windows version")
60 
61 #define W95STR _T("Windows 95")
62 #define W95SP1STR _T("Windows 95 SP1")
63 #define W95OSR2STR _T("Windows 95 OSR2")
64 #define W98STR _T("Windows 98")
65 #define W98SP1STR _T("Windows 98 SP1")
66 #define W98SESTR _T("Windows 98 SE")
67 #define WMESTR _T("Windows ME")
68 
69 #define WNT351STR _T("Windows NT 3.51")
70 #define WNT4STR _T("Windows NT 4")
71 #define W2KSTR _T("Windows 2000")
72 #define WXPSTR _T("Windows XP")
73 #define W2003STR _T("Windows Server 2003")
74 #define WUNKNOWNPSTR _T("Windows Unknown")
75 
76 #define WCESTR _T("Windows CE")
77 
78 
79 #define WUNKNOWN 0
80 
81 #define W9XFIRST 1
82 #define W95 1
83 #define W95SP1 2
84 #define W95OSR2 3
85 #define W98 4
86 #define W98SP1 5
87 #define W98SE 6
88 #define WME 7
89 #define W9XLAST 99
90 
91 #define WNTFIRST 101
92 #define WNT351 101
93 #define WNT4 102
94 #define W2K 103
95 #define WXP 104
96 #define W2003 105
97 #define WNTLAST 199
98 
99 #define WCEFIRST 201
100 #define WCE 201
101 #define WCELAST 299
102 
103 
104 ///////////////////////////////////////////////////////////////////////////////
105 //
106 // structs used by GetFontProperties()
107 //
108 typedef struct _tagFONT_PROPERTIES_ANSI
109 {
110  char csName[1024];
111  char csCopyright[1024];
112  char csTrademark[1024];
113  char csFamily[1024];
114 }
115 FONT_PROPERTIES_ANSI;
116 
117 typedef struct _tagTT_OFFSET_TABLE
118 {
119  USHORT uMajorVersion;
120  USHORT uMinorVersion;
121  USHORT uNumOfTables;
122  USHORT uSearchRange;
123  USHORT uEntrySelector;
124  USHORT uRangeShift;
125 }
126 TT_OFFSET_TABLE;
127 
128 typedef struct _tagTT_TABLE_DIRECTORY
129 {
130  char szTag[4]; //table name
131  ULONG uCheckSum; //Check sum
132  ULONG uOffset; //Offset from beginning of file
133  ULONG uLength; //length of the table in bytes
134 }
135 TT_TABLE_DIRECTORY;
136 
137 typedef struct _tagTT_NAME_TABLE_HEADER
138 {
139  USHORT uFSelector; //format selector. Always 0
140  USHORT uNRCount; //Name Records count
141  USHORT uStorageOffset; //Offset for strings storage, from start of the table
142 }
143 TT_NAME_TABLE_HEADER;
144 
145 typedef struct _tagTT_NAME_RECORD
146 {
147  USHORT uPlatformID;
148  USHORT uEncodingID;
149  USHORT uLanguageID;
150  USHORT uNameID;
151  USHORT uStringLength;
152  USHORT uStringOffset; //from start of storage area
153 }
154 TT_NAME_RECORD;
155 
156 #define SWAPWORD(x) MAKEWORD(HIBYTE(x), LOBYTE(x))
157 #define SWAPLONG(x) MAKELONG(SWAPWORD(HIWORD(x)), SWAPWORD(LOWORD(x)))
158 
159 
160 ///////////////////////////////////////////////////////////////////////////////
161 //
162 // GetFontFile()
163 //
164 // Purpose: Find the name of font file from the font name
165 //
166 // Parameters: lpszFontName - name of font
167 // lpszDisplayName - pointer to buffer where font display name
168 // will be copied
169 // nDisplayNameSize - size of display name buffer in TCHARs
170 // lpszFontFile - pointer to buffer where font file name
171 // will be copied
172 // nFontFileSize - size of font file buffer in TCHARs
173 //
174 // Returns: BOOL - TRUE = success
175 //
176 // Notes: This is *not* a foolproof method for finding the name of a
177 // font file. If a font has been installed in a normal manner,
178 // and if it is in the Windows "Font" directory, then this method
179 // will probably work. It will probably work for most screen
180 // fonts and TrueType fonts. However, this method might not work
181 // for fonts that are created or installed dynamically, or that
182 // are specific to a particular device, or that are not installed
183 // into the font directory.
184 //
185 BOOL GetFontFile( LPCTSTR lpszFontName,
186  LPTSTR lpszDisplayName,
187  int nDisplayNameSize,
188  LPTSTR lpszFontFile,
189  int nFontFileSize )
190 {
191  assert( lpszFontName && lpszFontName[0] != 0 );
192  if ( !lpszFontName || lpszFontName[0] == 0 )
193  return FALSE;
194 
195  assert( lpszDisplayName );
196  if ( !lpszDisplayName )
197  return FALSE;
198 
199  assert( lpszFontFile );
200  if ( !lpszFontFile )
201  return FALSE;
202 
203  lpszDisplayName[0] = _T( '\0' );
204  lpszFontFile[0] = _T( '\0' );
205 
206  TCHAR szName[2 * MAX_PATH];
207  TCHAR szData[2 * MAX_PATH];
208 
209  int nVersion;
210  TCHAR szVersion[100];
211  GetWinVer( szVersion, sizeof( szVersion ) / sizeof( TCHAR ) - 1, &nVersion );
212 
213  TCHAR szFontPath[1000];
214 
215  if ( ( nVersion >= WNTFIRST ) && ( nVersion <= WNTLAST ) )
216  _tcscpy( szFontPath, _T( "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" ) );
217  else
218  _tcscpy( szFontPath, _T( "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts" ) );
219 
220  BOOL bResult = FALSE;
221 
222  while ( GetNextNameValue( HKEY_LOCAL_MACHINE, szFontPath, szName, szData ) == ERROR_SUCCESS )
223  {
224  if ( _tcsnicmp( lpszFontName, szName, _tcslen( lpszFontName ) ) == 0 )
225  {
226  _tcsncpy( lpszDisplayName, szName, nDisplayNameSize - 1 );
227  _tcsncpy( lpszFontFile, szData, nFontFileSize - 1 );
228  bResult = TRUE;
229  break;
230  }
231 
232  szFontPath[0] = _T( '\0' ); // this will get next value, same key
233  }
234 
235  GetNextNameValue( HKEY_LOCAL_MACHINE, NULL, NULL, NULL ); // close the registry key
236 
237  return bResult;
238 }
239 
240 
241 ///////////////////////////////////////////////////////////////////////////////
242 //
243 // GetFontProperties()
244 //
245 // Purpose: Get font name from font file
246 //
247 // Parameters: lpszFilePath - file path of font file
248 // lpFontPropsX - pointer to font properties struct
249 //
250 // Returns: BOOL - TRUE = success
251 //
252 BOOL GetFontProperties( LPCTSTR lpszFilePath, FONT_PROPERTIES* lpFontPropsX )
253 {
254  FONT_PROPERTIES_ANSI fp;
255  FONT_PROPERTIES_ANSI* lpFontProps = &fp;
256 
257  memset( lpFontProps, 0, sizeof( FONT_PROPERTIES_ANSI ) );
258 
259  HANDLE hFile = INVALID_HANDLE_VALUE;
260  hFile = ::CreateFile( lpszFilePath,
261  GENERIC_READ,// | GENERIC_WRITE,
262  0,
263  NULL,
264  OPEN_ALWAYS,
265  FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
266  NULL );
267 
268  if ( hFile == INVALID_HANDLE_VALUE )
269  {
270  return FALSE;
271  }
272 
273  // get the file size
274  DWORD dwFileSize = ::GetFileSize( hFile, NULL );
275 
276  if ( dwFileSize == INVALID_FILE_SIZE )
277  {
278  ::CloseHandle( hFile );
279  return FALSE;
280  }
281 
282  // Create a file mapping object that is the current size of the file
283  HANDLE hMappedFile = NULL;
284  hMappedFile = ::CreateFileMapping( hFile,
285  NULL,
286  PAGE_READONLY, //PAGE_READWRITE,
287  0,
288  dwFileSize,
289  NULL );
290 
291  if ( hMappedFile == NULL )
292  {
293  ::CloseHandle( hFile );
294  return FALSE;
295  }
296 
297  LPBYTE lpMapAddress = ( LPBYTE ) ::MapViewOfFile( hMappedFile, // handle to file-mapping object
298  FILE_MAP_READ,//FILE_MAP_WRITE, // access mode
299  0, // high-order DWORD of offset
300  0, // low-order DWORD of offset
301  0 ); // number of bytes to map
302 
303  if ( lpMapAddress == NULL )
304  {
305  ::CloseHandle( hMappedFile );
306  ::CloseHandle( hFile );
307  return FALSE;
308  }
309 
310  BOOL bRetVal = FALSE;
311  int index = 0;
312 
313  TT_OFFSET_TABLE ttOffsetTable;
314  memcpy( &ttOffsetTable, &lpMapAddress[index], sizeof( TT_OFFSET_TABLE ) );
315  index += sizeof( TT_OFFSET_TABLE );
316 
317  ttOffsetTable.uNumOfTables = SWAPWORD( ttOffsetTable.uNumOfTables );
318  ttOffsetTable.uMajorVersion = SWAPWORD( ttOffsetTable.uMajorVersion );
319  ttOffsetTable.uMinorVersion = SWAPWORD( ttOffsetTable.uMinorVersion );
320 
321  //check is this is a true type font and the version is 1.0
322  if ( ttOffsetTable.uMajorVersion != 1 || ttOffsetTable.uMinorVersion != 0 )
323  return bRetVal;
324 
325  TT_TABLE_DIRECTORY tblDir;
326  memset( &tblDir, 0, sizeof( TT_TABLE_DIRECTORY ) );
327  BOOL bFound = FALSE;
328  char szTemp[4096];
329  memset( szTemp, 0, sizeof( szTemp ) );
330 
331  for ( int i = 0; i < ttOffsetTable.uNumOfTables; i++ )
332  {
333  //f.Read(&tblDir, sizeof(TT_TABLE_DIRECTORY));
334  memcpy( &tblDir, &lpMapAddress[index], sizeof( TT_TABLE_DIRECTORY ) );
335  index += sizeof( TT_TABLE_DIRECTORY );
336 
337  strncpy( szTemp, tblDir.szTag, 4 );
338  if ( stricmp( szTemp, "name" ) == 0 )
339  {
340  bFound = TRUE;
341  tblDir.uLength = SWAPLONG( tblDir.uLength );
342  tblDir.uOffset = SWAPLONG( tblDir.uOffset );
343  break;
344  }
345  else if ( szTemp[0] == 0 )
346  {
347  break;
348  }
349  }
350 
351  if ( bFound )
352  {
353  index = tblDir.uOffset;
354 
355  TT_NAME_TABLE_HEADER ttNTHeader;
356  memcpy( &ttNTHeader, &lpMapAddress[index], sizeof( TT_NAME_TABLE_HEADER ) );
357  index += sizeof( TT_NAME_TABLE_HEADER );
358 
359  ttNTHeader.uNRCount = SWAPWORD( ttNTHeader.uNRCount );
360  ttNTHeader.uStorageOffset = SWAPWORD( ttNTHeader.uStorageOffset );
361  TT_NAME_RECORD ttRecord;
362  bFound = FALSE;
363 
364  for ( int i = 0;
365  i < ttNTHeader.uNRCount &&
366  ( lpFontProps->csCopyright[0] == 0 ||
367  lpFontProps->csName[0] == 0 ||
368  lpFontProps->csTrademark[0] == 0 ||
369  lpFontProps->csFamily[0] == 0 );
370  i++ )
371  {
372  memcpy( &ttRecord, &lpMapAddress[index], sizeof( TT_NAME_RECORD ) );
373  index += sizeof( TT_NAME_RECORD );
374 
375  ttRecord.uNameID = SWAPWORD( ttRecord.uNameID );
376  ttRecord.uStringLength = SWAPWORD( ttRecord.uStringLength );
377  ttRecord.uStringOffset = SWAPWORD( ttRecord.uStringOffset );
378 
379  if ( ttRecord.uNameID == 1 || ttRecord.uNameID == 0 || ttRecord.uNameID == 7 )
380  {
381  int nPos = index; //f.GetPosition();
382 
383  index = tblDir.uOffset + ttRecord.uStringOffset + ttNTHeader.uStorageOffset;
384 
385  memset( szTemp, 0, sizeof( szTemp ) );
386 
387  memcpy( szTemp, &lpMapAddress[index], ttRecord.uStringLength );
388  index += ttRecord.uStringLength;
389 
390  if ( szTemp[0] != 0 )
391  {
392  assert( strlen( szTemp ) < sizeof( lpFontProps->csName ) );
393 
394  switch ( ttRecord.uNameID )
395  {
396  case 0:
397  if ( lpFontProps->csCopyright[0] == 0 )
398  strncpy( lpFontProps->csCopyright, szTemp,
399  sizeof( lpFontProps->csCopyright ) - 1 );
400  break;
401 
402  case 1:
403  if ( lpFontProps->csFamily[0] == 0 )
404  strncpy( lpFontProps->csFamily, szTemp,
405  sizeof( lpFontProps->csFamily ) - 1 );
406  bRetVal = TRUE;
407  break;
408 
409  case 4:
410  if ( lpFontProps->csName[0] == 0 )
411  strncpy( lpFontProps->csName, szTemp,
412  sizeof( lpFontProps->csName ) - 1 );
413  break;
414 
415  case 7:
416  if ( lpFontProps->csTrademark[0] == 0 )
417  strncpy( lpFontProps->csTrademark, szTemp,
418  sizeof( lpFontProps->csTrademark ) - 1 );
419  break;
420 
421  default:
422  break;
423  }
424  }
425  index = nPos;
426  }
427  }
428  }
429 
430  ::UnmapViewOfFile( lpMapAddress );
431  ::CloseHandle( hMappedFile );
432  ::CloseHandle( hFile );
433 
434  if ( lpFontProps->csName[0] == 0 )
435  strcpy( lpFontProps->csName, lpFontProps->csFamily );
436 
437  memset( lpFontPropsX, 0, sizeof( FONT_PROPERTIES ) );
438 
439 #ifdef _UNICODE
440  ::MultiByteToWideChar( CP_ACP, 0, lpFontProps->csName, -1, lpFontPropsX->csName,
441  sizeof( lpFontPropsX->csName ) / sizeof( TCHAR ) - 1 );
442  ::MultiByteToWideChar( CP_ACP, 0, lpFontProps->csCopyright, -1, lpFontPropsX->csCopyright,
443  sizeof( lpFontPropsX->csCopyright ) / sizeof( TCHAR ) - 1 );
444  ::MultiByteToWideChar( CP_ACP, 0, lpFontProps->csTrademark, -1, lpFontPropsX->csTrademark,
445  sizeof( lpFontPropsX->csTrademark ) / sizeof( TCHAR ) - 1 );
446  ::MultiByteToWideChar( CP_ACP, 0, lpFontProps->csFamily, -1, lpFontPropsX->csFamily,
447  sizeof( lpFontPropsX->csFamily ) / sizeof( TCHAR ) - 1 );
448 #else
449  strcpy( lpFontPropsX->csName, lpFontProps->csName );
450  strcpy( lpFontPropsX->csCopyright, lpFontProps->csCopyright );
451  strcpy( lpFontPropsX->csTrademark, lpFontProps->csTrademark );
452  strcpy( lpFontPropsX->csFamily, lpFontProps->csFamily );
453 #endif
454 
455  return bRetVal;
456 }
457 
458 
459 ///////////////////////////////////////////////////////////////////////////////
460 //
461 // GetNextNameValue()
462 //
463 // Purpose: Get first/next name/value pair from registry
464 //
465 // Parameters: key - handle to open key, or predefined key
466 // pszSubkey - subkey name
467 // pszName - pointer to buffer that receives the value string
468 // pszData - pointer to buffer that receives the data string
469 //
470 // Returns: LONG - return code from registry function; ERROR_SUCCESS = success
471 //
472 // Notes: If pszSubkey, pszName, and pszData are all NULL, then the open
473 // handle will be closed.
474 //
475 // The first time GetNextNameValue is called, pszSubkey should be
476 // specified. On subsequent calls, pszSubkey should be NULL or
477 // an empty string.
478 //
479 static LONG GetNextNameValue( HKEY key, LPCTSTR pszSubkey, LPTSTR pszName, LPTSTR pszData )
480 {
481  static HKEY hkey = NULL; // registry handle, kept open between calls
482  static DWORD dwIndex = 0; // count of values returned
483  LONG retval;
484 
485  // if all parameters are NULL then close key
486  if ( pszSubkey == NULL && pszName == NULL && pszData == NULL )
487  {
488  if ( hkey )
489  RegCloseKey( hkey );
490  hkey = NULL;
491  return ERROR_SUCCESS;
492  }
493 
494  // if subkey is specified then open key (first time)
495  if ( pszSubkey && pszSubkey[0] != 0 )
496  {
497  retval = RegOpenKeyEx( key, pszSubkey, 0, KEY_QUERY_VALUE, &hkey );
498  if ( retval != ERROR_SUCCESS )
499  {
500  return retval;
501  }
502  else
503  {}
504  dwIndex = 0;
505  }
506  else
507  {
508  dwIndex++;
509  }
510 
511  assert( pszName != NULL && pszData != NULL );
512 
513  *pszName = 0;
514  *pszData = 0;
515 
516  TCHAR szValueName[MAX_PATH];
517  DWORD dwValueNameSize = sizeof( szValueName ) - 1;
518  BYTE szValueData[MAX_PATH];
519  DWORD dwValueDataSize = sizeof( szValueData ) - 1;
520  DWORD dwType = 0;
521 
522  retval = RegEnumValue( hkey, dwIndex, szValueName, &dwValueNameSize, NULL,
523  &dwType, szValueData, &dwValueDataSize );
524  if ( retval == ERROR_SUCCESS )
525  {
526  lstrcpy( pszName, ( LPTSTR )szValueName );
527  lstrcpy( pszData, ( LPTSTR )szValueData );
528  }
529  else
530  {}
531 
532  return retval;
533 }
534 
535 
536 // from winbase.h
537 #ifndef VER_PLATFORM_WIN32s
538 #define VER_PLATFORM_WIN32s 0
539 #endif
540 #ifndef VER_PLATFORM_WIN32_WINDOWS
541 #define VER_PLATFORM_WIN32_WINDOWS 1
542 #endif
543 #ifndef VER_PLATFORM_WIN32_NT
544 #define VER_PLATFORM_WIN32_NT 2
545 #endif
546 #ifndef VER_PLATFORM_WIN32_CE
547 #define VER_PLATFORM_WIN32_CE 3
548 #endif
549 
550 
551 /*
552  This table has been assembled from Usenet postings, personal
553  observations, and reading other people's code. Please feel
554  free to add to it or correct it.
555 
556 
557  dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber
558 95 1 4 0 950
559 95 SP1 1 4 0 >950 && <=1080
560 95 OSR2 1 4 <10 >1080
561 98 1 4 10 1998
562 98 SP1 1 4 10 >1998 && <2183
563 98 SE 1 4 10 >=2183
564 ME 1 4 90 3000
565 
566 NT 3.51 2 3 51
567 NT 4 2 4 0 1381
568 2000 2 5 0 2195
569 XP 2 5 1 2600
570 
571 CE 3
572 
573 */
574 
575 ///////////////////////////////////////////////////////////////////////////////
576 //
577 // GetWinVer()
578 //
579 // Purpose: Get Windows version info
580 //
581 // Parameters: lpszVersion - pointer to buffer that receives the version
582 // string
583 // nVersionSize - size of the version buffer in TCHARs
584 // pnVersion - pointer to int that receives the version code
585 //
586 // Returns: BOOL - TRUE = success
587 //
588 ///////////////////////////////////////////////////////////////////////////////
589 // GetWinVer
590 static BOOL GetWinVer( LPTSTR lpszVersion, int nVersionSize, int* pnVersion )
591 {
592  _tcsncpy( lpszVersion, WUNKNOWNSTR, nVersionSize - 1 );
593  *pnVersion = WUNKNOWN;
594 
595  TCHAR* cp = WUNKNOWNSTR;
596 
597  OSVERSIONINFO osinfo;
598  osinfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
599 
600  if ( !GetVersionEx( &osinfo ) )
601  return FALSE;
602 
603  DWORD dwPlatformId = osinfo.dwPlatformId;
604  DWORD dwMinorVersion = osinfo.dwMinorVersion;
605  DWORD dwMajorVersion = osinfo.dwMajorVersion;
606  DWORD dwBuildNumber = osinfo.dwBuildNumber & 0xFFFF; // Win 95 needs this
607 
608  if ( ( dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) && ( dwMajorVersion == 4 ) )
609  {
610  if ( ( dwMinorVersion < 10 ) && ( dwBuildNumber == 950 ) )
611  {
612  cp = W95STR;
613  *pnVersion = W95;
614  }
615  else if ( ( dwMinorVersion < 10 ) &&
616  ( ( dwBuildNumber > 950 ) && ( dwBuildNumber <= 1080 ) ) )
617  {
618  cp = W95SP1STR;
619  *pnVersion = W95SP1;
620  }
621  else if ( ( dwMinorVersion < 10 ) && ( dwBuildNumber > 1080 ) )
622  {
623  cp = W95OSR2STR;
624  *pnVersion = W95OSR2;
625  }
626  else if ( ( dwMinorVersion == 10 ) && ( dwBuildNumber == 1998 ) )
627  {
628  cp = W98STR;
629  *pnVersion = W98;
630  }
631  else if ( ( dwMinorVersion == 10 ) &&
632  ( ( dwBuildNumber > 1998 ) && ( dwBuildNumber < 2183 ) ) )
633  {
634  cp = W98SP1STR;
635  *pnVersion = W98SP1;
636  }
637  else if ( ( dwMinorVersion == 10 ) && ( dwBuildNumber >= 2183 ) )
638  {
639  cp = W98SESTR;
640  *pnVersion = W98SE;
641  }
642  else if ( dwMinorVersion == 90 )
643  {
644  cp = WMESTR;
645  *pnVersion = WME;
646  }
647  }
648  else if ( dwPlatformId == VER_PLATFORM_WIN32_NT )
649  {
650  if ( ( dwMajorVersion == 3 ) && ( dwMinorVersion == 51 ) )
651  {
652  cp = WNT351STR;
653  *pnVersion = WNT351;
654  }
655  else if ( ( dwMajorVersion == 4 ) && ( dwMinorVersion == 0 ) )
656  {
657  cp = WNT4STR;
658  *pnVersion = WNT4;
659  }
660  else if ( ( dwMajorVersion == 5 ) && ( dwMinorVersion == 0 ) )
661  {
662  cp = W2KSTR;
663  *pnVersion = W2K;
664  }
665  else if ( ( dwMajorVersion == 5 ) && ( dwMinorVersion == 1 ) )
666  {
667  cp = WXPSTR;
668  *pnVersion = WXP;
669  }
670  else if ( ( dwMajorVersion == 5 ) && ( dwMinorVersion == 2 ) )
671  {
672  cp = W2003STR;
673  *pnVersion = W2003;
674  }
675 
676  }
677  else if ( dwPlatformId == VER_PLATFORM_WIN32_CE )
678  {
679  cp = WCESTR;
680  *pnVersion = WCE;
681  }
682 
683  _tcsncpy( lpszVersion, cp, nVersionSize - 1 );
684 
685  return TRUE;
686 }
687 
688 #endif //defined(__WXMSW__)
BOOL GetFontProperties(LPCTSTR lpszFilePath, LPFONT_PROPERTIES lpFontProps)
get font name from the file
BOOL GetFontFile(LPCTSTR lpszFontName, LPTSTR lpszDisplayName, int nDisplayNameSize, LPTSTR lpszFontFile, int nFontFileSize)
find a font that is close to a wxDC font.
MSW specific font properties.
Definition: mswfont.h:28
mswfont.cpp Source File -- Sun Oct 12 2014 17:04:22 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation