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.

104 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. CorrectFarEastFont.cpp
  5. Abstract:
  6. Some localized Far East applications create font to display localized-
  7. characters by supplying only font face name, and let the system pick up
  8. the correct charset. This works fine on Win9x platforms. But on Whistler,
  9. we need to specify correct charset in order to display localized characters
  10. correctly.
  11. We fix this in CreateFontIndirectA by correcting the charset value based on
  12. font face name.
  13. - If font face name contains DBCS characters, use the charset based on
  14. System Locale (DEFAULT_CHARSET)
  15. - If font face name is English or no face name is supplied,
  16. use ANSI_CHARSET
  17. History:
  18. 05/04/2001 rerkboos Created
  19. --*/
  20. #include "precomp.h"
  21. IMPLEMENT_SHIM_BEGIN(CorrectFarEastFont)
  22. #include "ShimHookMacro.h"
  23. APIHOOK_ENUM_BEGIN
  24. APIHOOK_ENUM_ENTRY(CreateFontIndirectA)
  25. APIHOOK_ENUM_END
  26. HFONT
  27. APIHOOK(CreateFontIndirectA)(
  28. CONST LOGFONTA* lplf // characteristics
  29. )
  30. {
  31. int j;
  32. BOOL bIsFEFont = FALSE;
  33. BYTE fNewCharSet = DEFAULT_CHARSET;
  34. LOGFONTA lfNew;
  35. if (lplf == NULL) {
  36. return ORIGINAL_API(CreateFontIndirectA)(lplf);
  37. }
  38. else
  39. {
  40. for (j=0; j<LF_FACESIZE; j++)
  41. {
  42. lfNew.lfFaceName[j] = lplf->lfFaceName[j]; // Copy the face name
  43. if ( IsDBCSLeadByte(lfNew.lfFaceName[j]) ) // Check for DBCS face name
  44. {
  45. bIsFEFont = TRUE;
  46. }
  47. if (lfNew.lfFaceName[j] == 0)
  48. {
  49. break;
  50. }
  51. }
  52. if (!bIsFEFont)
  53. {
  54. fNewCharSet = ANSI_CHARSET;
  55. }
  56. lfNew.lfHeight = lplf->lfHeight;
  57. lfNew.lfWidth = lplf->lfWidth;
  58. lfNew.lfEscapement = lplf->lfEscapement;
  59. lfNew.lfOrientation = lplf->lfOrientation;
  60. lfNew.lfWeight = lplf->lfWeight;
  61. lfNew.lfItalic = lplf->lfItalic;
  62. lfNew.lfUnderline = lplf->lfUnderline;
  63. lfNew.lfStrikeOut = lplf->lfStrikeOut;
  64. lfNew.lfCharSet = fNewCharSet;
  65. lfNew.lfOutPrecision = lplf->lfOutPrecision;
  66. lfNew.lfClipPrecision = lplf->lfClipPrecision;
  67. lfNew.lfQuality = lplf->lfQuality;
  68. lfNew.lfPitchAndFamily = lplf->lfPitchAndFamily;
  69. return ORIGINAL_API(CreateFontIndirectA)(&lfNew);
  70. }
  71. }
  72. /*++
  73. Register hooked functions
  74. --*/
  75. HOOK_BEGIN
  76. APIHOOK_ENTRY(GDI32.DLL, CreateFontIndirectA)
  77. HOOK_END
  78. IMPLEMENT_SHIM_END