Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

776 lines
24 KiB

  1. /***********************************************************************************
  2. * Module Name: fntassoc.cxx
  3. *
  4. * Font association routines.
  5. *
  6. * History
  7. *
  8. * 4-8-96 Gerrit van Wingerden Moved code from flinkgdi.cxx
  9. *
  10. * Copyright (c) 1996-1999 Microsoft Corporation
  11. **********************************************************************************/
  12. #include "precomp.hxx"
  13. #ifdef FE_SB
  14. #define FONT_ASSOCIATION_CHARSET_KEY \
  15. L"FontAssoc\\Associated CharSet"
  16. #define FONT_ASSOCIATION_DEFAULT_KEY \
  17. L"FontAssoc\\Associated DefaultFonts"
  18. #define FONT_ASSOCIATION_FONTS_KEY \
  19. L"FontAssoc\\Associated Fonts"
  20. // Font Association configuration value
  21. UINT fFontAssocStatus = 0x0;
  22. //
  23. // Fontfile path for AssocSystemFont in
  24. // KEY : HKL\\SYSTEM\\CurrentControlSet\\Control\\FontAssoc\\Associated DefaultFonts
  25. // VALUE : AssocSystemFont
  26. //
  27. // This font is loaded at system initialization stage. and will be used to provide
  28. // DBCS glyphs for System/Terminal/FixedSys/... This font should have all glyphs that
  29. // will be used on current system locale
  30. //
  31. // This hehavior is described in ...
  32. // "Font Association for Far East implementation for Windows 95"
  33. // Revision : 1.02
  34. // Author : WJPark,ShusukeU.
  35. //
  36. // Holds the path of the font the font used to provide glyphs to system,terminal,
  37. // and fixedsys fonts.
  38. WCHAR gawcSystemDBCSFontPath[MAX_PATH];
  39. // Identifies the facename to use for DBCS glyphs. This value comes out of the
  40. // "FontPackage" value in AssociatedDefaultFonts key
  41. static WCHAR gawcSystemDBCSFontFaceName[LF_FACESIZE+1];
  42. // Holds the pfe's (vertical and non-vertical) for the system DBCS font face name
  43. PFE *gappfeSystemDBCS[2] = { PPFENULL , PPFENULL };
  44. // set to TRUE if SystemDBCS font is enabled.
  45. BOOL gbSystemDBCSFontEnabled = FALSE;
  46. //
  47. // Font association default link initialization value.
  48. //
  49. // This value never be TRUE, if FontAssociation features are disabled.
  50. // And this value will be TRUE, if we suceed to read "Associated DefaultFonts"
  51. // key and fill up FontAssocDefaultTable.
  52. //
  53. BOOL bReadyToInitializeFontAssocDefault = FALSE;
  54. //
  55. // This value never be TRUE, if FontAssociation features are disabled.
  56. // And this value also never be TRUE, no-user logged-on this window station.
  57. // This value become TRUE at first time that GreEnableEUDC() is called.
  58. // and this value is turned off when user logout.
  59. //
  60. BOOL bFinallyInitializeFontAssocDefault = FALSE;
  61. //
  62. // Font Association default link configuration table
  63. //
  64. #define NUMBER_OF_FONTASSOC_DEFAULT 7
  65. #define FF_DEFAULT 0xFF
  66. FONT_DEFAULTASSOC FontAssocDefaultTable[NUMBER_OF_FONTASSOC_DEFAULT] = {
  67. {FALSE, FF_DONTCARE, L"FontPackageDontCare", L"\0", L"\0", {PPFENULL,PPFENULL}},
  68. {FALSE, FF_ROMAN, L"FontPackageRoman", L"\0", L"\0" , {PPFENULL,PPFENULL}},
  69. {FALSE, FF_SWISS, L"FontPackageSwiss", L"\0", L"\0", {PPFENULL,PPFENULL}},
  70. {FALSE, FF_MODERN, L"FontPackageModern", L"\0", L"\0", {PPFENULL,PPFENULL}},
  71. {FALSE, FF_SCRIPT, L"FontPackageScript", L"\0", L"\0", {PPFENULL,PPFENULL}},
  72. {FALSE, FF_DECORATIVE, L"FontPackageDecorative", L"\0", L"\0", {PPFENULL,PPFENULL}},
  73. {FALSE, FF_DEFAULT, L"FontPackage", L"\0", L"\0", {PPFENULL,PPFENULL}}
  74. };
  75. // Is font association substitition turned on?
  76. static BOOL bEnableFontAssocSubstitutes = FALSE;
  77. // Pointer to Substitution table for font association.
  78. static ULONG ulNumFontAssocSubs = 0L;
  79. PFONT_ASSOC_SUB pFontAssocSubs = (PFONT_ASSOC_SUB) NULL;
  80. // definition is in flinkgdi.cxx
  81. extern RTL_QUERY_REGISTRY_TABLE SharedQueryTable[2];
  82. extern BOOL bAppendSysDirectory( WCHAR *pwcTarget, const WCHAR *pwcSource, UINT cchBufferSize );
  83. extern BOOL bComputeQuickLookup(QUICKLOOKUP *pql, PFE *pPFE, BOOL bSystemEUDC);
  84. /******************************Public*Routine******************************\
  85. * NTSTATUS CountRegistryEntryCoutine(PWSTR,ULONG,PVOID,ULONG,PVOID,PVOID)
  86. *
  87. * History:
  88. * 19-Jan-1996 -by- Hideyuki Nagase [hideyukn]
  89. * Wrote it.
  90. \**************************************************************************/
  91. extern "C"
  92. NTSTATUS
  93. CountRegistryEntryRoutine
  94. (
  95. PWSTR ValueName,
  96. ULONG ValueType,
  97. PVOID ValueData,
  98. ULONG ValueLength,
  99. PVOID Context,
  100. PVOID EntryContext
  101. )
  102. {
  103. (*(ULONG *)EntryContext) += 1L;
  104. return( STATUS_SUCCESS );
  105. }
  106. /******************************Public*Routine******************************\
  107. * NTSTATUS FontAssocCharsetRoutine(PWSTR,ULONG,PVOID,ULONG,PVOID,PVOID)
  108. *
  109. * History:
  110. * 28-Aug-1995 -by- Hideyuki Nagase [hideyukn]
  111. * Wrote it.
  112. \**************************************************************************/
  113. extern "C"
  114. NTSTATUS
  115. FontAssocCharsetRoutine
  116. (
  117. PWSTR ValueName,
  118. ULONG ValueType,
  119. PVOID ValueData,
  120. ULONG ValueLength,
  121. PVOID Context,
  122. PVOID EntryContext
  123. )
  124. {
  125. //
  126. // Only process follows if the data value is "YES"
  127. //
  128. if( _wcsicmp((LPWSTR) ValueData, L"YES" ) == 0)
  129. {
  130. //
  131. // Check ANSI charset association is enabled
  132. //
  133. if( _wcsicmp(ValueName, L"ANSI(00)") == 0)
  134. {
  135. #if DBG
  136. DbgPrint("GDISRV:FONTASSOC CHARSET:Enable ANSI association\n");
  137. #endif
  138. fFontAssocStatus |= ANSI_ASSOC;
  139. return(STATUS_SUCCESS);
  140. }
  141. //
  142. // Check SYMBOL charset association is enabled
  143. //
  144. else if( _wcsicmp(ValueName, L"SYMBOL(02)") == 0)
  145. {
  146. #if DBG
  147. DbgPrint("GDISRV:FONTASSOC CHARSET:Enable SYMBOL association\n");
  148. #endif
  149. fFontAssocStatus |= SYMBOL_ASSOC;
  150. return(STATUS_SUCCESS);
  151. }
  152. //
  153. // Check OEM charset association is enabled
  154. //
  155. else if( _wcsicmp(ValueName, L"OEM(FF)") == 0)
  156. {
  157. #if DBG
  158. DbgPrint("GDISRV:FONTASSOC CHARSET:Enable OEM association\n");
  159. #endif
  160. fFontAssocStatus |= OEM_ASSOC;
  161. return(STATUS_SUCCESS);
  162. }
  163. }
  164. //
  165. // return STATUS_SUCCESS everytime,even we got error from above call, to
  166. // get next enumuration.
  167. //
  168. return(STATUS_SUCCESS);
  169. }
  170. /******************************Public*Routine******************************\
  171. * NTSTATUS FontAssocDefaultRoutine(PWSTR,ULONG,PVOID,ULONG,PVOID,PVOID)
  172. *
  173. * History:
  174. * 14-Jan-1996 -by- Hideyuki Nagase [hideyukn]
  175. * Wrote it.
  176. \**************************************************************************/
  177. extern "C"
  178. NTSTATUS
  179. FontAssocDefaultRoutine
  180. (
  181. PWSTR ValueName,
  182. ULONG ValueType,
  183. PVOID ValueData,
  184. ULONG ValueLength,
  185. PVOID Context,
  186. PVOID EntryContext
  187. )
  188. {
  189. UINT iIndex;
  190. if(_wcsicmp(ValueName,L"AssocSystemFont") == 0)
  191. {
  192. bAppendSysDirectory(gawcSystemDBCSFontPath,(const WCHAR *)ValueData, MAX_PATH);
  193. return(STATUS_SUCCESS);
  194. }
  195. else
  196. if(_wcsicmp(ValueName,L"FontPackage") == 0)
  197. {
  198. cCapString(gawcSystemDBCSFontFaceName,(const WCHAR*)ValueData,LF_FACESIZE);
  199. return(STATUS_SUCCESS);
  200. }
  201. for( iIndex = 0; iIndex < NUMBER_OF_FONTASSOC_DEFAULT; iIndex++ )
  202. {
  203. if(_wcsicmp(ValueName,
  204. FontAssocDefaultTable[iIndex].DefaultFontTypeID) == 0)
  205. {
  206. // Check if the registry has some data.
  207. if( *(LPWSTR)ValueData != L'\0' )
  208. {
  209. if (FAILED(StringCchCopyW(FontAssocDefaultTable[iIndex].DefaultFontFaceName, LF_FACESIZE+1, (const WCHAR *)ValueData)))
  210. {
  211. WARNING("FontAssocDefaultRoutine: not enough space in DefaultFontFaceName buffer\n");
  212. return STATUS_SUCCESS;
  213. }
  214. FontAssocDefaultTable[iIndex].ValidRegData = TRUE;
  215. #if DBG
  216. DbgPrint("GDISRV:FONTASSOC DEFAULT:%ws -> %ws\n",
  217. FontAssocDefaultTable[iIndex].DefaultFontTypeID,
  218. FontAssocDefaultTable[iIndex].DefaultFontFaceName);
  219. #endif
  220. }
  221. return(STATUS_SUCCESS);
  222. }
  223. }
  224. #if DBG
  225. DbgPrint("GDISRV:FONTASSOC DEFAULT:%ws is invalid registry key\n",(LPWSTR)ValueName);
  226. #endif
  227. //
  228. // return STATUS_SUCCESS everytime,even we got error to do next enumuration.
  229. //
  230. return(STATUS_SUCCESS);
  231. }
  232. /******************************Public*Routine******************************\
  233. * NTSTATUS FontAssocFontsRoutine(PWSTR,ULONG,PVOID,ULONG,PVOID,PVOID)
  234. *
  235. * History:
  236. * 19-Jan-1996 -by- Hideyuki Nagase [hideyukn]
  237. * Wrote it.
  238. \**************************************************************************/
  239. extern "C"
  240. NTSTATUS
  241. FontAssocFontsRoutine
  242. (
  243. PWSTR ValueName,
  244. ULONG ValueType,
  245. PVOID ValueData,
  246. ULONG ValueLength,
  247. PVOID Context,
  248. PVOID EntryContext
  249. )
  250. {
  251. UINT iIndex = (*(UINT *)EntryContext);
  252. PFONT_ASSOC_SUB pfas = pFontAssocSubs + iIndex;
  253. ASSERTGDI(iIndex < ulNumFontAssocSubs,
  254. "GDIOSRV:FONTASSOC iIndex >= ulNumFontAssocSubs\n");
  255. //
  256. // Copy the registry data to local buffer..
  257. //
  258. cCapString(pfas->AssociatedName,(const WCHAR*)ValueData,LF_FACESIZE+1);
  259. cCapString(pfas->OriginalName ,ValueName,LF_FACESIZE+1);
  260. #if DBG
  261. pfas->UniqNo = iIndex;
  262. DbgPrint("GDISRV:FONTASSOC FontSubs %d %ws -> %ws\n",iIndex,
  263. pfas->OriginalName,
  264. pfas->AssociatedName);
  265. #endif
  266. //
  267. // for Next entry....
  268. //
  269. (*(UINT *)EntryContext) = ++iIndex;
  270. return (STATUS_SUCCESS);
  271. }
  272. /******************************Public*Routine******************************\
  273. * VOID vInitializeFontAssocStatus()
  274. *
  275. * History:
  276. * 28-Aug-1995 -by- Hideyuki Nagase [hideyukn]
  277. * Wrote it.
  278. \**************************************************************************/
  279. VOID vInitializeFontAssocStatus(VOID)
  280. {
  281. NTSTATUS NtStatus;
  282. // Read Font Association configuration value.
  283. // Initialize "FontAssoc\Association CharSet" related.
  284. SharedQueryTable[0].QueryRoutine = FontAssocCharsetRoutine;
  285. SharedQueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
  286. SharedQueryTable[0].Name = (PWSTR)NULL;
  287. SharedQueryTable[0].EntryContext = (PVOID)NULL;
  288. SharedQueryTable[0].DefaultType = REG_NONE;
  289. SharedQueryTable[0].DefaultData = NULL;
  290. SharedQueryTable[0].DefaultLength = 0;
  291. SharedQueryTable[1].QueryRoutine = NULL;
  292. SharedQueryTable[1].Flags = 0;
  293. SharedQueryTable[1].Name = (PWSTR)NULL;
  294. fFontAssocStatus = 0;
  295. gawcSystemDBCSFontPath[0] = L'\0';
  296. // Enumurate registry values
  297. NtStatus = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL|RTL_REGISTRY_OPTIONAL,
  298. FONT_ASSOCIATION_CHARSET_KEY,
  299. SharedQueryTable,
  300. NULL,
  301. NULL);
  302. if(!NT_SUCCESS(NtStatus))
  303. {
  304. WARNING1("GDISRV:FontAssociation is disabled\n");
  305. fFontAssocStatus = 0;
  306. }
  307. gawcSystemDBCSFontFaceName[0] = 0;
  308. // Initialize "FontAssoc\Association DefaultFonts" related.
  309. SharedQueryTable[0].QueryRoutine = FontAssocDefaultRoutine;
  310. // Enumurate registry values
  311. NtStatus = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL|RTL_REGISTRY_OPTIONAL,
  312. FONT_ASSOCIATION_DEFAULT_KEY,
  313. SharedQueryTable,
  314. NULL,
  315. NULL);
  316. if( !NT_SUCCESS(NtStatus) )
  317. {
  318. WARNING1("GDISRV:FontAssociation:Default table is not presented\n");
  319. bReadyToInitializeFontAssocDefault = FALSE;
  320. }
  321. else
  322. {
  323. // We succeeded to read registry and fill up FontAssocDefaultTable.
  324. bReadyToInitializeFontAssocDefault = TRUE;
  325. // try to load the system DBCS font if we detected the appropriate registry
  326. // entries
  327. if(gawcSystemDBCSFontPath[0] && gawcSystemDBCSFontFaceName[0])
  328. {
  329. PUBLIC_PFTOBJ pfto;
  330. LONG cFonts;
  331. EUDCLOAD EudcLoadData;
  332. PFF *placeHolder;
  333. EudcLoadData.pppfeData = gappfeSystemDBCS;
  334. EudcLoadData.LinkedFace = gawcSystemDBCSFontFaceName;
  335. if(pfto.bLoadAFont(gawcSystemDBCSFontPath,
  336. (PULONG) &cFonts,
  337. PFF_STATE_EUDC_FONT,
  338. &placeHolder,
  339. &EudcLoadData ))
  340. {
  341. // initialize quick lookup table if we successfully loaded the font
  342. // this must be NULL for bComputeQuickLookup
  343. gqlTTSystem.puiBits = NULL;
  344. if(bComputeQuickLookup(&gqlTTSystem, gappfeSystemDBCS[PFE_NORMAL], FALSE))
  345. {
  346. // now try the vertical face if one is provided
  347. FLINKMESSAGE2(DEBUG_FONTLINK_INIT,
  348. "Loaded SystemDBCSFont %ws\n",
  349. gawcSystemDBCSFontPath);
  350. gbSystemDBCSFontEnabled = TRUE;
  351. gbAnyLinkedFonts = TRUE;
  352. }
  353. if(!gbSystemDBCSFontEnabled)
  354. {
  355. WARNING("vInitializeFontAssocStatus: error creating \
  356. quick lookup tables for SystemDBCSFont\n");
  357. pfto.bUnloadEUDCFont(gawcSystemDBCSFontPath);
  358. }
  359. }
  360. else
  361. {
  362. WARNING("vInitializeFontAssocStatus: error loading SystemDBCSFont\n");
  363. }
  364. }
  365. }
  366. // Initialize "Font Association\Fonts" related.
  367. bEnableFontAssocSubstitutes = FALSE;
  368. SharedQueryTable[0].QueryRoutine = CountRegistryEntryRoutine;
  369. SharedQueryTable[0].EntryContext = (PVOID)(&ulNumFontAssocSubs);
  370. // Count the number of the registry entries.
  371. // NtStatus = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL|RTL_REGISTRY_OPTIONAL,
  372. // FONT_ASSOCIATION_FONTS_KEY,
  373. // SharedQueryTable,
  374. // NULL,
  375. // NULL);
  376. ulNumFontAssocSubs = 0;
  377. if( NT_SUCCESS(NtStatus) && (ulNumFontAssocSubs != 0) )
  378. {
  379. #if DBG
  380. DbgPrint("GDISRV:FONTASSOC %d FontAssoc Substitution is found\n",
  381. ulNumFontAssocSubs);
  382. #endif
  383. // Allocate lookaside table for fontassociation's substitution.
  384. pFontAssocSubs = (PFONT_ASSOC_SUB)
  385. PALLOCMEM(sizeof(FONT_ASSOC_SUB)*ulNumFontAssocSubs,'flnk');
  386. if( pFontAssocSubs != NULL )
  387. {
  388. UINT iCount = 0; // This will be used as Current Table Index.
  389. SharedQueryTable[0].QueryRoutine = FontAssocFontsRoutine;
  390. SharedQueryTable[0].EntryContext = (PVOID)(&iCount);
  391. NtStatus = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL|RTL_REGISTRY_OPTIONAL,
  392. FONT_ASSOCIATION_FONTS_KEY,
  393. SharedQueryTable,
  394. NULL,
  395. NULL);
  396. if( !NT_SUCCESS(NtStatus) )
  397. {
  398. VFREEMEM( pFontAssocSubs );
  399. ulNumFontAssocSubs = 0L;
  400. }
  401. else
  402. {
  403. bEnableFontAssocSubstitutes = TRUE;
  404. gbAnyLinkedFonts = TRUE;
  405. }
  406. }
  407. else
  408. {
  409. ulNumFontAssocSubs = 0L;
  410. }
  411. }
  412. return;
  413. }
  414. /*****************************************************************************\
  415. * GreGetFontAssocStatus( BOOL bEnable )
  416. *
  417. * History:
  418. * 28-Aug-1995 -by- Hideyuki Nagase [hideyukn]
  419. * Wrote it.
  420. *****************************************************************************/
  421. UINT GreGetFontAssocStatus(VOID)
  422. {
  423. return(fFontAssocStatus);
  424. }
  425. /*****************************************************************************
  426. * BOOL bSetupDefaultFlEntry(BOOL,BOOL,INT)
  427. *
  428. * This function load font and build link for eudc font according to
  429. * the default link table.
  430. *
  431. * History
  432. * 1-15-96 Hideyuki Nagase
  433. * Wrote it.
  434. *****************************************************************************/
  435. BOOL bSetupDefaultFlEntry(VOID)
  436. {
  437. UINT iIndex;
  438. UINT bRet = FALSE;
  439. //
  440. // get and validate PFT user object
  441. //
  442. PUBLIC_PFTOBJ pfto; // access the public font table
  443. ASSERTGDI(
  444. pfto.bValid(),
  445. "gdisrv!bSetupDefaultFlEntry(): could not access the public font table\n"
  446. );
  447. for( iIndex = 0; iIndex < NUMBER_OF_FONTASSOC_DEFAULT; iIndex++ )
  448. {
  449. //
  450. // Check the registry data and fontpath is valid ,and
  451. // this font is not loaded, yet.
  452. //
  453. if( (FontAssocDefaultTable[iIndex].ValidRegData) &&
  454. (FontAssocDefaultTable[iIndex].DefaultFontPathName[0] != L'\0') &&
  455. (FontAssocDefaultTable[iIndex].DefaultFontPFEs[PFE_NORMAL] == PPFENULL) )
  456. {
  457. PPFE appfeLink[2]; // temporary buffer
  458. LONG cFonts; // count of fonts
  459. EUDCLOAD EudcLoadData; // eudc load data
  460. PFF *placeHolder;
  461. PWSZ FontPathName = FontAssocDefaultTable[iIndex].DefaultFontPathName;
  462. //
  463. // Fill up EudcLoadData structure
  464. //
  465. EudcLoadData.pppfeData = appfeLink;
  466. EudcLoadData.LinkedFace = FontAssocDefaultTable[iIndex].DefaultFontFaceName;
  467. //
  468. // Load the linked font.
  469. //
  470. if( pfto.bLoadAFont( FontPathName,
  471. (PULONG) &cFonts,
  472. (PFF_STATE_EUDC_FONT | PFF_STATE_PERMANENT_FONT),
  473. &placeHolder,
  474. &EudcLoadData ) )
  475. {
  476. //
  477. // Check we really succeed to load requested facename font.
  478. //
  479. //
  480. // Compute table for normal face
  481. //
  482. if(!bComputeQuickLookup(NULL, appfeLink[PFE_NORMAL], FALSE ))
  483. {
  484. WARNING("Unable to compute QuickLookUp for default link\n");
  485. //
  486. // Unload the fonts.
  487. //
  488. pfto.bUnloadEUDCFont(FontPathName);
  489. //
  490. // we got error during load, maybe font itself might be invalid,
  491. // just invalidate the pathname the default table.
  492. //
  493. FontAssocDefaultTable[iIndex].DefaultFontPathName[0] = L'\0';
  494. //
  495. // Do next entry in default table.
  496. //
  497. continue;
  498. }
  499. //
  500. // Compute table for vertical face, if vertical face font is provided,
  501. //
  502. if( !bComputeQuickLookup(NULL, appfeLink[PFE_VERTICAL], FALSE ))
  503. {
  504. WARNING("Unable to compute QuickLookUp for default link\n");
  505. // Unload the fonts.
  506. pfto.bUnloadEUDCFont(FontPathName);
  507. // we got error during load, maybe font itself might be invalid,
  508. // just invalidate the pathname the default table.
  509. FontAssocDefaultTable[iIndex].DefaultFontPathName[0] = L'\0';
  510. // Do next entry in default table.
  511. continue;
  512. }
  513. //
  514. // Finally, we keeps the PFEs in default array.
  515. //
  516. FontAssocDefaultTable[iIndex].DefaultFontPFEs[PFE_NORMAL] =
  517. appfeLink[PFE_NORMAL];
  518. FontAssocDefaultTable[iIndex].DefaultFontPFEs[PFE_VERTICAL] =
  519. appfeLink[PFE_VERTICAL];
  520. #if DBG
  521. DbgPrint("GDISRV:FONTASSOC DEFAULT:Load %ws for %ws\n",
  522. FontAssocDefaultTable[iIndex].DefaultFontPathName,
  523. FontAssocDefaultTable[iIndex].DefaultFontTypeID);
  524. #endif
  525. // We can load Associated font.
  526. bRet = TRUE;
  527. }
  528. else
  529. {
  530. #if DBG
  531. DbgPrint("Failed to load default link font. (%ws)\n",FontPathName);
  532. #endif
  533. //
  534. // we got error during load, maybe font itself might be invalid,
  535. // just invalidate the pathname the default table.
  536. //
  537. FontAssocDefaultTable[iIndex].DefaultFontPathName[0] = L'\0';
  538. //
  539. // Make sure the PFEs are invalid.
  540. //
  541. FontAssocDefaultTable[iIndex].DefaultFontPFEs[PFE_NORMAL] = PPFENULL;
  542. FontAssocDefaultTable[iIndex].DefaultFontPFEs[PFE_VERTICAL] = PPFENULL;
  543. }
  544. }
  545. }
  546. return(bRet);
  547. }
  548. /*****************************************************************************
  549. * ULONG NtGdiQueryFontAssocInfo
  550. *
  551. * Shared kernel mode entry point for QueryFontAssocStatus and
  552. * GetFontAssocStatus
  553. *
  554. * History
  555. * 6-12-96 Gerrit van Wingerden [gerritv]
  556. * Wrote it.
  557. ****************************************************************************/
  558. #define GFA_NOT_SUPPORTED 0
  559. #define GFA_SUPPORTED 1
  560. #define GFA_DBCSFONT 2
  561. extern "C" ULONG NtGdiQueryFontAssocInfo(HDC hdc)
  562. {
  563. // if hdc is NULL then just return fFontAssocStatus
  564. if(hdc == NULL)
  565. {
  566. return(fFontAssocStatus);
  567. }
  568. else
  569. {
  570. // for now eventually merge/share with NtGdiGetCharSet
  571. FLONG flSim;
  572. POINTL ptlSim;
  573. FLONG flAboutMatch;
  574. PFE *ppfe;
  575. DCOBJ dco (hdc);
  576. if (!dco.bValid())
  577. {
  578. SAVE_ERROR_CODE(ERROR_INVALID_HANDLE);
  579. return(GFA_NOT_SUPPORTED);
  580. }
  581. PDEVOBJ pdo(dco.hdev());
  582. ASSERTGDI(pdo.bValid(), "gdisrv!GetCharSet: bad pdev in dc\n");
  583. if (!pdo.bGotFonts())
  584. pdo.bGetDeviceFonts();
  585. LFONTOBJ lfo(dco.pdc->hlfntNew(), &pdo);
  586. if (dco.ulDirty() & DIRTY_CHARSET)
  587. {
  588. // force mapping
  589. if (!lfo.bValid())
  590. {
  591. WARNING("gdisrv!RFONTOBJ(dco): bad LFONT handle\n");
  592. return(GFA_NOT_SUPPORTED);
  593. }
  594. // Stabilize the public PFT for mapping.
  595. SEMOBJ so(ghsemPublicPFT);
  596. // LFONTOBJ::ppfeMapFont returns a pointer to the physical font face and
  597. // a simulation type (ist)
  598. // also store charset to the DC
  599. ppfe = lfo.ppfeMapFont(dco, &flSim, &ptlSim, &flAboutMatch);
  600. ASSERTGDI(!(dco.ulDirty() & DIRTY_CHARSET),
  601. "NtGdiGetCharSet, charset is dirty\n");
  602. }
  603. UINT Charset = (dco.pdc->iCS_CP() >> 16) & 0xFF;
  604. if (IS_ANY_DBCS_CHARSET( Charset ))
  605. {
  606. return GFA_DBCSFONT;
  607. }
  608. if (((Charset == ANSI_CHARSET) && (fFontAssocStatus & ANSI_ASSOC)) ||
  609. ((Charset == OEM_CHARSET) && (fFontAssocStatus & OEM_ASSOC)) ||
  610. ((Charset == SYMBOL_CHARSET) && (fFontAssocStatus & SYMBOL_ASSOC)) )
  611. {
  612. if(!(lfo.plfw()->lfClipPrecision & CLIP_DFA_DISABLE))
  613. {
  614. return(GFA_SUPPORTED);
  615. }
  616. }
  617. return(GFA_NOT_SUPPORTED);
  618. }
  619. }
  620. #endif