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.

652 lines
13 KiB

  1. /*++
  2. Copyright (c) 1990-1998, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. font.h
  5. Abstract:
  6. This module contains the header information for the Win32 font dialogs.
  7. Revision History:
  8. --*/
  9. //
  10. // Include Files.
  11. //
  12. #include <help.h>
  13. #ifdef MM_DESIGNVECTOR_DEFINED
  14. // new flag that for NT 5.0/IE 5.0 is used for testing purpose only
  15. #define CF_MM_DESIGNVECTOR 0x02000000L
  16. #if (_WIN32_WINNT < 0x0500)
  17. //
  18. // new NT 5.0 definitions related to MultipleMaster desing vector, from WinGdi.h
  19. //
  20. #define STAMP_DESIGNVECTOR (0x8000000 + 'd' + ('v' << 8))
  21. #define STAMP_AXESLIST (0x8000000 + 'a' + ('l' << 8))
  22. #define MM_MAX_NUMAXES 16
  23. typedef struct tagDESIGNVECTOR
  24. {
  25. DWORD dvReserved;
  26. DWORD dvNumAxes;
  27. LONG dvValues[MM_MAX_NUMAXES];
  28. } DESIGNVECTOR, *PDESIGNVECTOR, FAR *LPDESIGNVECTOR;
  29. typedef struct tagENUMLOGFONTEXDVA
  30. {
  31. ENUMLOGFONTEXA elfEnumLogfontEx;
  32. DESIGNVECTOR elfDesignVector;
  33. } ENUMLOGFONTEXDVA, *PENUMLOGFONTEXDVA, FAR *LPENUMLOGFONTEXDVA;
  34. typedef struct tagENUMLOGFONTEXDVW
  35. {
  36. ENUMLOGFONTEXW elfEnumLogfontEx;
  37. DESIGNVECTOR elfDesignVector;
  38. } ENUMLOGFONTEXDVW, *PENUMLOGFONTEXDVW, FAR *LPENUMLOGFONTEXDVW;
  39. #ifdef UNICODE
  40. typedef ENUMLOGFONTEXDVW ENUMLOGFONTEXDV;
  41. typedef PENUMLOGFONTEXDVW PENUMLOGFONTEXDV;
  42. typedef LPENUMLOGFONTEXDVW LPENUMLOGFONTEXDV;
  43. #else
  44. typedef ENUMLOGFONTEXDVA ENUMLOGFONTEXDV;
  45. typedef PENUMLOGFONTEXDVA PENUMLOGFONTEXDV;
  46. typedef LPENUMLOGFONTEXDVA LPENUMLOGFONTEXDV;
  47. #endif // UNICODE
  48. #define MM_MAX_AXES_NAMELEN 16
  49. typedef struct tagAXISINFOA
  50. {
  51. LONG axMinValue;
  52. LONG axMaxValue;
  53. BYTE axAxisName[MM_MAX_AXES_NAMELEN];
  54. } AXISINFOA, *PAXISINFOA, FAR *LPAXISINFOA;
  55. typedef struct tagAXISINFOW
  56. {
  57. LONG axMinValue;
  58. LONG axMaxValue;
  59. WCHAR axAxisName[MM_MAX_AXES_NAMELEN];
  60. } AXISINFOW, *PAXISINFOW, FAR *LPAXISINFOW;
  61. #ifdef UNICODE
  62. typedef AXISINFOW AXISINFO;
  63. typedef PAXISINFOW PAXISINFO;
  64. typedef LPAXISINFOW LPAXISINFO;
  65. #else
  66. typedef AXISINFOA AXISINFO;
  67. typedef PAXISINFOA PAXISINFO;
  68. typedef LPAXISINFOA LPAXISINFO;
  69. #endif // UNICODE
  70. typedef struct tagAXESLISTA
  71. {
  72. DWORD axlReserved;
  73. DWORD axlNumAxes;
  74. AXISINFOA axlAxisInfo[MM_MAX_NUMAXES];
  75. } AXESLISTA, *PAXESLISTA, FAR *LPAXESLISTA;
  76. typedef struct tagAXESLISTW
  77. {
  78. DWORD axlReserved;
  79. DWORD axlNumAxes;
  80. AXISINFOW axlAxisInfo[MM_MAX_NUMAXES];
  81. } AXESLISTW, *PAXESLISTW, FAR *LPAXESLISTW;
  82. #ifdef UNICODE
  83. typedef AXESLISTW AXESLIST;
  84. typedef PAXESLISTW PAXESLIST;
  85. typedef LPAXESLISTW LPAXESLIST;
  86. #else
  87. typedef AXESLISTA AXESLIST;
  88. typedef PAXESLISTA PAXESLIST;
  89. typedef LPAXESLISTA LPAXESLIST;
  90. #endif // UNICODE
  91. typedef struct tagENUMTEXTMETRICA
  92. {
  93. NEWTEXTMETRICEXA etmNewTextMetricEx;
  94. AXESLISTA etmAxesList;
  95. } ENUMTEXTMETRICA, *PENUMTEXTMETRICA, FAR *LPENUMTEXTMETRICA;
  96. typedef struct tagENUMTEXTMETRICW
  97. {
  98. NEWTEXTMETRICEXW etmNewTextMetricEx;
  99. AXESLISTW etmAxesList;
  100. } ENUMTEXTMETRICW, *PENUMTEXTMETRICW, FAR *LPENUMTEXTMETRICW;
  101. #ifdef UNICODE
  102. typedef ENUMTEXTMETRICW ENUMTEXTMETRIC;
  103. typedef PENUMTEXTMETRICW PENUMTEXTMETRIC;
  104. typedef LPENUMTEXTMETRICW LPENUMTEXTMETRIC;
  105. #else
  106. typedef ENUMTEXTMETRICA ENUMTEXTMETRIC;
  107. typedef PENUMTEXTMETRICA PENUMTEXTMETRIC;
  108. typedef LPENUMTEXTMETRICA LPENUMTEXTMETRIC;
  109. #endif // UNICODE
  110. #endif // (_WIN32_WINNT < 0x0500)
  111. #endif // MM_DESIGNVECTOR_DEFINED
  112. //
  113. // Constant Declarations.
  114. //
  115. // Finnish needs 17 chars (18 w/ NULL) -- let's give them 20.
  116. #define CCHCOLORNAMEMAX 20 // max length of color name text
  117. #define CCHCOLORS 16 // max # of pure colors in color combo
  118. #define POINTS_PER_INCH 72
  119. #define FFMASK 0xf0 // pitch and family mask
  120. #define CCHSTDSTRING 12 // max length of sample text string
  121. #define FONTPROP (LPCTSTR) 0xA000L
  122. #define CBN_MYEDITUPDATE (WM_USER + 501)
  123. #define KEY_FONT_SUBS TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\FontSubstitutes")
  124. #define DEF_POINT_SIZE 10
  125. //If you add a bitmaps to the font bitmap you should modify this constant.
  126. #define NUM_OF_BITMAP 5
  127. #define DX_BITMAP 20
  128. #define DY_BITMAP 12
  129. #define FONT_INVALID_CHARSET 0x100
  130. //
  131. // Typedef Declarations.
  132. //
  133. #ifdef MM_DESIGNVECTOR_DEFINED
  134. // CreateFontIndirectEx
  135. typedef HFONT (WINAPI *PFNCREATEFONTINDIRECTEX)( IN CONST ENUMLOGFONTEXDV *);
  136. #endif // MM_DESIGNVECTOR_DEFINED
  137. typedef struct {
  138. UINT ApiType;
  139. LPCHOOSEFONT pCF;
  140. UINT iCharset;
  141. RECT rcText;
  142. DWORD nLastFontType;
  143. DWORD ProcessVersion;
  144. #ifdef MM_DESIGNVECTOR_DEFINED
  145. PFNCREATEFONTINDIRECTEX pfnCreateFontIndirectEx;
  146. DESIGNVECTOR DefaultDesignVector;
  147. #endif // MM_DESIGNVECTOR_DEFINED
  148. #ifdef UNICODE
  149. LPCHOOSEFONTA pCFA;
  150. PUNICODE_STRING pusStyle;
  151. PANSI_STRING pasStyle;
  152. #endif
  153. } FONTINFO;
  154. typedef FONTINFO *PFONTINFO;
  155. typedef struct {
  156. HWND hwndFamily;
  157. HWND hwndStyle;
  158. HWND hwndSizes;
  159. HWND hwndScript;
  160. UINT iCharset; // returned for enumerating scripts
  161. UINT cfdCharset; // ChooseFontData charset passed in here
  162. HDC hDC;
  163. DWORD dwFlags;
  164. DWORD nFontType;
  165. BOOL bFillSize;
  166. BOOL bPrinterFont;
  167. LPCHOOSEFONT lpcf;
  168. #ifdef MM_DESIGNVECTOR_DEFINED
  169. HWND hwndParent; // to extend the dialog for MM
  170. PDESIGNVECTOR pDefaultDesignVector;
  171. #endif // MM_DESIGNVECTOR_DEFINED
  172. } ENUM_FONT_DATA, *LPENUM_FONT_DATA;
  173. typedef struct _ITEMDATA {
  174. PLOGFONT pLogFont;
  175. DWORD nFontType;
  176. } ITEMDATA, *LPITEMDATA;
  177. //
  178. // Chinese font numbers (zihao).
  179. //
  180. typedef struct {
  181. TCHAR name[5];
  182. int size;
  183. int sizeFr;
  184. } ZIHAO;
  185. #define NUM_ZIHAO 16
  186. #ifdef UNICODE
  187. ZIHAO stZihao[NUM_ZIHAO] =
  188. {
  189. { L"\x516b\x53f7", 5, 0 }, { L"\x4e03\x53f7", 5, 5 },
  190. { L"\x5c0f\x516d", 6, 5 }, { L"\x516d\x53f7", 7, 5 },
  191. { L"\x5c0f\x4e94", 9, 0 }, { L"\x4e94\x53f7", 10, 5 },
  192. { L"\x5c0f\x56db", 12, 0 }, { L"\x56db\x53f7", 14, 0 },
  193. { L"\x5c0f\x4e09", 15, 0 }, { L"\x4e09\x53f7", 16, 0 },
  194. { L"\x5c0f\x4e8c", 18, 0 }, { L"\x4e8c\x53f7", 22, 0 },
  195. { L"\x5c0f\x4e00", 24, 0 }, { L"\x4e00\x53f7", 26, 0 },
  196. { L"\x5c0f\x521d", 36, 0 }, { L"\x521d\x53f7", 42, 0 }
  197. };
  198. #else
  199. ZIHAO stZihao[NUM_ZIHAO] =
  200. {
  201. { "\xb0\xcb\xba\xc5", 5, 0 }, { "\xc6\xdf\xba\xc5", 5, 5 },
  202. { "\xd0\xa1\xc1\xf9", 6, 5 }, { "\xc1\xf9\xba\xc5", 7, 5 },
  203. { "\xd0\xa1\xce\xe5", 9, 0 }, { "\xce\xe5\xba\xc5", 10, 5 },
  204. { "\xd0\xa1\xcb\xc4", 12, 0 }, { "\xcb\xc4\xba\xc5", 14, 0 },
  205. { "\xd0\xa1\xc8\xfd", 15, 0 }, { "\xc8\xfd\xba\xc5", 16, 0 },
  206. { "\xd0\xa1\xb6\xfe", 18, 0 }, { "\xb6\xfe\xba\xc5", 22, 0 },
  207. { "\xd0\xa1\xd2\xbb", 24, 0 }, { "\xd2\xbb\xba\xc5", 26, 0 },
  208. { "\xd0\xa1\xb3\xf5", 36, 0 }, { "\xb3\xf5\xba\xc5", 42, 0 }
  209. };
  210. #endif
  211. //
  212. // Global Variables.
  213. //
  214. UINT msgWOWLFCHANGE;
  215. UINT msgWOWCHOOSEFONT_GETLOGFONT;
  216. //
  217. // Color tables for color combo box.
  218. // Order of values must match names in sz.src.
  219. //
  220. DWORD rgbColors[CCHCOLORS] =
  221. {
  222. RGB( 0, 0, 0), // Black
  223. RGB(128, 0, 0), // Dark red
  224. RGB( 0, 128, 0), // Dark green
  225. RGB(128, 128, 0), // Dark yellow
  226. RGB( 0, 0, 128), // Dark blue
  227. RGB(128, 0, 128), // Dark purple
  228. RGB( 0, 128, 128), // Dark aqua
  229. RGB(128, 128, 128), // Dark grey
  230. RGB(192, 192, 192), // Light grey
  231. RGB(255, 0, 0), // Light red
  232. RGB( 0, 255, 0), // Light green
  233. RGB(255, 255, 0), // Light yellow
  234. RGB( 0, 0, 255), // Light blue
  235. RGB(255, 0, 255), // Light purple
  236. RGB( 0, 255, 255), // Light aqua
  237. RGB(255, 255, 255), // White
  238. };
  239. HBITMAP hbmFont = NULL;
  240. HFONT hDlgFont = NULL;
  241. UINT DefaultCharset;
  242. TCHAR szRegular[CCHSTYLE];
  243. TCHAR szBold[CCHSTYLE];
  244. TCHAR szItalic[CCHSTYLE];
  245. TCHAR szBoldItalic[CCHSTYLE];
  246. TCHAR szPtFormat[] = TEXT("%d");
  247. TCHAR c_szRegular[] = TEXT("Regular");
  248. TCHAR c_szBold[] = TEXT("Bold");
  249. TCHAR c_szItalic[] = TEXT("Italic");
  250. TCHAR c_szBoldItalic[] = TEXT("Bold Italic");
  251. LPCFHOOKPROC glpfnFontHook = 0;
  252. BOOL g_bIsSimplifiedChineseUI = FALSE;
  253. //
  254. // Context Help IDs.
  255. //
  256. const static DWORD aFontHelpIDs[] = // Context Help IDs
  257. {
  258. stc1, IDH_FONT_FONT,
  259. cmb1, IDH_FONT_FONT,
  260. stc2, IDH_FONT_STYLE,
  261. cmb2, IDH_FONT_STYLE,
  262. stc3, IDH_FONT_SIZE,
  263. cmb3, IDH_FONT_SIZE,
  264. psh3, IDH_COMM_APPLYNOW,
  265. grp1, IDH_FONT_EFFECTS,
  266. chx1, IDH_FONT_EFFECTS,
  267. chx2, IDH_FONT_EFFECTS,
  268. stc4, IDH_FONT_COLOR,
  269. cmb4, IDH_FONT_COLOR,
  270. grp2, IDH_FONT_SAMPLE,
  271. stc5, IDH_FONT_SAMPLE,
  272. stc6, NO_HELP,
  273. stc7, IDH_FONT_SCRIPT,
  274. cmb5, IDH_FONT_SCRIPT,
  275. 0, 0
  276. };
  277. //
  278. // Function Prototypes.
  279. //
  280. #ifdef MM_DESIGNVECTOR_DEFINED
  281. /* flag used for ChooseFontExA, ChooseFontExW and ChooseFontX : */
  282. #define CHF_DESIGNVECTOR 0x0001
  283. /* give the MM result into DESIGNVECTOR,
  284. default is to convert the axis into the name for backwards compatibility */
  285. /* ChooseFontExA and ChooseFontExW must be called with lpLogFont of size ENUMLOGFONTEXDV */
  286. BOOL APIENTRY ChooseFontExA(LPCHOOSEFONTA, DWORD fl);
  287. BOOL APIENTRY ChooseFontExW(LPCHOOSEFONTW, DWORD fl);
  288. #ifdef UNICODE
  289. #define ChooseFontEx ChooseFontExW
  290. #else
  291. #define ChooseFontEx ChooseFontExA
  292. #endif // !UNICODE
  293. #endif // MM_DESIGNVECTOR_DEFINED
  294. BOOL
  295. ChooseFontX(
  296. #ifdef MM_DESIGNVECTOR_DEFINED
  297. PFONTINFO pFI, DWORD fl);
  298. #else
  299. PFONTINFO pFI);
  300. #endif // MM_DESIGNVECTOR_DEFINED
  301. VOID
  302. SetStyleSelection(
  303. HWND hDlg,
  304. LPCHOOSEFONT lpcf,
  305. BOOL bInit);
  306. #ifdef MM_DESIGNVECTOR_DEFINED
  307. VOID
  308. SetMMAxesSelection(
  309. HWND hDlg,
  310. LPCHOOSEFONT lpcf);
  311. #endif // MM_DESIGNVECTOR_DEFINED
  312. VOID
  313. HideDlgItem(
  314. HWND hDlg,
  315. int id);
  316. VOID
  317. FixComboHeights(
  318. HWND hDlg);
  319. BOOL_PTR CALLBACK
  320. FormatCharDlgProc(
  321. HWND hDlg,
  322. UINT wMsg,
  323. WPARAM wParam,
  324. LPARAM lParam);
  325. void
  326. SelectStyleFromLF(
  327. HWND hwnd,
  328. LPLOGFONT lplf);
  329. int
  330. CBSetTextFromSel(
  331. HWND hwnd);
  332. int
  333. CBSetSelFromText(
  334. HWND hwnd,
  335. LPTSTR lpszString);
  336. int
  337. CBGetTextAndData(
  338. HWND hwnd,
  339. LPTSTR lpszString,
  340. int iSize,
  341. PULONG_PTR lpdw);
  342. int
  343. CBFindString(
  344. HWND hwnd,
  345. LPTSTR lpszString);
  346. BOOL
  347. GetPointSizeInRange(
  348. HWND hDlg,
  349. LPCHOOSEFONT lpcf,
  350. LPINT pts,
  351. WORD wFlags);
  352. BOOL
  353. ResetSampleFromScript(
  354. HWND hdlg,
  355. HWND hwndScript,
  356. PFONTINFO pFI);
  357. BOOL ProcessDlgCtrlCommand(HWND hDlg, PFONTINFO pFI, WORD wId, WORD wCmd, HWND hwnd);
  358. int
  359. CmpFontType(
  360. DWORD ft1,
  361. DWORD ft2);
  362. int
  363. FontFamilyEnumProc(
  364. LPENUMLOGFONTEX lplf,
  365. LPNEWTEXTMETRIC lptm,
  366. DWORD nFontType,
  367. LPENUM_FONT_DATA lpData);
  368. BOOL
  369. GetFontFamily(
  370. HWND hDlg,
  371. HDC hDC,
  372. DWORD dwEnumCode,
  373. UINT iCharset);
  374. VOID
  375. CBAddSize(
  376. HWND hwnd,
  377. int pts,
  378. LPCHOOSEFONT lpcf);
  379. int
  380. InsertStyleSorted(
  381. HWND hwnd,
  382. LPTSTR lpszStyle,
  383. LPLOGFONT lplf);
  384. PLOGFONT
  385. CBAddStyle(
  386. HWND hwnd,
  387. LPTSTR lpszStyle,
  388. DWORD nFontType,
  389. LPLOGFONT lplf);
  390. int
  391. CBAddScript(
  392. HWND hwnd,
  393. LPTSTR lpszScript,
  394. UINT iCharset);
  395. VOID
  396. FillInMissingStyles(
  397. HWND hwnd);
  398. VOID
  399. FillScalableSizes(
  400. HWND hwnd,
  401. LPCHOOSEFONT lpcf);
  402. int
  403. FontStyleEnumProc(
  404. LPENUMLOGFONTEX lplf,
  405. LPNEWTEXTMETRIC lptm,
  406. DWORD nFontType,
  407. LPENUM_FONT_DATA lpData);
  408. VOID
  409. FreeFonts(
  410. HWND hwnd);
  411. VOID
  412. FreeAllItemData(
  413. HWND hDlg,
  414. PFONTINFO pFI);
  415. VOID
  416. InitLF(
  417. LPLOGFONT lplf);
  418. #ifdef MM_DESIGNVECTOR_DEFINED
  419. int
  420. FontMMAxesEnumProc(
  421. LPENUMLOGFONTEXDV lplf,
  422. LPENUMTEXTMETRIC lpetm,
  423. DWORD nFontType,
  424. LPENUM_FONT_DATA lpData);
  425. #endif // MM_DESIGNVECTOR_DEFINED
  426. int
  427. FontScriptEnumProc(
  428. LPENUMLOGFONTEX lplf,
  429. LPNEWTEXTMETRIC lptm,
  430. DWORD nFontType,
  431. LPENUM_FONT_DATA lpData);
  432. BOOL
  433. GetFontStylesAndSizes(
  434. HWND hDlg,
  435. PFONTINFO pFI,
  436. LPCHOOSEFONT lpcf,
  437. BOOL bForceSizeFill);
  438. VOID
  439. FillColorCombo(
  440. HWND hDlg);
  441. BOOL
  442. DrawSizeComboItem(
  443. LPDRAWITEMSTRUCT lpdis);
  444. BOOL
  445. DrawFamilyComboItem(
  446. LPDRAWITEMSTRUCT lpdis);
  447. BOOL
  448. DrawColorComboItem(
  449. LPDRAWITEMSTRUCT lpdis);
  450. VOID
  451. DrawSampleText(
  452. HWND hDlg,
  453. PFONTINFO pFI,
  454. LPCHOOSEFONT lpcf,
  455. HDC hDC);
  456. BOOL
  457. FillInFont(
  458. HWND hDlg,
  459. PFONTINFO pFI,
  460. LPCHOOSEFONT lpcf,
  461. LPLOGFONT lplf,
  462. BOOL bSetBits);
  463. #ifdef MM_DESIGNVECTOR_DEFINED
  464. BOOL
  465. FillInFontEx(
  466. HWND hDlg,
  467. PFONTINFO pFI,
  468. LPCHOOSEFONT lpcf,
  469. LPENUMLOGFONTEXDV lplf,
  470. BOOL bSetBits);
  471. BOOL
  472. SetLogFontEx(
  473. HWND hDlg,
  474. LPCHOOSEFONT lpcf,
  475. LPENUMLOGFONTEXDV lplf);
  476. #endif // MM_DESIGNVECTOR_DEFINED
  477. BOOL
  478. SetLogFont(
  479. HWND hDlg,
  480. LPCHOOSEFONT lpcf,
  481. LPLOGFONT lplf);
  482. VOID
  483. TermFont();
  484. int
  485. GetPointString(
  486. LPTSTR buf,
  487. HDC hDC,
  488. int height);
  489. DWORD
  490. FlipColor(
  491. DWORD rgb);
  492. HBITMAP
  493. LoadBitmaps(
  494. int id);
  495. BOOL LookUpFontSubs(LPCTSTR lpSubFontName, LPTSTR lpRealFontName);
  496. BOOL GetUnicodeSampleText(HDC hdc, LPTSTR lpString, int nMaxCount);
  497. #ifdef UNICODE
  498. void
  499. ThunkChooseFontA2W(
  500. PFONTINFO pFI);
  501. void
  502. ThunkChooseFontW2A(
  503. PFONTINFO pFI);
  504. #ifdef MM_DESIGNVECTOR_DEFINED
  505. VOID
  506. ThunkEnumLogFontExDvA2W(
  507. LPENUMLOGFONTEXDVA lpLFA,
  508. LPENUMLOGFONTEXDVW lpLFW);
  509. VOID
  510. ThunkEnumLogFontExDvW2A(
  511. LPENUMLOGFONTEXDVW lpLFW,
  512. LPENUMLOGFONTEXDVA lpLFA);
  513. #endif // MM_DESIGNVECTOR_DEFINED
  514. VOID
  515. ThunkLogFontA2W(
  516. LPLOGFONTA lpLFA,
  517. LPLOGFONTW lpLFW);
  518. VOID
  519. ThunkLogFontW2A(
  520. LPLOGFONTW lpLFW,
  521. LPLOGFONTA lpLFA);
  522. #endif