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.

227 lines
4.7 KiB

  1. /*
  2. * Adobe Universal Font Library
  3. *
  4. * Copyright (c) 1996 Adobe Systems Inc.
  5. * All Rights Reserved
  6. *
  7. * UFL.c
  8. *
  9. * $Header: $
  10. */
  11. #include "UFL.h"
  12. #include "UFLMem.h"
  13. #include "UFLStd.h"
  14. #include "UFLPriv.h"
  15. #include "UFLErr.h"
  16. #include "UFO.h"
  17. /*
  18. * Global constant strings
  19. * These strings are shared among all T1/T3/T42 downloading.
  20. */
  21. const char *gnotdefArray = " 256 array 0 1 255 {1 index exch /.notdef put} for ";
  22. const char *Notdef = ".notdef";
  23. const char *Hyphen = "hyphen";
  24. const char *Minus = "minus";
  25. const char *SftHyphen = "sfthyphen";
  26. const char *UFLSpace = "space";
  27. const char *Bullet = "bullet";
  28. const char *nilStr = "\0\0";
  29. /*
  30. * UFL function implementations
  31. */
  32. UFLHANDLE
  33. UFLInit(
  34. const UFLBool bDLGlyphTracking,
  35. const UFLMemObj *pMemObj,
  36. const UFLFontProcs *pFontProcs,
  37. const UFLOutputDevice *pOutDev
  38. )
  39. {
  40. UFLStruct *pUFL;
  41. if ((pMemObj == 0) || (pFontProcs == 0) || (pOutDev == 0))
  42. return 0;
  43. pUFL = (UFLStruct *)UFLNewPtr(pMemObj, sizeof (*pUFL));
  44. if (pUFL)
  45. {
  46. pUFL->bDLGlyphTracking = bDLGlyphTracking;
  47. pUFL->mem = *pMemObj;
  48. pUFL->fontProcs = *pFontProcs;
  49. pUFL->outDev = *pOutDev;
  50. pUFL->hOut = StrmInit(&pUFL->mem,
  51. pUFL->outDev.pstream,
  52. (const UFLBool)pOutDev->bAscii);
  53. if (!pUFL->hOut)
  54. {
  55. UFLDeletePtr(pMemObj, pUFL);
  56. pUFL = 0;
  57. }
  58. }
  59. return (UFLHANDLE)pUFL;
  60. }
  61. void
  62. UFLCleanUp(
  63. UFLHANDLE h
  64. )
  65. {
  66. UFLStruct *pUFL = (UFLStruct *)h;
  67. StrmCleanUp(pUFL->hOut);
  68. UFLDeletePtr(&pUFL->mem, h);
  69. }
  70. UFLBool
  71. bUFLTestRestricted(
  72. const UFLHANDLE h,
  73. const UFLRequest *pRequest
  74. )
  75. {
  76. UFLStruct *pUFL = (UFLStruct *)h;
  77. if (pUFL == 0)
  78. return 0;
  79. return bUFOTestRestricted(&pUFL->mem, pUFL, pRequest);
  80. }
  81. UFO
  82. UFLNewFont(
  83. const UFLHANDLE h,
  84. const UFLRequest *pRequest
  85. )
  86. {
  87. UFLStruct *pUFL = (UFLStruct *)h;
  88. if (pUFL == 0)
  89. return 0;
  90. return UFOInit(&pUFL->mem, pUFL, pRequest);
  91. }
  92. /*===========================================================================
  93. UFLDownloadIncr
  94. Downloads a font incrementally. The first time this is called for a
  95. particular font, it will create a base font, and download a set of
  96. requested characters. Subsequent calls on the same font will download
  97. additional characters.
  98. ==============================================================================*/
  99. UFLErrCode
  100. UFLDownloadIncr(
  101. const UFO h,
  102. const UFLGlyphsInfo *pGlyphs,
  103. unsigned long *pVMUsage,
  104. unsigned long *pFCUsage
  105. )
  106. {
  107. if (h == 0)
  108. return kErrInvalidHandle;
  109. return UFODownloadIncr((UFOStruct *)h, pGlyphs, pVMUsage, pFCUsage);
  110. }
  111. /*===========================================================================
  112. UFLVMNeeded
  113. Get a guestimate of VM needed for a download request.
  114. ==============================================================================*/
  115. UFLErrCode
  116. UFLVMNeeded(
  117. const UFO h,
  118. const UFLGlyphsInfo *pGlyphs,
  119. unsigned long *pVMNeeded,
  120. unsigned long *pFCNeeded
  121. )
  122. {
  123. if (h == 0)
  124. return kErrInvalidHandle;
  125. return UFOVMNeeded((UFOStruct *)h, pGlyphs, pVMNeeded, pFCNeeded);
  126. }
  127. void
  128. UFLDeleteFont(
  129. UFO h
  130. )
  131. {
  132. if (h == 0)
  133. return;
  134. UFOCleanUp((UFOStruct *)h);
  135. }
  136. UFLErrCode
  137. UFLUndefineFont(
  138. const UFO h
  139. )
  140. {
  141. if (h == 0)
  142. return kErrInvalidHandle;
  143. return UFOUndefineFont((UFOStruct *)h);
  144. }
  145. UFO
  146. UFLCopyFont(
  147. const UFO h,
  148. const UFLRequest* pRequest
  149. )
  150. {
  151. if (h == 0)
  152. return NULL;
  153. return UFOCopyFont((UFOStruct *)h, pRequest);
  154. }
  155. /*===========================================================================
  156. UFLGIDsToCIDs
  157. This function can only be used with a CID CFF font. It is used to
  158. obtain CIDs from a list of GIDs.
  159. ==============================================================================*/
  160. UFLErrCode
  161. UFLGIDsToCIDs(
  162. const UFO aCFFFont,
  163. const short cGlyphs,
  164. const UFLGlyphID *pGIDs,
  165. unsigned short *pCIDs
  166. )
  167. {
  168. if (aCFFFont == 0)
  169. return kErrInvalidHandle;
  170. return UFOGIDsToCIDs((UFOStruct *) aCFFFont, cGlyphs, pGIDs, pCIDs);
  171. }