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.

190 lines
5.0 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: fon32.c
  3. *
  4. * support for 32 bit fon files
  5. *
  6. * Created: 03-Mar-1992 15:48:53
  7. * Author: Bodin Dresevic [BodinD]
  8. *
  9. * Copyright (c) 1990 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #include "fd.h"
  13. /******************************Public*Routine******************************\
  14. * bLoadntFon()
  15. *
  16. * History:
  17. * 07-Jul-1995 -by- Gerrit van Wingerden [gerritv]
  18. * Rewrote for kernel mode.
  19. * 02-Mar-1992 -by- Bodin Dresevic [BodinD]
  20. * Wrote it.
  21. \**************************************************************************/
  22. BOOL
  23. bLoadNtFon(
  24. HFF iFile,
  25. PVOID pvView,
  26. HFF *phff
  27. )
  28. {
  29. PFONTFILE pff;
  30. IFIMETRICS* pifi;
  31. INT cFonts,i;
  32. BOOL bRet = FALSE;
  33. PVOID *ppvBases = NULL;
  34. ULONG cjIFI,cVerified;
  35. ULONG dpIFI;
  36. ULONG dpszFileName;
  37. ULONG cjff;
  38. #ifdef FE_SB
  39. ULONG cVerticalFaces = 0;
  40. USHORT CharSet;
  41. #endif
  42. PBYTE pjViewBase;
  43. SIZE_T cjViewSize;
  44. // first find the number of font resource in the executeable
  45. cFonts = cParseFontResources( (HANDLE) iFile, &ppvBases );
  46. if (cFonts == 0)
  47. {
  48. return bRet;
  49. }
  50. cVerified = cjIFI = 0;
  51. // next loop through all the FNT resources to get the size of each fonts
  52. // IFIMETRICS
  53. pjViewBase = (PBYTE)((PFONTFILEVIEW)iFile)->fv.pvViewFD;
  54. cjViewSize = ((PFONTFILEVIEW)iFile)->fv.cjView;
  55. for( i = 0; i < cFonts; i++ )
  56. {
  57. RES_ELEM re;
  58. ULONG cjBMFDIFIMETRICS;
  59. re.pvResData = ppvBases[i];
  60. re.cjResData = ulMakeULONG((PBYTE) ppvBases[i] + OFF_Size );
  61. re.pjFaceName = NULL;
  62. if( !bVerifyFNTQuick( &re ) )
  63. {
  64. goto exit_freemem;
  65. }
  66. if (!bBMFDIFIMETRICS(pjViewBase, cjViewSize, NULL, &re, &cjBMFDIFIMETRICS))
  67. {
  68. goto exit_freemem;
  69. }
  70. cVerified += 1;
  71. cjIFI += cjBMFDIFIMETRICS;
  72. }
  73. *phff = (HFF)NULL;
  74. #ifdef FE_SB
  75. // extra space for possible vertical face
  76. cjIFI *= 2;
  77. dpIFI = offsetof(FONTFILE,afai[0]) + cVerified * 2 * sizeof(FACEINFO);
  78. #else
  79. dpIFI = offsetof(FONTFILE,afai[0]) + cVerified * sizeof(FACEINFO);
  80. #endif
  81. dpszFileName = dpIFI + cjIFI;
  82. cjff = dpszFileName;
  83. if ((*phff = hffAlloc(cjff)) == (HFF)NULL)
  84. {
  85. SAVE_ERROR_CODE(ERROR_NOT_ENOUGH_MEMORY);
  86. RETURN("BMFD! bLoadDll32: memory allocation error\n", FALSE);
  87. }
  88. pff = PFF(*phff);
  89. // init fields of pff structure
  90. pff->ident = ID_FONTFILE;
  91. pff->fl = 0;
  92. pff->iType = TYPE_DLL32;
  93. pff->cFntRes = cVerified;
  94. pff->iFile = iFile;
  95. //!!! we could do better here, we could try to get a description string from
  96. //!!! the version stamp of the file, if there is one, if not we can still use
  97. //!!! this default mechanism [bodind]
  98. pff->dpwszDescription = 0; // no description string, use Facename later
  99. pff->cjDescription = 0;
  100. // finally convert all the resources
  101. pifi = (IFIMETRICS*)((PBYTE) pff + dpIFI);
  102. for( i = 0; i < cFonts; i++ )
  103. {
  104. RES_ELEM re;
  105. re.pvResData = ppvBases[i];
  106. re.cjResData = ulMakeULONG((PBYTE) ppvBases[i] + OFF_Size );
  107. re.dpResData = (PTRDIFF)((PBYTE) re.pvResData - (PBYTE) pvView );
  108. re.pjFaceName = NULL;
  109. pff->afai[i].re = re;
  110. pff->afai[i].pifi = pifi;
  111. #if FE_SB
  112. pff->afai[i].bVertical = FALSE;
  113. #endif
  114. if( !bConvertFontRes( pjViewBase, cjViewSize, &re, &pff->afai[i] ) )
  115. {
  116. goto exit_freemem;
  117. }
  118. pifi = (IFIMETRICS*)((PBYTE)pifi + pff->afai[i].pifi->cjThis);
  119. #ifdef FE_SB
  120. CharSet = pff->afai[i].pifi->jWinCharSet;
  121. if( IS_ANY_DBCS_CHARSET(CharSet) )
  122. {
  123. re.pvResData = ppvBases[i];
  124. re.cjResData = ulMakeULONG((PBYTE) ppvBases[i] + OFF_Size );
  125. re.dpResData = (PTRDIFF)((PBYTE) re.pvResData - (PBYTE) pvView );
  126. re.pjFaceName = NULL;
  127. pff->afai[cFonts+cVerticalFaces].re = re;
  128. pff->afai[cFonts+cVerticalFaces].pifi = pifi;
  129. pff->afai[cFonts+cVerticalFaces].bVertical = TRUE;
  130. if( !bConvertFontRes( pjViewBase, cjViewSize, &re, &pff->afai[cFonts+cVerticalFaces] ) )
  131. {
  132. goto exit_freemem;
  133. }
  134. pifi = (IFIMETRICS*)((PBYTE)pifi + pff->afai[i].pifi->cjThis);
  135. cVerticalFaces += 1;
  136. }
  137. #endif
  138. }
  139. #ifdef FE_SB
  140. pff->cFntRes += cVerticalFaces;
  141. #endif
  142. bRet = TRUE;
  143. pff->cRef = 0L;
  144. exit_freemem:
  145. EngFreeMem( (PVOID*) ppvBases );
  146. if( !bRet && *phff )
  147. {
  148. EngFreeMem( (PVOID) *phff );
  149. *phff = (HFF)NULL;
  150. }
  151. return(bRet);
  152. }