]> git.saurik.com Git - wxWidgets.git/blame - src/os2/fontutil.cpp
Change m_windowCurrent to m_currentNSWindow such that m_currentNSWindow is
[wxWidgets.git] / src / os2 / fontutil.cpp
CommitLineData
d8cde57b
DW
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/fontutil.cpp
3// Purpose: font-related helper functions for wxMSW
4// Author: Modified by David Webster for OS/2
5// Modified by:
6// Created: 01.03.00
7// RCS-ID: $Id$
8// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
6aa89a22 9// Licence: wxWindows licence
d8cde57b 10///////////////////////////////////////////////////////////////////////////////
7e99520b
DW
11#define DEBUG_PRINTF(NAME) { static int raz=0; \
12 printf( #NAME " %i\n",raz); fflush(stdout); \
13 raz++; \
14 }
d8cde57b
DW
15
16// ============================================================================
17// declarations
18// ============================================================================
19
20// ----------------------------------------------------------------------------
21// headers
22// ----------------------------------------------------------------------------
23
a4372af6
SN
24#ifdef __GNUG__
25 #pragma implementation "fontutil.h"
26#endif
27
d8cde57b
DW
28// For compilers that support precompilation, includes "wx.h".
29#include "wx/wxprec.h"
30
31#ifndef WX_PRECOMP
3417f661 32 #include "wx/app.h"
d8cde57b
DW
33 #include "wx/string.h"
34 #include "wx/log.h"
35 #include "wx/intl.h"
36#endif //WX_PRECOMP
37
38#include "wx/os2/private.h"
39
40#include "wx/fontutil.h"
41#include "wx/fontmap.h"
bd6685b3 42#include "wx/encinfo.h"
d8cde57b
DW
43
44#include "wx/tokenzr.h"
45
46// ============================================================================
47// implementation
48// ============================================================================
49
50// ----------------------------------------------------------------------------
51// wxNativeEncodingInfo
52// ----------------------------------------------------------------------------
53
54// convert to/from the string representation: format is
1e1d0be1 55// encodingid;facename[;charset]
d8cde57b 56
e99762c0
DW
57bool wxNativeEncodingInfo::FromString(
58 const wxString& rsStr
59)
d8cde57b 60{
e99762c0
DW
61 wxStringTokenizer vTokenizer(rsStr, _T(";"));
62 wxString sEncid = vTokenizer.GetNextToken();
63 long lEnc;
d8cde57b 64
e99762c0 65 if (!sEncid.ToLong(&lEnc))
1e1d0be1 66 return FALSE;
e99762c0
DW
67 encoding = (wxFontEncoding)lEnc;
68 facename = vTokenizer.GetNextToken();
69 if (!facename)
d8cde57b
DW
70 return FALSE;
71
e99762c0
DW
72 wxString sTmp = vTokenizer.GetNextToken();
73
74 if (!sTmp)
d8cde57b 75 {
e99762c0 76 charset = 850;
d8cde57b
DW
77 }
78 else
79 {
e99762c0 80 if ( wxSscanf(sTmp, _T("%u"), &charset) != 1 )
d8cde57b
DW
81 {
82 // should be a number!
83 return FALSE;
84 }
85 }
d8cde57b 86 return TRUE;
e99762c0 87} // end of wxNativeEncodingInfo::FromString
d8cde57b
DW
88
89wxString wxNativeEncodingInfo::ToString() const
90{
e99762c0 91 wxString sStr;
7e99520b 92
e99762c0 93 sStr << (long)encoding << _T(';') << facename;
1e1d0be1 94
e99762c0 95 if (charset != 850)
d8cde57b 96 {
e99762c0 97 sStr << _T(';') << charset;
d8cde57b 98 }
e99762c0
DW
99 return sStr;
100} // end of wxNativeEncodingInfo::ToString
d8cde57b
DW
101
102// ----------------------------------------------------------------------------
103// helper functions
104// ----------------------------------------------------------------------------
105
e99762c0
DW
106bool wxGetNativeFontEncoding(
107 wxFontEncoding vEncoding
108, wxNativeEncodingInfo* pInfo
109)
d8cde57b 110{
e99762c0
DW
111 wxCHECK_MSG(pInfo, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
112 if (vEncoding == wxFONTENCODING_DEFAULT)
d8cde57b 113 {
e99762c0 114 vEncoding = wxFont::GetDefaultEncoding();
d8cde57b 115 }
e99762c0 116 switch (vEncoding)
d8cde57b 117 {
d8cde57b
DW
118 case wxFONTENCODING_ISO8859_1:
119 case wxFONTENCODING_ISO8859_15:
e99762c0
DW
120 case wxFONTENCODING_CP1250:
121 pInfo->charset = 1250;
d8cde57b
DW
122 break;
123
e99762c0
DW
124 case wxFONTENCODING_ISO8859_2:
125 case wxFONTENCODING_CP1252:
126 pInfo->charset = 1252;
d8cde57b
DW
127 break;
128
e99762c0
DW
129 case wxFONTENCODING_ISO8859_4:
130 case wxFONTENCODING_ISO8859_10:
131 pInfo->charset = 921; // what is baltic?
d8cde57b
DW
132 break;
133
e99762c0
DW
134 case wxFONTENCODING_ISO8859_5:
135 case wxFONTENCODING_CP1251:
136 pInfo->charset = 1251;
d8cde57b
DW
137 break;
138
e99762c0
DW
139 case wxFONTENCODING_ISO8859_6:
140 pInfo->charset = 864;
d8cde57b
DW
141 break;
142
e99762c0
DW
143 case wxFONTENCODING_ISO8859_7:
144 pInfo->charset = 869;
d8cde57b
DW
145 break;
146
e99762c0
DW
147 case wxFONTENCODING_ISO8859_8:
148 pInfo->charset = 862;
d8cde57b
DW
149 break;
150
e99762c0
DW
151 case wxFONTENCODING_ISO8859_9:
152 pInfo->charset = 857;
d8cde57b
DW
153 break;
154
e99762c0
DW
155 case wxFONTENCODING_ISO8859_11:
156 pInfo->charset = 874; // what is thai
d8cde57b
DW
157 break;
158
159 case wxFONTENCODING_CP437:
e99762c0 160 pInfo->charset = 437;
d8cde57b 161 break;
e99762c0 162
d8cde57b 163 default:
e99762c0
DW
164 wxFAIL_MSG(wxT("unsupported encoding"));
165 // fall through
d8cde57b 166
e99762c0
DW
167 case wxFONTENCODING_SYSTEM:
168 pInfo->charset = 850;
169 break;
170 }
d8cde57b 171 return TRUE;
e99762c0 172} // end of wxGetNativeFontEncoding
d8cde57b 173
cc95f4f9
DW
174wxFontEncoding wxGetFontEncFromCharSet(
175 int nCharSet
176)
177{
178 wxFontEncoding eFontEncoding;
179
180 switch (nCharSet)
181 {
182 default:
183 case 1250:
184 eFontEncoding = wxFONTENCODING_CP1250;
185 break;
186
187 case 1252:
188 eFontEncoding = wxFONTENCODING_CP1252;
189 break;
190
191 case 921:
192 eFontEncoding = wxFONTENCODING_ISO8859_4;
193 break;
194
195 case 1251:
196 eFontEncoding = wxFONTENCODING_CP1251;
197 break;
198
199 case 864:
200 eFontEncoding = wxFONTENCODING_ISO8859_6;
201 break;
202
203 case 869:
204 eFontEncoding = wxFONTENCODING_ISO8859_7;
205 break;
206
207 case 862:
208 eFontEncoding = wxFONTENCODING_ISO8859_8;
209 break;
210
211 case 857:
212 eFontEncoding = wxFONTENCODING_ISO8859_9;
213 break;
214
215 case 874:
216 eFontEncoding = wxFONTENCODING_ISO8859_11;
217 break;
218
219 case 437:
220 eFontEncoding = wxFONTENCODING_CP437;
221 break;
222 }
223 return eFontEncoding;
224} // end of wxGetNativeFontEncoding
225
e99762c0
DW
226bool wxTestFontEncoding(
227 const wxNativeEncodingInfo& rInfo
228)
d8cde57b 229{
e99762c0
DW
230 FATTRS vLogFont;
231 HPS hPS;
232
233 hPS = ::WinGetPS(HWND_DESKTOP);
234
235 memset(&vLogFont, '\0', sizeof(FATTRS)); // all default values
236 vLogFont.usRecordLength = sizeof(FATTRS);
237 vLogFont.usCodePage = rInfo.charset;
238 vLogFont.lMaxBaselineExt = 0L; // Outline fonts should use 0
239 vLogFont.lAveCharWidth = 0L; // Outline fonts should use 0
240 vLogFont.fsFontUse = FATTR_FONTUSE_OUTLINE | // only outline fonts allowed
241 FATTR_FONTUSE_TRANSFORMABLE; // may be transformed
242
243 strncpy(vLogFont.szFacename, rInfo.facename.c_str(), sizeof(vLogFont.szFacename));
244
245 if (!::GpiCreateLogFont( hPS
246 ,NULL
247 ,1L
248 ,&vLogFont
249 ))
d8cde57b 250 {
e99762c0 251 ::WinReleasePS(hPS);
d8cde57b
DW
252 return FALSE;
253 }
e99762c0 254 ::WinReleasePS(hPS);
d8cde57b 255 return TRUE;
e99762c0 256} // end of wxTestFontEncoding
d8cde57b
DW
257
258// ----------------------------------------------------------------------------
259// wxFont <-> LOGFONT conversion
260// ----------------------------------------------------------------------------
261
a4353f07
DW
262void wxConvertVectorFontSize(
263 FIXED fxPointSize
264, PFATTRS pFattrs
265)
266{
267 HPS hPS;
268 HDC hDC;
269 LONG lXFontResolution;
270 LONG lYFontResolution;
271 SIZEF vSizef;
272
273 hPS = WinGetScreenPS(HWND_DESKTOP); // Screen presentation space
274
275 //
276 // Query device context for the screen and then query
277 // the resolution of the device for the device context.
278 //
279
280 hDC = GpiQueryDevice(hPS);
281 DevQueryCaps( hDC, CAPS_HORIZONTAL_FONT_RES, (LONG)1, &lXFontResolution);
282 DevQueryCaps( hDC, CAPS_VERTICAL_FONT_RES, (LONG)1, &lYFontResolution);
283
284 //
285 // Calculate the size of the character box, based on the
286 // point size selected and the resolution of the device.
287 // The size parameters are of type FIXED, NOT int.
288 // NOTE: 1 point == 1/72 of an inch.
289 //
290
291 vSizef.cx = (FIXED)(((fxPointSize) / 72 ) * lXFontResolution );
292 vSizef.cy = (FIXED)(((fxPointSize) / 72 ) * lYFontResolution );
293
294 pFattrs->lMaxBaselineExt = MAKELONG( HIUSHORT( vSizef.cy ), 0 );
295 pFattrs->lAveCharWidth = MAKELONG( HIUSHORT( vSizef.cx ), 0 );
296 WinReleasePS(hPS);
297
298} // end of wxConvertVectorPointSize
299
e99762c0 300void wxFillLogFont(
cc95f4f9 301 LOGFONT* pFattrs // OS2 GPI FATTRS
e99762c0 302, PFACENAMEDESC pFaceName
54ffa107 303, HPS* phPS
828621c2 304, bool* pbInternalPS
cc95f4f9
DW
305, long* pflId
306, wxString& sFaceName
307, wxFont* pFont
e99762c0 308)
d8cde57b 309{
cc95f4f9
DW
310 LONG lNumFonts = 0L; // For system font count
311 ERRORID vError; // For logging API errors
54ffa107 312 LONG lTemp = 0L;
cc95f4f9
DW
313 bool bInternalPS = FALSE; // if we have to create one
314 PFONTMETRICS pFM = NULL;
315
316 //
317 // Initial house cleaning to free data buffers and ensure we have a
318 // functional PS to work with
319 //
54ffa107 320 if (!*phPS)
cc95f4f9 321 {
54ffa107 322 *phPS = ::WinGetPS(HWND_DESKTOP);
cc95f4f9
DW
323 bInternalPS = TRUE;
324 }
325
326 //
327 // Determine the number of fonts.
328 //
54ffa107 329 if((lNumFonts = ::GpiQueryFonts( *phPS
a23692f0 330 ,QF_PUBLIC | QF_PRIVATE
54ffa107
DW
331 ,NULL
332 ,&lTemp
333 ,(LONG) sizeof(FONTMETRICS)
334 ,NULL
335 )) < 0L)
336 {
337 ERRORID vError;
338 wxString sError;
339
340 vError = ::WinGetLastError(wxGetInstance());
341 sError = wxPMErrorToStr(vError);
342 return;
343 }
cc95f4f9
DW
344
345 //
346 // Allocate space for the font metrics.
347 //
348 pFM = new FONTMETRICS[lNumFonts + 1];
e99762c0 349
cc95f4f9
DW
350 //
351 // Retrieve the font metrics.
352 //
353 lTemp = lNumFonts;
54ffa107 354 lTemp = ::GpiQueryFonts( *phPS
cc95f4f9
DW
355 ,QF_PUBLIC
356 ,NULL
357 ,&lTemp
358 ,(LONG) sizeof(FONTMETRICS)
359 ,pFM
360 );
361 pFont->SetFM( pFM
362 ,(int)lNumFonts
363 );
364
cc95f4f9
DW
365 //
366 // Initialize FATTR and FACENAMEDESC
367 //
368 pFattrs->usRecordLength = sizeof(FATTRS);
a4353f07 369 pFattrs->fsFontUse = FATTR_FONTUSE_OUTLINE; // only outline fonts allowed
cc95f4f9
DW
370 pFattrs->fsType = 0;
371 pFattrs->lMaxBaselineExt = pFattrs->lAveCharWidth = 0;
372 pFattrs->idRegistry = 0;
373 pFattrs->lMatch = 0;
374
375 pFaceName->usSize = sizeof(FACENAMEDESC);
a23692f0
DW
376 pFaceName->usWeightClass = FWEIGHT_DONT_CARE;
377 pFaceName->usWidthClass = FWIDTH_DONT_CARE;
cc95f4f9 378 pFaceName->usReserved = 0;
e99762c0 379 pFaceName->flOptions = 0;
cc95f4f9
DW
380
381 //
382 // This does the actual selection of fonts
383 //
384 wxOS2SelectMatchingFontByName( pFattrs
385 ,pFaceName
386 ,pFM
387 ,(int)lNumFonts
388 ,pFont
389 );
390 //
391 // We should now have the correct FATTRS set with the selected
392 // font, so now we need to generate an ID
393 //
54ffa107 394 long lNumLids = ::GpiQueryNumberSetIds(*phPS);
cc95f4f9
DW
395
396 if(lNumLids )
397 {
398 long alTypes[255];
399 STR8 azNames[255];
400 long alIds[255];
401
d697657f 402 memset(alIds, 0, sizeof(long) * 255);
54ffa107 403 if(!::GpiQuerySetIds( *phPS
cc95f4f9
DW
404 ,lNumLids
405 ,alTypes
406 ,azNames
407 ,alIds
408 ))
409 {
410 if (bInternalPS)
54ffa107 411 ::WinReleasePS(*phPS);
cc95f4f9
DW
412 return;
413 }
d697657f
DW
414 if (*pflId == 0L)
415 *pflId = 1L;
cc95f4f9
DW
416 for(unsigned long LCNum = 0; LCNum < lNumLids; LCNum++)
417 if(alIds[LCNum] == *pflId)
418 ++*pflId;
419 if(*pflId > 254) // wow, no id available!
420 {
421 if (bInternalPS)
54ffa107 422 ::WinReleasePS(*phPS);
cc95f4f9
DW
423 return;
424 }
425 }
54ffa107
DW
426 else
427 *pflId = 1L;
cc95f4f9
DW
428 //
429 // Release and delete the current font
430 //
54ffa107
DW
431 ::GpiSetCharSet(*phPS, LCID_DEFAULT);/* release the font before deleting */
432 ::GpiDeleteSetId(*phPS, 1L); /* delete the logical font */
cc95f4f9
DW
433
434 //
435 // Now build a facestring
436 //
437 char zFacename[128];
438
439 strcpy(zFacename, pFattrs->szFacename);
440
54ffa107 441 if(::GpiQueryFaceString( *phPS
cc95f4f9
DW
442 ,zFacename
443 ,pFaceName
444 ,FACESIZE
445 ,pFattrs->szFacename
446 ) == GPI_ERROR)
447 {
448 vError = ::WinGetLastError(vHabmain);
449 }
450 sFaceName = zFacename;
828621c2 451 *pbInternalPS = bInternalPS;
cc95f4f9
DW
452
453 //
454 // That's it, we now have everything we need to actually create the font
455 //
456} // end of wxFillLogFont
457
458void wxOS2SelectMatchingFontByName(
459 PFATTRS pFattrs
460, PFACENAMEDESC pFaceName
461, PFONTMETRICS pFM
462, int nNumFonts
463, const wxFont* pFont
464)
465{
466 int i;
cc95f4f9 467 int nPointSize;
cc95f4f9 468 int nIs;
cc95f4f9 469 int nMinDiff0;
cc95f4f9
DW
470 int anDiff[16];
471 int anMinDiff[16];
e1146627 472 int nIndex = 0;
cc95f4f9
DW
473 char zFontFaceName[FACESIZE];
474 wxString sFaceName;
475 USHORT usWeightClass;
476 int fsSelection = 0;
477
478 nMinDiff0 = 0xf000;
479 for(i = 0;i < 16; i++)
480 anMinDiff[i] = nMinDiff0;
481
e99762c0 482 switch (pFont->GetFamily())
d8cde57b
DW
483 {
484 case wxSCRIPT:
1b75810c 485 sFaceName = wxT("Tms Rmn");
d8cde57b
DW
486 break;
487
488 case wxDECORATIVE:
07df68c8
DW
489 sFaceName = wxT("WarpSans");
490 break;
491
d8cde57b 492 case wxROMAN:
1b75810c 493 sFaceName = wxT("Tms Rmn");
d8cde57b
DW
494 break;
495
496 case wxTELETYPE:
1b75810c 497 sFaceName = wxT("Courier") ;
d8cde57b
DW
498 break;
499
e3bfcacf 500 case wxMODERN:
1b75810c 501 sFaceName = wxT("System VIO") ;
e3bfcacf
DW
502 break;
503
d8cde57b 504 case wxSWISS:
e3bfcacf 505 sFaceName = wxT("Helv") ;
d8cde57b
DW
506 break;
507
508 case wxDEFAULT:
509 default:
a23692f0 510 sFaceName = wxT("System VIO") ;
d8cde57b
DW
511 }
512
e99762c0 513 switch (pFont->GetWeight())
d8cde57b
DW
514 {
515 default:
516 wxFAIL_MSG(_T("unknown font weight"));
cc95f4f9
DW
517 // fall through
518 usWeightClass = FWEIGHT_DONT_CARE;
e99762c0 519 break;
d8cde57b
DW
520
521 case wxNORMAL:
cc95f4f9 522 usWeightClass = FWEIGHT_NORMAL;
d8cde57b
DW
523 break;
524
525 case wxLIGHT:
cc95f4f9 526 usWeightClass = FWEIGHT_LIGHT;
d8cde57b
DW
527 break;
528
529 case wxBOLD:
cc95f4f9 530 usWeightClass = FWEIGHT_BOLD;
e99762c0
DW
531 break;
532
cc95f4f9
DW
533 case wxFONTWEIGHT_MAX:
534 usWeightClass = FWEIGHT_ULTRA_BOLD;
d8cde57b
DW
535 break;
536 }
cc95f4f9 537 pFaceName->usWeightClass = usWeightClass;
d8cde57b 538
e99762c0
DW
539 switch (pFont->GetStyle())
540 {
541 case wxITALIC:
542 case wxSLANT:
cc95f4f9
DW
543 fsSelection = FM_SEL_ITALIC;
544 pFaceName->flOptions = FTYPE_ITALIC;
e99762c0
DW
545 break;
546
547 default:
548 wxFAIL_MSG(wxT("unknown font slant"));
549 // fall through
d8cde57b 550
e99762c0 551 case wxNORMAL:
cc95f4f9 552 fsSelection = 0;
e99762c0
DW
553 break;
554 }
cc95f4f9
DW
555
556 wxStrncpy(zFontFaceName, sFaceName.c_str(), WXSIZEOF(zFontFaceName));
557 nPointSize = pFont->GetPointSize();
e99762c0
DW
558
559 //
cc95f4f9 560 // Matching logic to find the right FM struct
e99762c0 561 //
cc95f4f9
DW
562 nIndex = 0;
563 for(i = 0, nIs = 0; i < nNumFonts; i++)
d8cde57b 564 {
cc95f4f9
DW
565 int nEmHeight = 0;
566 int nXHeight = 0;
567
a23692f0 568 anDiff[0] = wxGpiStrcmp(pFM[i].szFacename, zFontFaceName);
cc95f4f9
DW
569 anDiff[1] = abs(pFM[i].lEmHeight - nPointSize);
570 anDiff[2] = abs(pFM[i].usWeightClass - usWeightClass);
571 anDiff[3] = abs((pFM[i].fsSelection & 0x2f) - fsSelection);
572 if(anDiff[0] == 0)
573 {
574 nEmHeight = (int)pFM[i].lEmHeight;
575 nXHeight =(int)pFM[i].lXHeight;
576 if( (nIs & 0x01) == 0)
577 {
578 nIs = 1;
579 nIndex = i;
580 anMinDiff[1] = anDiff[1];
581 anMinDiff[2] = anDiff[2];
582 anMinDiff[3] = anDiff[3];
583 }
584 else if(anDiff[3] < anMinDiff[3])
585 {
586 nIndex = i;
587 anMinDiff[3] = anDiff[3];
588 }
589 else if(anDiff[2] < anMinDiff[2])
590 {
591 nIndex = i;
592 anMinDiff[2] = anDiff[2];
593 }
594 else if(anDiff[1] < anMinDiff[1])
595 {
596 nIndex = i;
597 anMinDiff[1] = anDiff[1];
598 }
599 anMinDiff[0] = 0;
600 }
601 else if(anDiff[0] < anMinDiff[0])
602 {
603 nIs = 2;
604 nIndex = i;
605 anMinDiff[3] = anDiff[3];
606 anMinDiff[2] = anDiff[2];
607 anMinDiff[1] = anDiff[1];
608 anMinDiff[0] = anDiff[0];
609 }
610 else if(anDiff[0] == anMinDiff[0])
611 {
612 if(anDiff[3] < anMinDiff[3])
613 {
614 nIndex = i;
615 anMinDiff[3] = anDiff[3];
616 nIs = 2;
617 }
618 else if(anDiff[2] < anMinDiff[2])
619 {
620 nIndex = i;
621 anMinDiff[2] = anDiff[2];
622 nIs = 2;
623 }
624 else if(anDiff[1] < anMinDiff[1])
625 {
626 nIndex = i;
627 anMinDiff[1] = anDiff[1];
628 nIs = 2;
629 }
630 }
d8cde57b 631 }
d8cde57b 632
e99762c0 633 //
cc95f4f9 634 // Fill in the FATTRS with the best match from FONTMETRICS
e99762c0 635 //
a23692f0 636 pFattrs->usRecordLength = sizeof(FATTRS); // Sets size of structure
a23692f0 637 pFattrs->lMatch = pFM[nIndex].lMatch; // Force match
f289196b
DW
638 pFattrs->idRegistry = 0;
639 pFattrs->usCodePage = 0;
640 pFattrs->fsFontUse = 0;
641 pFattrs->fsType = 0;
642 pFattrs->lMaxBaselineExt = 0;
643 pFattrs->lAveCharWidth = 0;
cc95f4f9 644 wxStrcpy(pFattrs->szFacename, pFM[nIndex].szFacename);
a4353f07
DW
645 if (pFont->GetWeight() == wxNORMAL)
646 pFattrs->fsSelection = 0;
647 else
648 pFattrs->fsSelection = FATTR_SEL_BOLD;
cc95f4f9 649
a4353f07 650 if (pFont->GetStyle() == wxITALIC || pFont->GetStyle() == wxSLANT)
cc95f4f9 651 pFattrs->fsSelection |= FATTR_SEL_ITALIC;
a4353f07
DW
652
653 if (pFont->GetUnderlined())
654 pFattrs->fsSelection |= FATTR_SEL_UNDERSCORE;
cc95f4f9 655} // end of wxOS2SelectMatchingFontByName
e99762c0
DW
656
657wxFont wxCreateFontFromLogFont(
658 const LOGFONT* pLogFont
659, const PFONTMETRICS pFM
660, PFACENAMEDESC pFaceName
661)
d8cde57b 662{
47df2b8c 663 wxNativeFontInfo vInfo;
d8cde57b 664
47df2b8c
DW
665 vInfo.fa = *pLogFont;
666 vInfo.fm = *pFM;
667 vInfo.fn = *pFaceName;
668 return wxFont(vInfo);
e99762c0
DW
669} // end of wxCreateFontFromLogFont
670
671int wxGpiStrcmp(
672 char* s0
673, char* s1
674)
675{ int l0;
676 int l1;
677 int l;
678 int d;
679 int d1;
680 int i;
681 int rc;
682
683 rc = 0;
684 if(s0 == NULL)
685 {
686 if(s1 == NULL)
687 return 0;
688 else
689 return 32;
690 }
691 else if(s1 == NULL)
692 return 32;
693
694 l0 = strlen(s0);
695 l1 = strlen(s1);
696 l = l0;
697 if(l0 != l1)
698 {
699 rc++;
700 if(l1 < l0)
701 l = l1;
702 }
703 for(i=0;i<l;i++)
704 {
705 d = s0[i]-s1[i];
706 if(!d)
707 continue;
708 d1 = toupper(s0[i]) - toupper(s1[i]);
709 if(!d1)
710 continue;
711 rc += abs(d);
712 }
713 return rc;
d8cde57b 714}
d8cde57b 715