Source code of Windows XP (NT5)
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.

765 lines
20 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* Fonts.c -- WRITE font routines */
  5. #define NOVIRTUALKEYCODES
  6. #define NOWINSTYLES
  7. #define NOSYSMETRICS
  8. #define NOMENUS
  9. #define NOICON
  10. #define NOKEYSTATE
  11. #define NOSYSCOMMANDS
  12. #define NORASTEROPS
  13. #define NOSHOWWINDOW
  14. #define NOATOM
  15. #define NOBITMAP
  16. #define NOBRUSH
  17. #define NOCLIPBOARD
  18. #define NOCOLOR
  19. #define NOCREATESTRUCT
  20. #define NODRAWTEXT
  21. #define NOMEMMGR
  22. #define NOMENUS
  23. #define NOMETAFILE
  24. #define NOMINMAX
  25. #define NOMSG
  26. #define NOOPENFILE
  27. #define NOPEN
  28. #define NOPOINT
  29. #define NOREGION
  30. #define NOSCROLL
  31. #define NOSOUND
  32. #define NOWH
  33. #define NOWINOFFSETS
  34. #define NOWNDCLASS
  35. #define NOCOMM
  36. #include <windows.h>
  37. #include "mw.h"
  38. #define NOUAC
  39. #include "cmddefs.h"
  40. #include "dlgdefs.h"
  41. #include "propdefs.h"
  42. #include "fontdefs.h"
  43. #include "prmdefs.h"
  44. #include "str.h"
  45. #include "docdefs.h"
  46. #ifdef DBCS
  47. #include "kanji.h"
  48. #endif
  49. #ifdef JAPAN
  50. CHAR szDefFFN0[10];
  51. CHAR szDefFFN1[10];
  52. #endif
  53. extern struct DOD (**hpdocdod)[];
  54. extern HANDLE hMmwModInstance;
  55. extern HANDLE hParentWw;
  56. extern int vfSeeSel;
  57. extern int docCur;
  58. extern HWND vhWndMsgBoxParent;
  59. extern int vfCursorVisible;
  60. extern HCURSOR vhcArrow;
  61. int iszSizeEnum;
  62. int iszSizeEnumMac;
  63. int iszSizeEnumMax;
  64. extern CHAR szSystem[];
  65. #ifdef DBCS_VERT
  66. extern CHAR szAtSystem[]; // Use for '@' fontface checking.
  67. #endif
  68. int iffnEnum;
  69. int vfFontEnumFail;
  70. struct FFNTB **hffntbEnum = NULL;
  71. #ifdef NEWFONTENUM
  72. /* Changed because it is INCORRECT to filter out all non-ANSI
  73. character sets. Also we've removed this aspect-ratio checking
  74. stuff ..pault */
  75. #define FCheckFont(lptm) (1)
  76. #else
  77. BOOL FCheckFont(lptm)
  78. LPTEXTMETRIC lptm;
  79. {
  80. /* This routine returns TRUE iff the character set for this font is the
  81. ANSI set and either this is a vector font or the aspect ratio is correct. */
  82. extern int aspectXFont;
  83. extern int aspectYFont;
  84. return (
  85. #ifdef DBCS
  86. lptm->tmCharSet == NATIVE_CHARSET
  87. #else
  88. lptm->tmCharSet == ANSI_CHARSET
  89. #endif
  90. && ((lptm->tmPitchAndFamily & 0x6) == 0x2
  91. || (lptm->tmDigitizedAspectX == aspectXFont
  92. && lptm->tmDigitizedAspectY == aspectYFont)));
  93. }
  94. #endif /* else-def-NEWFONTENUM */
  95. /* FontFaceEnum used to be called for a number of reasons so it used
  96. rg[] to pass in parameters to get it to do different things including
  97. aspect-ratio filtering. I've simplified this a great deal so Write
  98. will allow more things (this can be good or bad) ..pault */
  99. BOOL far PASCAL FontFaceEnum(lplf, lptm, fty, lParam)
  100. LPLOGFONT lplf;
  101. LPTEXTMETRIC lptm;
  102. int fty; /* font type, passed through from the EnumFonts call: */
  103. /* fty & RASTER_FONTTYPE == fRasterFont */
  104. /* fty & DEVICE_FONTTYPE == fDeviceFont */
  105. long lParam;
  106. {
  107. /* Callback routine to record all of the appropriate face names for the
  108. current printer. "appropriate" is based on the params as follows:
  109. * rgw[0]=0 normal mode,
  110. =enumQuickFaces indicates "streamlined mode"
  111. (i.e. ignore all the following params in this case), and
  112. =
  113. * rgw[1]=RASTER_FONTTYPE if only raster fonts are to be enumerated,
  114. * =DEVICE_FONTTYPE if only device fonts are to be enumerated,
  115. * =TRUETYPE_FONTTYPE if only TRUE_TYPE fonts are to be enumerated,
  116. * rgw[2]=desired font family code (e.g. we start out
  117. only wanting swiss, and later expand that)
  118. * rgw[3] indicates whether or not we must match rgw[2]
  119. * rgw[4]=max number of fonts we have room for
  120. ..pault 10/12/89*/
  121. int *rgw = (int *)LOWORD(lParam);
  122. /* Stop enumerating if we have enough fonts */
  123. if ((*hffntbEnum)->iffnMac >= rgw[4])
  124. /* we have all we need */
  125. return(FALSE);
  126. #ifdef DENUMF
  127. {
  128. char rgch[100];
  129. wsprintf(rgch,"FFEn: %s, devicebit %d rasterbit %d ",lplf->lfFaceName,
  130. fty&DEVICE_FONTTYPE, fty&RASTER_FONTTYPE);
  131. CommSz(rgch);
  132. }
  133. #endif
  134. #ifdef JAPAN //T-HIROYN Win3.1
  135. if (rgw[0] == enumQuickFaces)
  136. goto addenumj;
  137. if (rgw[0] == enumFaceNameJapan)
  138. {
  139. if (lplf->lfCharSet == NATIVE_CHARSET)
  140. {
  141. if (rgw[1] == 0 && (fty & DEVICE_FONTTYPE) &&
  142. !(CchDiffer(lplf->lfFaceName,szDefFFN0,lstrlen(szDefFFN0))))
  143. goto addenumj;
  144. // 12/15/92
  145. #if 1
  146. if (rgw[1] == 3 && (fty & TRUETYPE_FONTTYPE) &&
  147. (lplf->lfPitchAndFamily & 0xf0) == FF_ROMAN )
  148. goto addenumj;
  149. if (rgw[1] == 4 && (fty & TRUETYPE_FONTTYPE))
  150. goto addenumj;
  151. #endif
  152. if (rgw[1] == 1 &&
  153. !(CchDiffer(lplf->lfFaceName,szDefFFN1,lstrlen(szDefFFN1))))
  154. goto addenumj;
  155. if (rgw[1] == 2 &&
  156. (lplf->lfPitchAndFamily & 0xf0) == FF_ROMAN &&
  157. (lplf->lfPitchAndFamily & 0x0f) == FIXED_PITCH)
  158. goto addenumj;
  159. /* Is this the right type of font? */
  160. }
  161. goto retenumj;
  162. }
  163. if (rgw[0] == enumFaceNames && (fty & rgw[1]))
  164. {
  165. if( (rgw[3] == 0) ||
  166. ( (lptm->tmPitchAndFamily&grpbitFamily) == rgw[2] ) )
  167. goto addenumj;
  168. }
  169. goto retenumj;
  170. addenumj:
  171. {
  172. #else
  173. if ((rgw[0] == enumQuickFaces) ||
  174. /* Is this the right type of font? */
  175. ((fty & rgw[1]) &&
  176. /* Does this font belong to the correct family? Well
  177. when rgw[3] says: NEEDN'T MATCH then of course it does, and
  178. when rgw[3] says: MATCH then we check to see! */
  179. ((rgw[3] == 0)||((lptm->tmPitchAndFamily&grpbitFamily) == rgw[2])))) {
  180. #endif //JAPAN
  181. CHAR rgb[ibFfnMax];
  182. struct FFN *pffn = (struct FFN *)rgb;
  183. bltbx(lplf->lfFaceName, (LPSTR)pffn->szFfn,
  184. umin(LF_FACESIZE, IchIndexLp((LPCH)lplf->lfFaceName, '\0')+1));
  185. pffn->chs = lplf->lfCharSet; /* save this setting */
  186. /* We're interested in this one */
  187. if (FCheckFont(lptm) && (*hffntbEnum)->iffnMac < iffnEnumMax)
  188. {
  189. pffn->ffid = lplf->lfPitchAndFamily & grpbitFamily;
  190. #ifdef DENUMF
  191. CommSz("(adding)");
  192. #endif
  193. if (!FAddEnumFont(pffn))
  194. {
  195. /* Couldn't add it to the table. */
  196. vfFontEnumFail = TRUE;
  197. return(FALSE);
  198. }
  199. }
  200. }
  201. #ifdef DENUMF
  202. CommSz("\n\r");
  203. #endif
  204. #ifdef JAPAN //T-HIROYN Win3.1
  205. retenumj:
  206. #endif
  207. return(TRUE);
  208. }
  209. FInitFontEnum(doc, cffnInteresting, fOrder)
  210. /* sets up for a font enumeration, where caller cares about
  211. 'cffnInteresting' fonts, and special stuff is done iff 'fOrder'
  212. (to help us pick good default font(s) on startup */
  213. int doc, cffnInteresting, fOrder;
  214. {
  215. extern HDC vhDCPrinter;
  216. #ifdef INEFFLOCKDOWN
  217. extern FARPROC lpFontFaceEnum;
  218. #else
  219. FARPROC lpFontFaceEnum = NULL;
  220. #endif
  221. int iffn, iffnMac;
  222. struct FFNTB **hffntb;
  223. struct FFN *pffn, **hffn;
  224. struct FFN ffn;
  225. CHAR rgb[ibFfnMax];
  226. int rgw[5];
  227. vfFontEnumFail = FALSE;
  228. if (hffntbEnum != NULL)
  229. {
  230. return(FALSE);
  231. }
  232. if (FNoHeap(hffntbEnum = HffntbAlloc()))
  233. {
  234. hffntbEnum = NULL;
  235. return(FALSE);
  236. }
  237. /* First we list all the fonts used in the current doc's ffntb */
  238. #ifdef DENUMF
  239. CommSzNumNum("FINITFONTENUM: cffnInteresting,fOrder ",cffnInteresting,fOrder);
  240. #endif
  241. #ifdef JAPAN //T-HIROYN Win3.1J
  242. //Clear defalut KanjiFtc <-- use menu.c GetKanjiFtc();
  243. {
  244. extern int KanjiFtc;
  245. KanjiFtc = ftcNil;
  246. }
  247. #endif
  248. if (doc != docNil)
  249. {
  250. hffntb = HffntbGet(doc);
  251. iffnMac = imin((*hffntb)->iffnMac, iffnEnumMax);
  252. pffn = (struct FFN *)rgb;
  253. for (iffn = 0; iffn < iffnMac; iffn++)
  254. {
  255. hffn = (*hffntb)->mpftchffn[iffn];
  256. bltbyte((*hffn), pffn, CbFromPffn(*hffn));
  257. if (!FAddEnumFont(pffn))
  258. goto InitFailure;
  259. }
  260. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  261. {
  262. goto HaveCffnInteresting;
  263. }
  264. }
  265. #if 0
  266. /* Include the fonts from WIN.INI in the enumeration */
  267. if (!FAddProfileFonts())
  268. {
  269. goto InitFailure;
  270. }
  271. #endif
  272. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  273. goto HaveCffnInteresting;
  274. if (vhDCPrinter == NULL)
  275. {
  276. GetPrinterDC(FALSE);
  277. Assert(vhDCPrinter);
  278. }
  279. #ifndef INEFFLOCKDOWN
  280. if (!(lpFontFaceEnum = MakeProcInstance(FontFaceEnum, hMmwModInstance)))
  281. {
  282. WinFailure();
  283. goto InitFailure;
  284. }
  285. #endif
  286. /* See what the system knows about!
  287. If order ISN'T significant, we'll examine all fonts at once. */
  288. if (!fOrder)
  289. {
  290. #ifdef DENUMF
  291. CommSz("FINITFONTENUM: EnumFonts(all) \n\r");
  292. #endif
  293. rgw[0] = enumQuickFaces; // means igonre the rest
  294. #if 0
  295. rgw[1] = RASTER_FONTTYPE; // ignored, why set?
  296. rgw[2] = FF_SWISS; // ignored, why set?
  297. rgw[3] = TRUE; // ignored, why set?
  298. rgw[4] = cffnInteresting; // ignored, why set?
  299. #endif
  300. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  301. if (vfFontEnumFail)
  302. goto InitFailure;
  303. else
  304. goto HaveCffnInteresting; /* got what we needed */
  305. }
  306. #ifdef JAPAN //T-HIROYN Win3.1
  307. /* japanens write try in steps first
  308. #1 KANJI_CHARSET device_fonttype mincho
  309. //12/15/92
  310. add KANJI_CHARSET TRUETYPE FF_ROMAN
  311. add KANJI_CHARSET TRUETYPE
  312. #2 KANJI_CHARSET hyoujyun mincho
  313. #3 KANJI_CHARSET all font FF_ROMAN FIXED_PITCH
  314. */
  315. rgw[0] = enumFaceNameJapan; /* #define in FONTDEFS.H */
  316. rgw[1] = 0;
  317. rgw[2] = rgw[3] = 0; /* dummy */
  318. rgw[4] = 32767;
  319. EnumFonts(vhDCPrinter,0L,lpFontFaceEnum,(LPSTR)MAKELONG(&rgw[0], 0));
  320. if (vfFontEnumFail)
  321. goto InitFailure;
  322. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  323. goto HaveCffnInteresting; /* got what we needed */
  324. // 12/15/92
  325. #if 1
  326. rgw[1] = 3;
  327. EnumFonts(vhDCPrinter,0L,lpFontFaceEnum,(LPSTR)MAKELONG(&rgw[0], 0));
  328. if (vfFontEnumFail)
  329. goto InitFailure;
  330. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  331. goto HaveCffnInteresting; /* got what we needed */
  332. rgw[1] = 4;
  333. EnumFonts(vhDCPrinter,0L,lpFontFaceEnum,(LPSTR)MAKELONG(&rgw[0], 0));
  334. if (vfFontEnumFail)
  335. goto InitFailure;
  336. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  337. goto HaveCffnInteresting; /* got what we needed */
  338. #endif
  339. rgw[1] = 1;
  340. EnumFonts(vhDCPrinter,0L,lpFontFaceEnum,(LPSTR)MAKELONG(&rgw[0], 0));
  341. if (vfFontEnumFail)
  342. goto InitFailure;
  343. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  344. goto HaveCffnInteresting; /* got what we needed */
  345. rgw[1] = 2;
  346. EnumFonts(vhDCPrinter,0L,lpFontFaceEnum,(LPSTR)MAKELONG(&rgw[0], 0));
  347. if (vfFontEnumFail)
  348. goto InitFailure;
  349. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  350. goto HaveCffnInteresting; /* got what we needed */
  351. #endif /* JAPAN */
  352. /* Ahh... but since we now know order IS significant, i.e. we are
  353. trying to pick good default fonts for startup, we'll try in steps:
  354. #1--any good TrueType fonts in the Swiss font family?
  355. #2--any good TrueType fonts in the non-Swiss?
  356. #3--any good device-based fonts in the Swiss font family?
  357. #4-- " " " " non-Swiss?
  358. #5--any non device-based fonts in the Swiss font family?
  359. #6-- " " " " non-Swiss? */
  360. #ifdef DENUMF
  361. CommSz("FINITFONTENUM: EnumFonts(Swiss truetype) \n\r");
  362. #endif
  363. rgw[0] = enumFaceNames;
  364. rgw[1] = TRUETYPE_FONTTYPE;
  365. rgw[2] = FF_SWISS;
  366. rgw[3] = TRUE; /* match swiss! */
  367. rgw[4] = 32767;
  368. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  369. if (vfFontEnumFail)
  370. goto InitFailure;
  371. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  372. goto HaveCffnInteresting; /* got what we needed */
  373. #ifdef DENUMF
  374. CommSz("FINITFONTENUM: EnumFonts(nonSwiss truetype) \n\r");
  375. #endif
  376. rgw[3] = FALSE; /* need not match swiss! */
  377. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  378. if (vfFontEnumFail)
  379. goto InitFailure;
  380. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  381. goto HaveCffnInteresting; /* got what we needed */
  382. #ifdef DENUMF
  383. CommSz("FINITFONTENUM: EnumFonts(Swiss device) \n\r");
  384. #endif
  385. rgw[1] = DEVICE_FONTTYPE;
  386. rgw[3] = TRUE; /* match swiss! */
  387. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  388. if (vfFontEnumFail)
  389. goto InitFailure;
  390. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  391. goto HaveCffnInteresting; /* got what we needed */
  392. #ifdef DENUMF
  393. CommSz("FINITFONTENUM: EnumFonts(nonSwiss device) \n\r");
  394. #endif
  395. rgw[3] = FALSE; /* need not match swiss */
  396. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  397. if (vfFontEnumFail)
  398. goto InitFailure;
  399. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  400. goto HaveCffnInteresting; /* got what we needed */
  401. #ifdef DENUMF
  402. CommSz("FINITFONTENUM: EnumFonts(Swiss nondevice) \n\r");
  403. #endif
  404. rgw[1] = RASTER_FONTTYPE;
  405. rgw[3] = TRUE; /* match swiss! */
  406. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  407. if (vfFontEnumFail)
  408. goto InitFailure;
  409. if ((*hffntbEnum)->iffnMac >= cffnInteresting)
  410. goto HaveCffnInteresting; /* got what we needed */
  411. #ifdef DENUMF
  412. CommSz("FINITFONTENUM: EnumFonts(Swiss nondevice) \n\r");
  413. #endif
  414. rgw[3] = FALSE; /* need not match swiss */
  415. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  416. if (vfFontEnumFail)
  417. goto InitFailure;
  418. HaveCffnInteresting:
  419. iffnEnum = 0;
  420. #ifndef INEFFLOCKDOWN
  421. if (lpFontFaceEnum)
  422. FreeProcInstance(lpFontFaceEnum);
  423. #endif
  424. #ifdef JAPAN //T-HIROYN Win3.1
  425. if(docNil == doc && fOrder)
  426. SaveKanjiFfn();
  427. #endif
  428. return(TRUE);
  429. InitFailure:
  430. FreeFfntb(hffntbEnum);
  431. hffntbEnum = NULL;
  432. #ifndef INEFFLOCKDOWN
  433. if (lpFontFaceEnum)
  434. FreeProcInstance(lpFontFaceEnum);
  435. #endif
  436. return(FALSE);
  437. }
  438. void ResetFontTables(void)
  439. {
  440. /*
  441. Free the pfce's. LoadFont will reallocate them with new information
  442. obtained below.
  443. */
  444. FreeFonts(TRUE,TRUE);
  445. /* This is a clumsy method that takes advantage of side effect of
  446. resetting the data stored in the font tables */
  447. FInitFontEnum(docNil, 32767, FALSE);
  448. #ifdef JAPAN //T-HIROYN 92.08.18 Win3.1
  449. //Printer Change ?
  450. //Sync FontFaceName and CharSet
  451. {
  452. int iffn, iffnMac;
  453. int Eiffn, EiffnMac;
  454. struct FFNTB **hffntb;
  455. struct FFN ***mpftchffn;
  456. struct FFN ***Empftchffn;
  457. char msg[30];
  458. hffntb = HffntbGet(docCur);
  459. if (hffntb != 0) {
  460. mpftchffn = (*hffntb)->mpftchffn;
  461. iffnMac = (*hffntb)->iffnMac;
  462. Empftchffn = (*hffntbEnum)->mpftchffn;
  463. EiffnMac = (*hffntbEnum)->iffnMac;
  464. for (iffn = 0; iffn < iffnMac; iffn++) {
  465. for (Eiffn = 0; Eiffn < EiffnMac; Eiffn++) {
  466. if (WCompSz((*mpftchffn[iffn])->szFfn,
  467. (*Empftchffn[Eiffn])->szFfn) == 0)
  468. {
  469. (*mpftchffn[iffn])->chs = (*Empftchffn[Eiffn])->chs;
  470. break;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. #endif
  477. EndFontEnum();
  478. }
  479. CHAR * (NEAR PchSkipSpacesPch( CHAR * ));
  480. int WFromSzNumber( ppch )
  481. CHAR **ppch;
  482. { /* Given an ASCII string containing a (base 10) number, return the number
  483. represented. Ignores leading and trailing spaces.
  484. Does not accept negative numbers. */
  485. /* 10/12/89 ..pault
  486. Now increments the pointer to just past last digit converted */
  487. unsigned w = 0;
  488. CHAR ch;
  489. *ppch = PchSkipSpacesPch( *ppch );
  490. while ( ((ch = (*(*ppch)++)) >= '0') && (ch <= '9') )
  491. {
  492. w = (w * 10) + (ch - '0');
  493. }
  494. (*ppch)--; /* bumped one too far */
  495. return w;
  496. }
  497. CHAR * (NEAR PchSkipSpacesPch( pch ))
  498. CHAR *pch;
  499. { /* Return a pointer to the first character in the string
  500. at pch that is either null or non-whitespace */
  501. for ( ;; ) {
  502. #ifdef DBCS
  503. /* DB Char space must be checked */
  504. if (FKanjiSpace(*pch, *(pch + 1))) {
  505. pch += cchKanji;
  506. continue;
  507. }
  508. #endif /* DBCS */
  509. switch (*pch) {
  510. default:
  511. return pch;
  512. case ' ':
  513. case 0x09:
  514. pch++;
  515. break;
  516. }
  517. }
  518. }
  519. BOOL FEnumFont(pffn)
  520. /* returns the next font entry through pffn. Returns FALSE if no more */
  521. struct FFN *pffn;
  522. {
  523. int cb;
  524. struct FFN **hffn;
  525. if (iffnEnum >= (*hffntbEnum)->iffnMac)
  526. {
  527. return(FALSE);
  528. }
  529. hffn = (*hffntbEnum)->mpftchffn[iffnEnum];
  530. #ifdef DEBUG
  531. cb = CchSz( (*hffn)->szFfn );
  532. Assert( cb <= LF_FACESIZE );
  533. cb = CbFfn( cb );
  534. #else
  535. cb = CbFfn(CchSz((*hffn)->szFfn));
  536. #endif
  537. bltbyte(*hffn, pffn, cb);
  538. iffnEnum++;
  539. return(TRUE);
  540. }
  541. EndFontEnum()
  542. /* cleans up after a font enumeration */
  543. {
  544. FreeFfntb(hffntbEnum);
  545. hffntbEnum = NULL;
  546. }
  547. FAddEnumFont(pffn)
  548. /* code factoring for adding described font to enumeration table - filters
  549. out "ghost fonts" and system font */
  550. struct FFN *pffn;
  551. {
  552. #ifdef JAPAN
  553. // It is required to do vertical writing with system font in JAPAN.
  554. if ( pffn->szFfn[0] == chGhost)
  555. #else
  556. if (WCompSz(pffn->szFfn, szSystem) == 0 || pffn->szFfn[0] == chGhost)
  557. #endif
  558. return(TRUE);
  559. return(FEnsurePffn(hffntbEnum, pffn));
  560. }
  561. #ifdef JAPAN //T-HIROYN 92.08.18 Win3.1
  562. BYTE scrFontChs;
  563. //I want to get true Charset
  564. BOOL far PASCAL _export NFontFaceEnum(lplf, lptm, fty, lParam)
  565. LPLOGFONT lplf;
  566. LPTEXTMETRIC lptm;
  567. int fty;
  568. long lParam;
  569. {
  570. if (LOWORD(lParam) == 0)
  571. {
  572. scrFontChs = lplf->lfCharSet;
  573. return(FALSE);
  574. }
  575. return(TRUE);
  576. }
  577. #endif
  578. #ifdef NEWFONTENUM
  579. /* This stuff added for Win3 because we have to be able to determine
  580. with which character set a font in a particular document is associated,
  581. since our file format does not store it. Naturally, WinWord added that
  582. to their file format! ..pault */
  583. /* Look through the list of fonts sitting out there [i.e. FInitFontEnum
  584. must have been called, and it is from HffntbForFn()] and make our best
  585. guess as to what CharSet it's supposed to have, since we don't store
  586. these in the doc font table! */
  587. int ChsInferred( pffn )
  588. struct FFN *pffn;
  589. {
  590. struct FFN *pffnCheck;
  591. char *sz = pffn->szFfn;
  592. #ifdef DBCS
  593. int chs = NATIVE_CHARSET;
  594. #else
  595. int chs = 0;
  596. #endif
  597. int i, iMac = (*hffntbEnum)->iffnMac;
  598. for (i = 0; i < iMac; i++)
  599. {
  600. pffnCheck = *(struct FFN **) ((*hffntbEnum)->mpftchffn[i]);
  601. if (WCompSz(pffnCheck->szFfn, sz) == 0)
  602. {
  603. #ifdef DIAG
  604. if (pffnCheck->ffid != pffn->ffid)
  605. {
  606. CommSzSz("ChsInferred: matched fontname ",sz);
  607. CommSzNumNum(" but enum->ffid / doc->ffid", pffnCheck->ffid,pffn->ffid);
  608. }
  609. #endif
  610. Assert(pffnCheck->ffid == pffn->ffid);
  611. chs = pffnCheck->chs;
  612. break;
  613. }
  614. }
  615. #ifdef JAPAN //T-HIROYN 92.08.18 Win3.1
  616. //I want to get true Charset
  617. {
  618. extern HDC vhMDC; /* memory DC compatible with the screen */
  619. FARPROC NlpFontFaceEnum;
  620. if(i == iMac) {
  621. if(vhMDC != NULL) {
  622. if (NlpFontFaceEnum =
  623. MakeProcInstance(NFontFaceEnum, hMmwModInstance))
  624. {
  625. scrFontChs = chs;
  626. EnumFonts(vhMDC,(LPSTR)sz,NlpFontFaceEnum,(LPSTR) NULL);
  627. FreeProcInstance(NlpFontFaceEnum);
  628. if(chs != scrFontChs)
  629. chs = scrFontChs;
  630. }
  631. }
  632. }
  633. }
  634. #endif
  635. return(chs);
  636. }
  637. #endif /* NEWFONTENUM */
  638. #ifdef JAPAN //T-HIROYN Win3.1
  639. CHAR saveKanjiDefFfn[ibFfnMax];
  640. SaveKanjiFfn()
  641. {
  642. int i, iMac = (*hffntbEnum)->iffnMac;
  643. struct FFN *pffn = (struct FFN *)saveKanjiDefFfn;
  644. struct FFN *hffn;
  645. for (i = 0; i < iMac; i++)
  646. {
  647. hffn = *(struct FFN **) ((*hffntbEnum)->mpftchffn[i]);
  648. if (NATIVE_CHARSET == hffn->chs)
  649. {
  650. lstrcpy(pffn->szFfn, hffn->szFfn);
  651. pffn->ffid = hffn->ffid;
  652. pffn->chs = hffn->chs;
  653. break;
  654. }
  655. }
  656. }
  657. #endif
  658.