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