00001 // $Id: atmfonts.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 // implementation file for ATM Font manager winoil inclusion. 00099 00100 /* 00101 */ 00102 00103 #include "camtypes.h" 00104 #include "camelot.h" 00105 #include "atmfonts.h" 00106 #include "fontman.h" 00107 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 #include "atminfo.h" 00109 #include "oilmods.h" 00110 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00111 //#include "txtattr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 #include "textfuns.h" 00113 #include "atminst.h" 00114 #include "unicdman.h" 00115 00116 DECLARE_SOURCE( "$Revision: 1282 $" ); 00117 00118 CC_IMPLEMENT_DYNCREATE( ATMFontMan, CCObject ) 00119 CC_IMPLEMENT_DYNCREATE( ATMFont, FontBase ) 00120 00121 #define new CAM_DEBUG_NEW 00122 #define SCALEORD(ord) (MulDiv(ord,72000,65536)) 00123 #define MINORV(ver) LOBYTE(LOWORD(ver)) 00124 #define MAJORV(ver) HIBYTE(LOWORD(ver)) 00125 00126 BOOL ATMFontMan::ATMRunning = FALSE; 00127 INT32 ATMFontMan::ATMVersion = 0; 00128 INT32 ATMFontMan::ATMUtilVersion = 0; 00129 00130 BOOL ATMFontMan::UseThunking = TRUE; 00131 00132 // The DLL handle 00133 HINSTANCE ATMFontMan::DLLHandle = NULL; 00134 00135 // Static pointers to functions in the DLL 00136 ATMFontMan::PFN_ATMProperlyLoaded ATMFontMan::pfnATMProperlyLoaded = NULL; 00137 ATMFontMan::PFN_ATMGetVersion ATMFontMan::pfnATMGetVersion = NULL; 00138 ATMFontMan::PFN_ATMGetOutline ATMFontMan::pfnATMGetOutline = NULL; 00139 ATMFontMan::PFN_ATMForceExactWidth ATMFontMan::pfnATMForceExactWidth = NULL; 00140 ATMFontMan::PFN_ATMBeginFontChange ATMFontMan::pfnATMBeginFontChange = NULL; 00141 ATMFontMan::PFN_ATMEndFontChange ATMFontMan::pfnATMEndFontChange = NULL; 00142 ATMFontMan::PFN_ATMForceFontChange ATMFontMan::pfnATMForceFontChange = NULL; 00143 ATMFontMan::PFN_ATMFontStatus ATMFontMan::pfnATMFontStatus = NULL; 00144 ATMFontMan::PFN_ATMAddFont ATMFontMan::pfnATMAddFont = NULL; 00145 ATMFontMan::PFN_ATMRemoveFont ATMFontMan::pfnATMRemoveFont = NULL; 00146 00147 // Static pointers to functions in the thunking DLL 00148 LPFNATMPROPERLYLOADED ATMFontMan::pfnXSATMProperlyLoaded = NULL; 00149 //LPFNATMGETVERSION ATMFontMan::pfnXSATMGetVersion = NULL; 00150 LPFNATMGETOUTLINE ATMFontMan::pfnXSATMGetOutline = NULL; 00151 LPFNATMFORCEEXACTWIDTH ATMFontMan::pfnXSATMForceExactWidth = NULL; 00152 LPFNATMBEGINFONTCHANGE ATMFontMan::pfnXSATMBeginFontChange = NULL; 00153 LPFNATMENDFONTCHANGE ATMFontMan::pfnXSATMEndFontChange = NULL; 00154 //PFN_ATMForceFontChange ATMFontMan::pfnXSATMForceFontChange = NULL; 00155 LPFNATMFONTSTATUS ATMFontMan::pfnXSATMFontStatus = NULL; 00156 LPFNATMADDFONT ATMFontMan::pfnXSATMAddFont = NULL; 00157 LPFNATMREMOVEFONT ATMFontMan::pfnXSATMRemoveFont = NULL; 00158 00159 00160 /******************************************************************************************** 00161 00162 > ATMFont::ATMFont() 00163 00164 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 12/09/95 00166 Purpose: Default constructor 00167 00168 ********************************************************************************************/ 00169 00170 ATMFont::ATMFont() 00171 { 00172 } 00173 00174 /******************************************************************************************** 00175 00176 > ATMFont::~ATMFont() 00177 00178 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00179 Created: 12/09/95 00180 Purpose: destructor for the ATMFont class 00181 00182 ********************************************************************************************/ 00183 00184 ATMFont::~ATMFont() 00185 { 00186 } 00187 00188 /******************************************************************************************** 00189 00190 > void ATMFont::Dump() 00191 00192 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00193 Created: 12/09/95 00194 Purpose: Dump the contents of this cache entry out 00195 00196 ********************************************************************************************/ 00197 00198 void ATMFont::Dump() 00199 { 00200 FontBase::Dump(); 00201 TRACE( _T(" FontClass = ATM Type1\n")); 00202 } 00203 00204 /******************************************************************************************** 00205 00206 > ATMFontMan::ATMFontMan() 00207 00208 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00209 Created: 12/09/95 00210 Purpose: Default constructor 00211 00212 ********************************************************************************************/ 00213 00214 ATMFontMan::ATMFontMan() 00215 { 00216 } 00217 00218 /******************************************************************************************** 00219 00220 > static BOOL ATMFontMan::InitDLL() 00221 00222 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00223 Created: 01/9/95 00224 Inputs: - 00225 Outputs: 00226 Returns: TRUE if the ATM mangler is actually running and can be used on this OpSys 00227 Purpose: Determine whether we can make further calls to the Adobe Type Manager 00228 00229 ********************************************************************************************/ 00230 00231 BOOL ATMFontMan::InitDLL() 00232 { 00233 if (!ATMRunning) 00234 ATMRunning = (ThunkProperlyLoaded()>0); 00235 00236 ATMVersion = ThunkGetVersion(); 00237 ATMUtilVersion = ThunkGetUtilVersion(); 00238 00239 return ATMRunning; 00240 } 00241 00242 00243 /******************************************************************************************** 00244 00245 > static void ATMFont::EnumAllFonts(OILEnumFonts* pClass) 00246 00247 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00248 Created: 12/9/95 00249 Purpose: Give the kernel a way of enumerating fonts itself 00250 00251 ********************************************************************************************/ 00252 00253 void ATMFontMan::EnumAllFonts(OILEnumFonts* pClass) 00254 { 00255 CDC Screen; 00256 if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0)) 00257 { 00258 EnumFontFamilies(Screen.m_hDC, 00259 NULL, 00260 (FONTENUMPROC) ATMFontMan_CallBackDispatchFont, 00261 (LPARAM)pClass); 00262 Screen.DeleteDC(); 00263 } 00264 } 00265 00266 /******************************************************************************************** 00267 00268 > static BOOL ATMFontMan::CacheNamedFont(String_64* pFontName) 00269 00270 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00271 Created: 12/9/95 00272 Inputs: pFontName = a pointer to a fontname to find and cache 00273 Outputs: - 00274 Returns: - 00275 Purpose: This function attempts to cache a font of the ATM variety 00276 00277 ********************************************************************************************/ 00278 00279 BOOL ATMFontMan::CacheNamedFont(String_64* pFontName) 00280 { 00281 CDC Screen; // and create a new one 00282 if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0)) 00283 { 00284 FontManager* pFontMan = GetApplication()->GetFontManager(); 00285 ERROR2IF(pFontMan == NULL,FALSE,"NULL FontManager ptr"); 00286 pFontMan->ClearTempFont(); 00287 EnumFontFamilies(Screen.m_hDC, 00288 NULL, 00289 (FONTENUMPROC) ATMFontMan_CallBackCacheNamedFont, 00290 (LPARAM)pFontName); 00291 Screen.DeleteDC(); 00292 return pFontMan->TempFontValid(); 00293 } 00294 return FALSE; 00295 } 00296 00297 /******************************************************************************************** 00298 00299 > static BOOL ATMFontMan::CacheCompatibleFont(String_64* pFontName) 00300 00301 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00302 Created: 12/9/95 00303 Inputs: pFontName = a pointer to a fontname to find and cache 00304 Outputs: - 00305 Returns: - 00306 Purpose: This function attempts to cache a font of the ATM variety. It is called 00307 as a second pass function after CacheNamedFont() has tried to cache the 00308 actual font. From here we can perform several actions to attempt to 00309 construct the font if it is an instance of a multiple master. 00310 00311 ********************************************************************************************/ 00312 00313 BOOL ATMFontMan::CacheCompatibleFont(String_64* pFontName) 00314 { 00315 00316 // search for an underscore in the font 00317 INT32 pos = pFontName->Sub(String_32("_"),0,0); 00318 if (pos==-1) 00319 return FALSE; 00320 00321 // pos is position of first _ character, is there a digit next? 00322 TCHAR digit = (*pFontName)[pos+1]; 00323 if (!StringBase::IsNumeric(digit)) 00324 return FALSE; 00325 00326 String_64 MultiMaster; 00327 pFontName->Left(&MultiMaster, pos); 00328 00329 // now we need to know whether this font exists. 00330 return FALSE; 00331 } 00332 00333 00334 /******************************************************************************************** 00335 00336 > static void ATMFontMan::ValidateCache() 00337 00338 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00339 Created: 12/9/95 00340 Purpose: This function attempts to recache a font of the ATM variety 00341 00342 ********************************************************************************************/ 00343 00344 void ATMFontMan::ValidateCache() 00345 { 00346 CDC Screen; 00347 if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0)) 00348 { 00349 EnumFontFamilies(Screen.m_hDC, 00350 NULL, 00351 (FONTENUMPROC) ATMFontMan_CallBackValidateFont, 00352 NULL); 00353 Screen.DeleteDC(); 00354 } 00355 } 00356 00357 /******************************************************************************************** 00358 00359 > static void ATMFontMan::FindClosestFont() 00360 00361 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 00362 Created: 20/08/96 00363 Purpose: Attempts to search the list of installed fonts, looking for a match 00364 00365 ********************************************************************************************/ 00366 00367 void ATMFontMan::FindClosestFont() 00368 { 00369 CDC Screen; 00370 if (Screen.CreateIC(TEXT("DISPLAY"), 0, 0, 0)) 00371 { 00372 EnumFontFamilies(Screen.m_hDC, 00373 NULL, 00374 (FONTENUMPROC) ATMFontMan_CallBackFindClosestFont, 00375 NULL); 00376 Screen.DeleteDC(); 00377 } 00378 } 00379 00380 /******************************************************************************************** 00381 00382 > ATMFont* ATMFontMan::CreateNewFont(String_64* pFontName) 00383 00384 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00385 Created: 12/9/95 00386 Purpose: This function attempts to create a font instance and will be called by 00387 the font manager when new fonts are added. 00388 00389 ********************************************************************************************/ 00390 00391 ATMFont* ATMFontMan::CreateNewFont(String_64* pFontName) 00392 { 00393 ATMFont *pFont = new ATMFont; 00394 if (pFont==NULL) 00395 return NULL; 00396 if (!pFont->Initialise(pFontName)) 00397 { 00398 delete pFont; 00399 return NULL; 00400 } 00401 return pFont; 00402 } 00403 00404 /******************************************************************************************** 00405 00406 static BOOL ATMFontMan::IsOkToCall() 00407 00408 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00409 Created: 01/9/95 00410 Returns: TRUE if the ATM mangler is actually running and can be used on this OpSys 00411 Purpose: Determine whether we can make further calls to the Adobe Type Manager 00412 00413 ********************************************************************************************/ 00414 00415 BOOL ATMFontMan::IsOkToCall() 00416 { 00417 return ATMRunning; 00418 } 00419 00420 /******************************************************************************************** 00421 00422 static HINSTANCE ATMFontMan::GetATMDLL() 00423 00424 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00425 Created: 01/9/95 00426 Returns: the hInst instance of the ATM dll. 00427 NULL if the DLL has not been loaded or cannot be called due to error 00428 Purpose: Returns the instance handle of the ATM DLL, or NULL if the DLL is not 00429 running. 00430 00431 ********************************************************************************************/ 00432 00433 HINSTANCE ATMFontMan::GetATMDLL() 00434 { 00435 if (!IsOkToCall()) 00436 return NULL; 00437 00438 // Are we on Windows 95 and hence require the thunking DLL? 00439 // This should be the default case 00440 if (UseThunking) 00441 return ExtraDLLs[ ATM_Util_DLL ]; 00442 00443 // We must be on NT where we have a real DLL 00444 return DLLHandle; 00445 } 00446 00447 00448 /******************************************************************************************** 00449 00450 > BOOL ATMFontMan::CorrectVersion(INT32 version) 00451 00452 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00453 Created: 01/9/95 00454 Inputs: version = the version number to check against 00455 lo byte = minor version 00456 hi byte = major version 00457 Returns: TRUE if the running version of ATM is new enough to use 00458 FALSE if not 00459 Purpose: This routine can be used by our OIL layer functions needing to call ATM 00460 provided functions. The problem is there are likely to be many versions 00461 of ATM out there, and new functions obviously appear in later versions. 00462 So it is recommended that you check the running ATM version to make sure 00463 the function was actually implemented in this version. See ATM.h for all 00464 function versions. 00465 NOTE all the functions we call should have MinVer_<functionname> defines 00466 in the header. 00467 00468 ********************************************************************************************/ 00469 00470 BOOL ATMFontMan::CorrectVersion(INT32 version) 00471 { 00472 return (version <= ATMVersion); 00473 } 00474 00475 /******************************************************************************************** 00476 00477 > INT32 ATMFontMan::ThunkProperlyLoaded() 00478 00479 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00480 Created: 01/9/95 00481 Inputs: - 00482 Outputs: 00483 Returns: >0 if the ATM manager is actually running and can be used on this OpSys 00484 Purpose: Determine whether we can make further calls to the Adobe Type Manager 00485 This call has been in the ATM from version 1.00 so there's no need to check 00486 it. 00487 00488 ********************************************************************************************/ 00489 00490 INT32 ATMFontMan::ThunkProperlyLoaded() 00491 { 00492 typedef WORD (FAR PASCAL *PFN)(); 00493 00494 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00495 // if our DLL is not up then return FALSE. 00496 if (!hLib) 00497 return 0; 00498 00499 // extract the function pointers that we require 00500 pfnXSATMProperlyLoaded = (LPFNATMPROPERLYLOADED) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMProperlyLoaded)); 00501 // pfnXSATMGetVersion = (LPFNATMGETVERSION) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMGetVersion)); 00502 pfnXSATMGetOutline = (LPFNATMGETOUTLINE) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMGetOutline)); 00503 pfnXSATMForceExactWidth = (LPFNATMFORCEEXACTWIDTH) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMForceExactWidth)); 00504 pfnXSATMBeginFontChange = (LPFNATMBEGINFONTCHANGE) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMBeginFontChange)); 00505 pfnXSATMEndFontChange = (LPFNATMENDFONTCHANGE) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMEndFontChange)); 00506 // pfnXSATMForceFontChange = (PFN_ATMForceFontChange) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMForceFontChange")); 00507 pfnXSATMFontStatus = (LPFNATMFONTSTATUS) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMFontStatus)); 00508 pfnXSATMAddFont = (LPFNATMADDFONT) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMAddFont)); 00509 pfnXSATMRemoveFont = (LPFNATMREMOVEFONT) GetProcAddress( hLib, MAKEINTRESOURCE(XSATM_ATMRemoveFont)); 00510 00511 // If we had a problem then unload the DLL and say so 00512 if (pfnXSATMProperlyLoaded == NULL || 00513 // pfnXSATMGetVersion == NULL || 00514 pfnXSATMGetOutline == NULL || 00515 pfnXSATMForceExactWidth == NULL || 00516 pfnXSATMBeginFontChange == NULL || 00517 pfnXSATMEndFontChange == NULL || 00518 // pfnXSATMForceFontChange == NULL || 00519 pfnXSATMFontStatus == NULL || 00520 pfnXSATMAddFont == NULL || 00521 pfnXSATMRemoveFont == NULL 00522 ) 00523 { 00524 return FALSE; 00525 } 00526 00527 INT32 result = (INT32)(*pfnXSATMProperlyLoaded)(); 00528 return result; 00529 } 00530 00531 /******************************************************************************************** 00532 00533 > static INT32 ATMFontMan::ThunkGetUtilVersion() 00534 00535 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00536 Created: 01/9/94 00537 Inputs: None 00538 Outputs: None 00539 Returns: High byte major version, low byte minor version 00540 Purpose: Returns the version number of our ATM thunking layer support DLL. 00541 Errors: None. 00542 00543 ********************************************************************************************/ 00544 00545 INT32 ATMFontMan::ThunkGetUtilVersion() 00546 { 00547 // if our DLL is not up then return FALSE. 00548 const HINSTANCE hLib = GetATMDLL(); 00549 if (!hLib) 00550 return 0; 00551 00552 // do some dynamic linking to the DLL 00553 LPFNATMGETUTILVERSION lpfn = (LPFNATMGETUTILVERSION)GetProcAddress(hLib, MAKEINTRESOURCE(XSATM_GetUtilVersion) ); 00554 if (lpfn==NULL) 00555 return 0; 00556 00557 return (INT32)(*lpfn)(); 00558 } 00559 00560 /******************************************************************************************** 00561 00562 > static INT32 ATMFontMan::ThunkGetVersion() 00563 00564 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00565 Created: 01/9/94 00566 Inputs: None 00567 Outputs: None 00568 Returns: High byte major version, low byte minor version 00569 Purpose: The version number of the currently running ATM. 00570 00571 ********************************************************************************************/ 00572 00573 INT32 ATMFontMan::ThunkGetVersion() 00574 { 00575 // if our DLL is not up then return FALSE. 00576 const HINSTANCE hLib = GetATMDLL(); 00577 if (!hLib) 00578 return 0; 00579 00580 // do some dynamic linking to the DLL 00581 LPFNATMGETVERSION lpfn = (LPFNATMGETVERSION)GetProcAddress(hLib, MAKEINTRESOURCE(XSATM_ATMGetVersion) ); 00582 if (lpfn==NULL) 00583 return 0; 00584 00585 INT32 result = (INT32)(*lpfn)(); 00586 00587 // swap the byte order as its rampant! 00588 INT32 minor = HIBYTE(LOWORD(result)); 00589 INT32 major = LOBYTE(LOWORD(result)); 00590 00591 return (minor | (major<<8)); 00592 } 00593 00594 /******************************************************************************************** 00595 00596 > static BOOL ATMFontMan::ForceExactWidth() 00597 00598 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00599 Created: 01/9/95 00600 Inputs: - 00601 Outputs: - 00602 Returns: TRUE if the call is successful, FALSE otherwise. 00603 Purpose: This routine causes the 'next' call for creating a font to create 00604 a font without adjusting the width data for the screen. 00605 00606 ********************************************************************************************/ 00607 00608 BOOL ATMFontMan::ForceExactWidth() 00609 { 00610 // Are we on Windows 95 and hence require the thunking DLL? 00611 // This should be the default case 00612 if (UseThunking) 00613 { 00614 // If we haven't got the correct version then we cannot call it. 00615 if (!CorrectVersion(MinVer_ForceExactWidth)) 00616 return FALSE; 00617 00618 if (pfnXSATMForceExactWidth == NULL) 00619 return FALSE; 00620 00621 return (BOOL)(*pfnXSATMForceExactWidth)(); 00622 } 00623 00624 // We must be on NT where we have a real DLL 00625 if (pfnATMForceExactWidth == NULL) 00626 return FALSE; 00627 00628 return (BOOL)(*pfnATMForceExactWidth)(); 00629 } 00630 00631 00632 00633 00634 /******************************************************************************************** 00635 00636 > static INT32 ATMFontMan::BeginFontChange() 00637 00638 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00639 Created: 01/9/95 00640 Inputs: - 00641 Outputs: - 00642 Returns: 00643 Purpose: Starts a series of font change operations consisting of calls to 00644 the rotuines ATMAddFont and ATMRemoveFont. Must be called before 00645 calling ATMAddFont or ATMRemoveFont. 00646 00647 ********************************************************************************************/ 00648 00649 INT32 ATMFontMan::BeginFontChange() 00650 { 00651 // Are we on Windows 95 and hence require the thunking DLL? 00652 // This should be the default case 00653 if (UseThunking) 00654 { 00655 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00656 // if our DLL is not up then return FALSE. 00657 if (!hLib) 00658 return ATM_NOTRUNNING; 00659 00660 // If we haven't got the correct version then we cannot call it. 00661 if (!CorrectVersion(MinVer_BeginFontChange)) 00662 return ATM_NOTSUPPORTED; 00663 00664 if (pfnXSATMBeginFontChange == NULL) 00665 return ATM_NOTRUNNING; 00666 00667 return (INT32)((INT8)(*pfnXSATMBeginFontChange)()); 00668 } 00669 00670 // We must be on NT where we have a real DLL 00671 if (pfnATMBeginFontChange == NULL) 00672 return ATM_NOTRUNNING; 00673 00674 return (BOOL)(*pfnATMBeginFontChange)(); 00675 } 00676 00677 00678 00679 /******************************************************************************************** 00680 00681 static INT32 ATMFontMan::EndFontChange() 00682 00683 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00684 Created: 01/9/95 00685 Inputs: - 00686 Outputs: - 00687 Returns: 00688 Purpose: Finishes a series of font change operations consisting of calls to 00689 the rotuines ATMAddFont and ATMRemoveFont. 00690 Call this function after font changes are completed, or your font 00691 changes may not take effect. 00692 00693 ********************************************************************************************/ 00694 00695 INT32 ATMFontMan::EndFontChange() 00696 { 00697 // Are we on Windows 95 and hence require the thunking DLL? 00698 // This should be the default case 00699 if (UseThunking) 00700 { 00701 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00702 // if our DLL is not up then return FALSE. 00703 if (!hLib) 00704 return ATM_NOTRUNNING; 00705 00706 // If we haven't got the correct version then we cannot call it. 00707 if (!CorrectVersion(MinVer_EndFontChange)) 00708 return ATM_NOTSUPPORTED; 00709 00710 if (pfnXSATMEndFontChange == NULL) 00711 return ATM_NOTRUNNING; 00712 00713 return (INT32)((INT8)(*pfnXSATMEndFontChange)()); 00714 } 00715 00716 // We must be on NT where we have a real DLL 00717 if (pfnATMEndFontChange == NULL) 00718 return ATM_NOTRUNNING; 00719 00720 return (BOOL)(*pfnATMEndFontChange)(); 00721 } 00722 00723 00724 /******************************************************************************************** 00725 00726 > static INT32 ATMFontMan::FontStatus( TCHAR *pMenuName, 00727 WORD Style, 00728 TCHAR *lpMetricsFile, 00729 TCHAR *lpFontFile) 00730 00731 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00732 Created: 01/9/95 00733 Inputs: The lpMenuName contains the Windows name of the font. 00734 The style parameter contains none, one or both of the flags 00735 ATM_ITALIC and ATM_BOLD. 00736 The lpMetricsFile contains the full pathname to the .pfm file 00737 for the font. 00738 The lpFontFile contains the full pathname to the .pfb file for 00739 the font. 00740 Outputs: - 00741 Returns: Successful return values are: 00742 ATM_FONTINUSE The paths and menu name specify an 00743 existing font which is in use by ATM. 00744 ATM_FONTPRESENT The paths and menu name specify an 00745 existing font which is NOT in use. 00746 ATM_FONTDIFFERENT The font, as specified by its menu name 00747 and styles, exists but its data files 00748 are different from those specified by 00749 lpMetricsFile & lpFontFile parameters. 00750 ATM_FONTABSENT There is no such font installed. 00751 00752 Failure return values are: 00753 ATM_PATHTOOLONG At least one path is too long. 00754 ATM_BADFONTTYPE The font is uncompressed. 00755 ATM_BADSTYLE The style parameter has bad bits! 00756 ATM_NOFONT At least one path doesn't point to 00757 the correct file. 00758 ATM_BADMENUNAME Missing or invalid menu name given. 00759 00760 Purpose: This routine determines whether or not a given font is currently 00761 installed and/or in use by ATM. It should be called prior to 00762 installing a new font. 00763 If the return value is ATM_FONTINUSE, then no attempt should be made 00764 to install the font. 00765 00766 00767 ********************************************************************************************/ 00768 00769 INT32 ATMFontMan::FontStatus(TCHAR *pMenuName, WORD Style, TCHAR *lpMetricsFile, TCHAR *lpFontFile) 00770 { 00771 // Are we on Windows 95 and hence require the thunking DLL? 00772 // This should be the default case 00773 if (UseThunking) 00774 { 00775 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00776 // if our DLL is not up then return FALSE. 00777 if (!hLib) 00778 return ATM_NOTRUNNING; 00779 00780 // If we haven't got the correct version then we cannot call it. 00781 if (!CorrectVersion(MinVer_FontStatus)) 00782 return ATM_NOTSUPPORTED; 00783 00784 if (pfnXSATMFontStatus == NULL) 00785 return ATM_NOTRUNNING; 00786 00787 return (INT32)((INT8)(*pfnXSATMFontStatus)(pMenuName, Style, lpMetricsFile, lpFontFile)); 00788 } 00789 00790 // We must be on NT where we have a real DLL 00791 if (pfnATMFontStatus == NULL) 00792 return ATM_NOTRUNNING; 00793 00794 return (INT32)((INT8)(*pfnATMFontStatus)(pMenuName, Style, lpMetricsFile, lpFontFile)); 00795 } 00796 00797 00798 00799 /******************************************************************************************** 00800 00801 > static INT32 ATMFontMan::AddFont(TCHAR *pMenuName, WORD Style, TCHAR *lpMetricsFile, TCHAR *lpFontFile) 00802 00803 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00804 Created: 01/9/95 00805 Inputs: The lpMenuName contains the Windows name of the font. 00806 The style parameter contains none, one or both of the flags 00807 ATM_ITALIC and ATM_BOLD. 00808 The lpMetricsFile contains the full pathname to the .pfm file 00809 for the font. 00810 The lpFontFile contains the full pathname to the .pfb file for 00811 the font. 00812 Outputs: - 00813 Returns: Successful return values are: 00814 ATM_NOERR 00815 00816 Failure return values are: 00817 ATM_INVALIDFONT Invalid font format. 00818 ATM_PATHTOOLONG At least one path is too long. 00819 ATM_BADFONTTYPE The font is uncompressed. 00820 ATM_BADSTYLE The style parameter has bad bits! 00821 ATM_NOROOM Can't add to internal tables. 00822 ATM_NOFONT At least one path doesn't point to 00823 the correct file. 00824 ATM_BADMENUNAME Missing or invalid menu name given. 00825 ATM_FONTINUSE The paths and menu name specify an 00826 existing font which is in use by ATM. 00827 00828 Purpose: This routine makes a newly installed font available to ATM. 00829 00830 ********************************************************************************************/ 00831 00832 INT32 ATMFontMan::AddFont(TCHAR *pMenuName, WORD Style, TCHAR *lpMetricsFile, TCHAR *lpFontFile) 00833 { 00834 // Are we on Windows 95 and hence require the thunking DLL? 00835 // This should be the default case 00836 if (UseThunking) 00837 { 00838 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00839 // if our DLL is not up then return FALSE. 00840 if (!hLib) 00841 return ATM_NOTRUNNING; 00842 00843 // If we haven't got the correct version then we cannot call it. 00844 if (!CorrectVersion(MinVer_AddFont)) 00845 return ATM_NOTSUPPORTED; 00846 00847 // do some dynamic linking to the DLL 00848 if (pfnXSATMAddFont == NULL) 00849 return ATM_NOTRUNNING; 00850 00851 return (INT32) ((INT8) ( (*pfnXSATMAddFont)(pMenuName, Style, lpMetricsFile, lpFontFile) )); 00852 } 00853 00854 // We must be on NT where we have a real DLL 00855 if (pfnATMAddFont == NULL) 00856 return ATM_NOTRUNNING; 00857 00858 return (INT32) ((INT8) ( (*pfnATMAddFont)(pMenuName, Style, lpMetricsFile, lpFontFile) )); 00859 } 00860 00861 00862 00863 00864 00865 /******************************************************************************************** 00866 00867 > static INT32 ATMFontMan::RemoveFont(TCHAR *pMenuName, WORD Style) 00868 00869 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00870 Created: 01/9/95 00871 Inputs: The lpMenuName contains the Windows name of the font. 00872 The style parameter contains none, one or both of the flags 00873 ATM_ITALIC and ATM_BOLD. 00874 Outputs: - 00875 Returns: Successful return values are: 00876 ATM_NOERR 00877 00878 Failure return values are: 00879 ATM_BADSTYLE The style parameter has bad bits! 00880 ATM_NOFONT The specified font is not available. 00881 ATM_BADMENUNAME Missing or invalid menu name given. 00882 00883 Purpose: This call makes a font inaccessible to ATM. Any subsequent 00884 requests to ATM for this font will fail. 00885 00886 ********************************************************************************************/ 00887 00888 INT32 ATMFontMan::RemoveFont(TCHAR *pMenuName, WORD Style) 00889 { 00890 // Are we on Windows 95 and hence require the thunking DLL? 00891 // This should be the default case 00892 if (UseThunking) 00893 { 00894 const HINSTANCE hLib = ExtraDLLs[ ATM_Util_DLL ]; 00895 // if our DLL is not up then return FALSE. 00896 if (!hLib) 00897 return ATM_NOTRUNNING; 00898 00899 // If we haven't got the correct version then we cannot call it. 00900 if (!CorrectVersion(MinVer_RemoveFont)) 00901 return ATM_NOTSUPPORTED; 00902 00903 // do some dynamic linking to the DLL 00904 if (pfnXSATMRemoveFont == NULL) 00905 return ATM_NOTRUNNING; 00906 00907 return (INT32)((INT8)(*pfnXSATMRemoveFont)(pMenuName, Style)); 00908 } 00909 00910 // We must be on NT where we have a real DLL 00911 if (pfnATMRemoveFont == NULL) 00912 return ATM_NOTRUNNING; 00913 00914 return (INT32)((INT8)(*pfnATMRemoveFont)(pMenuName, Style)); 00915 } 00916 00917 00918 00919 /******************************************************************************************** 00920 00921 > static BOOL ATMFontMan::GetCharOutline(CharDescription& ChDesc, 00922 DocCoord** ppCoords, 00923 PathVerb** ppVerbs, 00924 UINT32* pNumCoords, 00925 CDC* pDC) 00926 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 00927 Created: 28/9/95 00928 Inputs: ChDesc = description of char 00929 pDC = (possible) pointer to a DC (for optimisation) defaults to NULL 00930 Outputs: ppCoords = pointer to path coords buffer 00931 ppVerbs = pointer to path verbs buffer 00932 pNumCoords = number of elements in path 00933 Returns: FALSE if unable to generate the character outline 00934 Purpose: Get the path associated with a given character 00935 00936 ********************************************************************************************/ 00937 00938 BOOL ATMFontMan::GetCharOutline(CharDescription& ChDesc, 00939 DocCoord** ppCoords, 00940 PathVerb** ppVerbs, 00941 UINT32* pNumCoords, 00942 CDC* pDC) 00943 { 00944 LPFNMYMOVETO lpMyMoveTo = NULL; 00945 LPFNMYLINETO lpMyLineTo = NULL; 00946 LPFNMYCURVETO lpMyCurveTo = NULL; 00947 LPFNMYCLOSEPATH lpMyClosePath = NULL; 00948 00949 ATMFixedMatrix tMatrix = { ATMINTTOFIXED(1),0,0,ATMINTTOFIXED(1),0,0 }; 00950 INT32 result; 00951 char renderchar; 00952 WCHAR wchar; 00953 CFont hFont, *pOldFont; 00954 LOGFONT CharLogFont; 00955 BOOL LocalDC=FALSE; 00956 00957 // Check some input parameters 00958 ERROR2IF(ppCoords==NULL,FALSE,"ATMFontMan::GetCharOutline pCoords==NULL"); 00959 ERROR2IF(ppVerbs==NULL,FALSE,"ATMFontMan::GetCharOutline ppVerbs==NULL"); 00960 ERROR2IF(pNumCoords==NULL,FALSE,"ATMFontMan::GetCharOutline pNumCoords==NULL"); 00961 00962 // Check we can call the ATM first 00963 const HINSTANCE hLib = GetATMDLL(); 00964 if (!hLib) 00965 return FALSE; 00966 00967 // Do we need to create a local DC? 00968 LocalDC=(pDC==NULL); 00969 if (LocalDC) 00970 { 00971 pDC=new CDC; 00972 ERROR2IF(pDC==NULL,FALSE,"ATMFontMan::GetCharOutline() - failed to create DC"); 00973 if (pDC->CreateCompatibleDC(NULL)==FALSE) 00974 { 00975 delete pDC; 00976 pDC=NULL; 00977 ERROR2(FALSE,"ATMFontMan::GetCharOutline() - CreateCompatibleDC() failed"); 00978 } 00979 } 00980 00981 // get the character to render. 00982 // we limit the character if we are trying to get a unicode char as ATM GetOutline 00983 // takes a char. This happens to be a signed which is a bit rampant but it seems 00984 // ATM can cope with -97 given as a character code and maps it correctly 00985 wchar = ChDesc.GetCharCode(); 00986 renderchar = (char)(UnicodeManager::UnicodeToMultiByte(wchar)); 00987 00988 // fill the log font description 00989 if (!TextManager::GetLogFontFromCharDescriptor(pDC, ChDesc, &CharLogFont)) 00990 goto OutlineError; 00991 00992 // Values from ATM docs (Jonathan 10/2000) 00993 CharLogFont.lfHeight = -1; 00994 CharLogFont.lfWidth = 0; 00995 CharLogFont.lfEscapement = 0; 00996 00997 // now stick it in our CFont object 00998 if (!hFont.CreateFontIndirect(&CharLogFont)) 00999 goto OutlineError; 01000 01001 // Select the font into the CDC 01002 pOldFont = pDC->SelectObject(&hFont); 01003 if (pOldFont==NULL) 01004 goto OutlineError; 01005 01006 // Make Proc instances 01007 lpMyMoveTo = MakeProcInstance(ATMFontMan::MyMoveTo, AppInst); 01008 lpMyLineTo = MakeProcInstance(ATMFontMan::MyLineTo, AppInst); 01009 lpMyCurveTo = MakeProcInstance(ATMFontMan::MyCurveTo, AppInst); 01010 lpMyClosePath = MakeProcInstance(ATMFontMan::MyClosePath, AppInst); 01011 01012 // Set our path cache to 0 01013 OILFontMan::InitialiseOutlineCache(); 01014 01015 // Are we on Windows 95 and hence require the thunking DLL? 01016 // This should be the default case 01017 if (UseThunking) 01018 { 01019 if (pfnXSATMGetOutline) 01020 result = (*pfnXSATMGetOutline)( pDC->GetSafeHdc(), 01021 renderchar, 01022 &tMatrix, 01023 lpMyMoveTo, 01024 lpMyLineTo, 01025 lpMyCurveTo, 01026 lpMyClosePath, 01027 NULL); 01028 } 01029 else 01030 { 01031 if (pfnATMGetOutline) 01032 result = (*pfnATMGetOutline)( pDC->GetSafeHdc(), 01033 renderchar, 01034 &tMatrix, 01035 lpMyMoveTo, 01036 lpMyLineTo, 01037 lpMyCurveTo, 01038 lpMyClosePath, 01039 NULL); 01040 } 01041 01042 /* 01043 switch (result) 01044 { 01045 case ATM_NOERR: TRACE( _T("Normal return\n")); break; 01046 case ATM_INVALIDFONT: TRACE( _T("Font not consistent\n")); break; 01047 case ATM_CANTHAPPEN: TRACE( _T("Some kind of internal error\n")); break; 01048 case ATM_BADMATRIX: TRACE( _T("Matrix inverse undefined\n")); break; 01049 case ATM_MEMORY: TRACE( _T("Out of memory\n")); break; 01050 case ATM_NOTSUPPORTED: TRACE( _T("Running ATM does not support this call\n")); break; 01051 case ATM_NOTRUNNING: TRACE( _T("ATM is not running\n")); break; 01052 case ATM_FILLORDER: TRACE( _T("Inconsitent fill calls\n")); break; 01053 case ATM_CANCELLED: TRACE( _T("Client halted operation\n")); break; 01054 case ATM_NOCHAR: TRACE( _T("No outline for char code in font\n")); break; 01055 case ATM_BADPROC: TRACE( _T("Bad callback proc address\n")); break; 01056 case ATM_CANTDRAW: TRACE( _T("Error in imaging a bad rop?\n")); break; 01057 case ATM_BADPARM: TRACE( _T("Bad parameter passed in\n")); break; 01058 case ATM_SELECTED: TRACE( _T("See ATMSelectObject\n")); break; 01059 case ATM_SELECTERROR: TRACE( _T("See ATMSelectObject\n")); break; 01060 default: TRACE( _T("ATM call returned unknown error result\n")); break; 01061 } 01062 */ 01063 01064 01065 // Matt 5/12/2000 01066 // Temporary Bodge-Fix for ATM Fonts Problem... 01067 // If the result of the font outline caching is 'Cancelled' then we change it to 'NoErr' and remove the 01068 // dodgy cache info for this character... 01069 // On some configurations of WinNT4 with ATM4 Deluxe, entering the 'Space' (UNICODE 32) 01070 // character causes it to throw this 'cancelled' error... THIS IS INTENDED AS A TEMPORARY FIX 01071 // UNTIL WE FIND THE REAL PROBLEM!!! 01072 if (result == ATM_CANCELLED) 01073 { 01074 result = ATM_NOERR; 01075 OILFontMan::InitialiseOutlineCache(); 01076 } 01077 01078 01079 01080 pDC->SelectObject(pOldFont); 01081 01082 // delete any allocated dc 01083 if (LocalDC && pDC!=NULL) 01084 { 01085 delete pDC; 01086 pDC=NULL; 01087 } 01088 01089 // Tell our path cache its all over 01090 OILFontMan::FinaliseOutlineCache(); 01091 01092 // return the resulting array details. 01093 if (result==0) 01094 { 01095 (*pNumCoords) = OILFontMan::GetOutlineCache(ppCoords,ppVerbs); 01096 } 01097 01098 return (result==0); 01099 01100 OutlineError: 01101 if (LocalDC && pDC!=NULL) 01102 delete pDC; 01103 return FALSE; 01104 } 01105 01106 01107 01108 01109 /******************************************************************************************** 01110 01111 > static INT32 ATMFontMan::InstallFont(TCHAR *pMenuName, WORD Style, TCHAR *lpMetricsFile, TCHAR *lpFontFile) 01112 01113 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 01114 Created: 28/9/95 01115 Purpose: See ATMFontMan::AddFont for details 01116 01117 ********************************************************************************************/ 01118 01119 INT32 ATMFontMan::InstallFont(TCHAR *pMenuName, WORD Style, TCHAR *lpMetricsFile, TCHAR *lpFontFile) 01120 { 01121 INT32 err = BeginFontChange(); 01122 01123 if (err==ATM_NOERR) 01124 err = AddFont(pMenuName, Style, lpMetricsFile, lpFontFile); 01125 01126 EndFontChange(); 01127 01128 return err; 01129 } 01130 01131 01132 /******************************************************************************************** 01133 01134 > INT32 ATMFontMan::DeInstallFont(TCHAR *pMenuName, WORD Style) 01135 01136 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 01137 Created: 28/9/95 01138 Purpose: See ATMFontMan::RemoveFont for details 01139 01140 ********************************************************************************************/ 01141 01142 INT32 ATMFontMan::DeInstallFont(TCHAR *pMenuName, WORD Style) 01143 { 01144 INT32 err = BeginFontChange(); 01145 01146 if (err==ATM_NOERR) 01147 err = RemoveFont(pMenuName, Style); 01148 01149 EndFontChange(); 01150 01151 return err; 01152 } 01153 01154 01156 // the call back functions to handle input coordinates 01158 01159 BOOL FAR PASCAL EXPORT ATMFontMan::MyClosePath(LPSTR lpData) 01160 { 01161 return OILFontMan::ClosePath(); 01162 } 01163 01164 BOOL FAR PASCAL EXPORT ATMFontMan::MyMoveTo(LPATMFixedPoint lpFixPnt, LPSTR lpData) 01165 { 01166 POINT p; 01167 p.x = SCALEORD(lpFixPnt->x); 01168 p.y = SCALEORD(lpFixPnt->y); 01169 return OILFontMan::AddMoveTo(p); 01170 } 01171 01172 BOOL FAR PASCAL EXPORT ATMFontMan::MyLineTo(LPATMFixedPoint lpFixPnt, LPSTR lpData) 01173 { 01174 POINT p; 01175 p.x = SCALEORD(lpFixPnt->x); 01176 p.y = SCALEORD(lpFixPnt->y); 01177 return OILFontMan::AddLineTo(p); 01178 } 01179 01180 BOOL FAR PASCAL EXPORT ATMFontMan::MyCurveTo(LPATMFixedPoint lpFixPnt1, 01181 LPATMFixedPoint lpFixPnt2, 01182 LPATMFixedPoint lpFixPnt3, 01183 LPSTR lpData) 01184 { 01185 POINT p0,p1,p2; 01186 p0.x = SCALEORD(lpFixPnt1->x); 01187 p0.y = SCALEORD(lpFixPnt1->y); 01188 p1.x = SCALEORD(lpFixPnt2->x); 01189 p1.y = SCALEORD(lpFixPnt2->y); 01190 p2.x = SCALEORD(lpFixPnt3->x); 01191 p2.y = SCALEORD(lpFixPnt3->y); 01192 return OILFontMan::AddBezierTo(p0,p1,p2); 01193 } 01194 01195 /******************************************************************************************** 01196 01197 > INT32 APIENTRY ATMFontMan_CallBackCacheNamedFont( 01198 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01199 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01200 INT32 FontType, // type of font 01201 LPARAM lParam // address of application-defined data 01202 01203 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 01204 Created: 12/9/95 01205 Purpose: The call back function providing all font data 01206 01207 ********************************************************************************************/ 01208 01209 INT32 APIENTRY ATMFontMan_CallBackCacheNamedFont( 01210 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01211 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01212 INT32 FontType, // type of font 01213 LPARAM lParam // address of application-defined data 01214 ) 01215 { 01216 UNREFERENCED_PARAMETER (lpntm); 01217 01218 if (FontType & DEVICE_FONTTYPE) 01219 { 01220 String_64 FontName(lpelf->elfLogFont.lfFaceName); 01221 01222 if (lParam==NULL || (_tcsncicmp(FontName, *((String_64 * )lParam), 64) == 0)) 01223 { 01224 FontManager* pFontMan = GetApplication()->GetFontManager(); 01225 pFontMan->SetTempFont(FC_ATM, &FontName, lpelf); 01226 return FALSE; 01227 } 01228 } 01229 return TRUE; 01230 } 01231 01232 /******************************************************************************************** 01233 01234 > INT32 APIENTRY ATMFontMan_CallBackValidateFont( 01235 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01236 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01237 INT32 FontType, // type of font 01238 LPARAM lParam // address of application-defined data 01239 01240 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 01241 Created: 12/9/95 01242 Purpose: The call back function providing all font data 01243 01244 ********************************************************************************************/ 01245 01246 INT32 APIENTRY ATMFontMan_CallBackValidateFont( 01247 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01248 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01249 INT32 FontType, // type of font 01250 LPARAM lParam // address of application-defined data 01251 ) 01252 { 01253 UNREFERENCED_PARAMETER (lpntm); 01254 01255 if (FontType & DEVICE_FONTTYPE) 01256 { 01257 String_64 FontName(lpelf->elfLogFont.lfFaceName); 01258 01259 FontManager* pFontMan = GetApplication()->GetFontManager(); 01260 pFontMan->ValidateItem(FC_ATM, &FontName, lpelf); 01261 } 01262 return TRUE; 01263 } 01264 01265 /******************************************************************************************** 01266 01267 > INT32 APIENTRY ATMFontMan_CallBackFindClosestFont( 01268 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01269 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01270 INT32 FontType, // type of font 01271 LPARAM lParam // address of application-defined data 01272 01273 Author: Andy_Hayward (Xara Group Ltd) <camelotdev@xara.com> 01274 Created: 20/08/96 01275 Purpose: The call back function for searching for a match to a panose number 01276 01277 ********************************************************************************************/ 01278 01279 INT32 APIENTRY ATMFontMan_CallBackFindClosestFont( 01280 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01281 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01282 INT32 FontType, // type of font 01283 LPARAM lParam // address of application-defined data 01284 ) 01285 { 01286 UNREFERENCED_PARAMETER (lpntm); 01287 01288 if (FontType & DEVICE_FONTTYPE) 01289 { 01290 String_64 FontName(lpelf->elfLogFont.lfFaceName); 01291 01292 FontManager* pFontMan = GetApplication()->GetFontManager(); 01293 return pFontMan->FindClosestFontFullTry(FC_ATM, &FontName, lpelf); 01294 } 01295 01296 return TRUE; 01297 } 01298 01299 /******************************************************************************************** 01300 01301 > INT32 APIENTRY ATMFontMan_CallBackDispatchFont( 01302 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01303 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01304 INT32 FontType, // type of font 01305 LPARAM lParam // address of application-defined data 01306 01307 Author: Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com> 01308 Created: 12/9/95 01309 Purpose: The call back function providing all font data 01310 01311 ********************************************************************************************/ 01312 01313 INT32 APIENTRY ATMFontMan_CallBackDispatchFont( 01314 ENUMLOGFONT FAR* lpelf, // address of logical-font data 01315 NEWTEXTMETRIC FAR* lpntm, // address of physical-font data 01316 INT32 FontType, // type of font 01317 LPARAM lParam // address of application-defined data 01318 ) 01319 { 01320 UNREFERENCED_PARAMETER (lpntm); 01321 if (FontType & DEVICE_FONTTYPE) 01322 { 01323 // Hide aliases... 01324 if(!ATMInstall::IsFontAlias(lpelf->elfLogFont.lfFaceName)) 01325 { 01326 return ((OILEnumFonts*)lParam)->NewFont(FC_ATM, lpelf); 01327 } 01328 } 01329 return TRUE; 01330 } 01331 01332 01333 /******************************************************************************************** 01335 ********************************************************************************************/ 01336 01337 /******************************************************************************************** 01338 01339 > static BOOL ATMFontMan::InitLib() 01340 01341 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 01342 Created: 07/10/97 01343 Inputs: - 01344 Outputs: 01345 Returns: TRUE if the proper ATM library is actually running and can be used on this OpSys 01346 Purpose: Determine whether we can make further calls to the Adobe Type Manager 01347 Notes: Implemented for the ATM for Windows NT4 01348 01349 ********************************************************************************************/ 01350 01351 BOOL ATMFontMan::InitLib() 01352 { 01353 if (!ATMRunning) 01354 ATMRunning = (LibProperlyLoaded() > 0); 01355 01356 if (ATMRunning) 01357 { 01358 ATMVersion = LibGetVersion(); 01359 ATMUtilVersion = 0; // ThunkGetUtilVersion(); 01360 01361 UseThunking = FALSE; 01362 } 01363 01364 return ATMRunning; 01365 } 01366 01367 /******************************************************************************************** 01368 01369 > INT32 ATMFontMan::LibProperlyLoaded() 01370 01371 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 01372 Created: 07/10/97 01373 Inputs: - 01374 Outputs: 01375 Returns: >0 if the ATM manager is actually running and can be used on this OpSys 01376 Purpose: Determine whether we can make further calls to the Adobe Type Manager 01377 This call has been in the ATM from version 1.00 so there's no need to check 01378 it. 01379 01380 ********************************************************************************************/ 01381 01382 INT32 ATMFontMan::LibProperlyLoaded() 01383 { 01384 // Try and set up the dynamic links to the AtmLib dll. 01385 LPSTR LibName = "AtmLib.DLL"; 01386 DLLHandle = LoadLibrary(LibName); 01387 if (DLLHandle == NULL) 01388 { 01389 return FALSE; 01390 } 01391 01392 // extract the function pointers that we require 01393 pfnATMProperlyLoaded = (PFN_ATMProperlyLoaded) GetProcAddress( DLLHandle, "ATMProperlyLoaded"); 01394 pfnATMGetVersion = (PFN_ATMGetVersion) GetProcAddress( DLLHandle, "ATMGetVersion"); 01395 pfnATMGetOutline = (PFN_ATMGetOutline) GetProcAddress( DLLHandle, "ATMGetOutlineA"); 01396 pfnATMForceExactWidth = (PFN_ATMForceExactWidth) GetProcAddress( DLLHandle, "ATMForceExactWidth"); 01397 pfnATMBeginFontChange = (PFN_ATMBeginFontChange) GetProcAddress( DLLHandle, "ATMBeginFontChange"); 01398 pfnATMEndFontChange = (PFN_ATMEndFontChange) GetProcAddress( DLLHandle, "ATMEndFontChange"); 01399 pfnATMForceFontChange = (PFN_ATMForceFontChange) GetProcAddress( DLLHandle, "ATMForceFontChange"); 01400 pfnATMFontStatus = (PFN_ATMFontStatus) GetProcAddress( DLLHandle, "ATMFontStatusA"); 01401 pfnATMAddFont = (PFN_ATMAddFont) GetProcAddress( DLLHandle, "ATMAddFontA"); 01402 pfnATMRemoveFont = (PFN_ATMRemoveFont) GetProcAddress( DLLHandle, "ATMRemoveFontA"); 01403 01404 // If we had a problem then unload the DLL and say so 01405 if (pfnATMProperlyLoaded == NULL || 01406 pfnATMGetVersion == NULL || 01407 pfnATMGetOutline == NULL || 01408 // pfnATMForceExactWidth == NULL || 01409 pfnATMBeginFontChange == NULL || 01410 pfnATMEndFontChange == NULL || 01411 pfnATMForceFontChange == NULL || 01412 pfnATMFontStatus == NULL || 01413 pfnATMAddFont == NULL || 01414 pfnATMRemoveFont == NULL 01415 ) 01416 { 01417 FreeLibrary(DLLHandle); // remove DLL as no longer required 01418 DLLHandle = NULL; 01419 return FALSE; 01420 } 01421 01422 // Otherwise, check that the DLL thinks that everything is ok 01423 INT32 result = (INT32)(*pfnATMProperlyLoaded)(); 01424 return result; 01425 } 01426 01427 /******************************************************************************************** 01428 01429 > static INT32 ATMFontMan::LibGetVersion() 01430 01431 Author: Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com> 01432 Created: 07/10/97 01433 Inputs: None 01434 Outputs: None 01435 Returns: High byte major version, low byte minor version 01436 Purpose: The version number of the currently running ATM. 01437 01438 ********************************************************************************************/ 01439 01440 INT32 ATMFontMan::LibGetVersion() 01441 { 01442 if (pfnATMGetVersion == NULL) 01443 { 01444 return FALSE; 01445 } 01446 01447 INT32 result = (INT32)(*pfnATMGetVersion)(); 01448 01449 return result; 01450 }