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.

467 lines
14 KiB

  1. /*
  2. * Adobe Universal Font Library
  3. *
  4. * Copyright (c) 1996 Adobe Systems Inc.
  5. * All Rights Reserved
  6. *
  7. * UFO -- Universal Font Object
  8. *
  9. *
  10. * $Header:
  11. */
  12. #ifndef _H_UFO
  13. #define _H_UFO
  14. /*===============================================================================*
  15. * Include files used by this interface *
  16. *===============================================================================*/
  17. #include "UFL.h"
  18. #include "UFLPriv.h"
  19. #include "goodname.h"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /*===============================================================================*
  24. * Theory of Operation *
  25. *===============================================================================*/
  26. /*
  27. * This file defines the Universal Font Object.
  28. */
  29. /*===============================================================================*
  30. * Constants *
  31. *===============================================================================*/
  32. /*===============================================================================*
  33. * Macros *
  34. *===============================================================================*/
  35. #define MAX_GLYPHNAME_LEN 256
  36. #define IS_GLYPH_SENT(arr, i) ((arr)[((i)>>3)] & (1 << ((i)&7)))
  37. #define SET_GLYPH_SENT_STATUS(arr, i) (arr)[((i)>>3)] |= (1 << ((i)&7))
  38. #define GLYPH_SENT_BUFSIZE(n) ( ((n) + 7) / 8 )
  39. /*===============================================================================*
  40. * Scalar Types *
  41. *===============================================================================*/
  42. /* Font state */
  43. typedef enum {
  44. kFontCreated, /* The font object is created, but has not initialized. */
  45. kFontInit, /* The font object is initialized and is valid to be used. */
  46. kFontInit2, /* Still requre to create its font instance. */
  47. kFontHeaderDownloaded, /* The font object downloaded an empty font header. */
  48. kFontHasChars, /* Font has chars in it. */
  49. kFontFullDownloaded /* The font object downloaded a full font. */
  50. } UFLFontState;
  51. /* Misc Flags for UFOStruct.dwFlags */
  52. #define UFO_HasFontInfo 0x00000001L
  53. #define UFO_HasG2UDict 0x00000002L
  54. #define UFO_HasXUID 0x00000004L
  55. #define UFO_HostFontAble 0x00000008L // %hostfont% support
  56. //
  57. // %hostfont% support
  58. //
  59. #define HOSTFONT_IS_VALID_UFO(pUFO) (((pUFO)->hHostFontData) && ((pUFO)->dwFlags & UFO_HostFontAble))
  60. #define HOSTFONT_IS_VALID_UFO_HFDH(pUFO) ((pUFO)->hHostFontData)
  61. #define HOSTFONT_VALIDATE_UFO(pUFO) ((pUFO)->dwFlags |= UFO_HostFontAble)
  62. #define HOSTFONT_INVALIDATE_UFO(pUFO) ((pUFO)->dwFlags &= ~UFO_HostFontAble)
  63. #define HOSTFONT_GETNAME(pUFO, ppName, psize, sfindex) \
  64. (UFLBool)(pUFO)->pUFL->fontProcs.pfHostFontUFLHandler(HOSTFONT_UFLREQUEST_GET_NAME, \
  65. (pUFO)->hHostFontData, \
  66. (ppName), (psize), \
  67. (pUFO)->hClientData, (sfindex))
  68. #define HOSTFONT_ISALLOWED(pUFO, pName) \
  69. (UFLBool)(pUFO)->pUFL->fontProcs.pfHostFontUFLHandler(HOSTFONT_UFLREQUEST_IS_ALLOWED, \
  70. (pUFO)->hHostFontData, \
  71. (pName), NULL, \
  72. NULL, 0)
  73. #define HOSTFONT_SAVE_CURRENTNAME(pUFO, pName) \
  74. (UFLBool)(pUFO)->pUFL->fontProcs.pfHostFontUFLHandler(HOSTFONT_UFLREQUEST_SET_CURRENTNAME, \
  75. (pUFO)->hHostFontData, \
  76. (pName), NULL, \
  77. NULL, 0)
  78. /*===============================================================================*
  79. * Classes defined in this interface *
  80. *===============================================================================*/
  81. typedef struct t_UFOStruct UFOStruct;
  82. typedef UFLErrCode (UFLCALLBACK *pfnUFODownloadIncr)(
  83. const UFOStruct *aFont,
  84. const UFLGlyphsInfo *pGlyphs,
  85. unsigned long *pVMUsage,
  86. unsigned long *pFCUsage /* Type 32 FontCache tracking */
  87. );
  88. typedef UFLErrCode (UFLCALLBACK *pfnUFOVMNeeded)(
  89. const UFOStruct *aFont,
  90. const UFLGlyphsInfo *pGlyphs,
  91. unsigned long *pVMNeeded,
  92. unsigned long *pFCNeeded /* Type 32 FontCache tracking */
  93. );
  94. typedef UFLErrCode (UFLCALLBACK *pfnUFOUndefineFont)(
  95. const UFOStruct *pFont
  96. );
  97. typedef void (UFLCALLBACK *pfnUFOCleanUp)(
  98. UFOStruct *pFont
  99. );
  100. typedef UFOStruct * (UFLCALLBACK *pfnUFOCopy)(
  101. const UFOStruct *pFont,
  102. const UFLRequest* pRequest
  103. );
  104. /*
  105. * This is the base font class.
  106. * Subclasses for each type of font is derived from this.
  107. */
  108. /*
  109. * A common, sharable structure to be used with TT-as-T1/T3/T42 or CFF.
  110. * Notice that it saves a bunch of pointers just a comvenient way to access
  111. * data and a common structure for functions such as GetGlyphName() and
  112. * GETFONTDATA().
  113. */
  114. typedef UFLHANDLE UFOHandle; /* a void Pointer */
  115. typedef struct t_AFontStruct {
  116. unsigned long refCount; /* reference counter of this structure */
  117. UFOHandle hFont; /* a pointer to a font dependent structure */
  118. UFLXUID Xuid; /* XUID array: copied from client or created from TTF file */
  119. unsigned char *pDownloadedGlyphs; /* list of downloaded glyphs for hFont */
  120. unsigned char *pVMGlyphs; /* list of downloaded glyphs, used to calculate VM usage */
  121. unsigned char *pCodeGlyphs; /* list of glyphs used to update Code Points in FontInfo */
  122. void *pTTpost; /* pointer to 'post' table for Speed */
  123. unsigned long dwTTPostSize; /* size of 'post' table */
  124. unsigned short gotTables:1,
  125. hascmap:1,
  126. hasmort:1,
  127. hasGSUB:1,
  128. hasPSNameStr:1,
  129. hasTTData:1,
  130. knownROS:1,
  131. hasvmtx:1, /* fix #358889 */
  132. unused:8;
  133. int info; /* DIST_SYSFONT_INFO_* bits */
  134. /*
  135. * Stuff used for GoodName
  136. */
  137. /* 'cmap' table data */
  138. unsigned long cmapTBSize;
  139. void *pTTcmap;
  140. TTcmapFormat cmapFormat;
  141. TTcmap2Stuff cmap2; /* convenient pointers/numbers */
  142. TTcmap4Stuff cmap4; /* convenient pointers/numbers */
  143. /* 'mort' table data */
  144. unsigned long mortTBSize;
  145. void *pTTmort;
  146. TTmortStuff mortStuff; /* convenient pointers/numbers */
  147. /* 'GSUB' table data */
  148. unsigned long gsubTBSize;
  149. void *pTTGSUB;
  150. TTGSUBStuff GSUBStuff; /* convenient pointers/numbers */
  151. /* a global string - to put unusual glyph-name in it. */
  152. char gGlyphName[MAX_GLYPHNAME_LEN];
  153. } AFontStruct;
  154. /*
  155. * Macros for managing AFontStruct
  156. */
  157. #define AFONT_AddRef(pDLGlyphs) ((pDLGlyphs)->refCount++)
  158. #define AFONT_Release(pDLGlyphs) ((pDLGlyphs)->refCount--)
  159. #define AFONT_RefCount(pDLGlyphs) ((pDLGlyphs)->refCount)
  160. /*
  161. * Universal Font Object class definition
  162. */
  163. typedef struct t_UFOStruct {
  164. int ufoType; /* font object type */
  165. UFLDownloadType lDownloadFormat; /* download format type */
  166. UFLFontState flState; /* flag used to keep track the state of the font. */
  167. UFLHANDLE hClientData; /* UFL Client private data (pointer to SUBFONT structure) */
  168. long lProcsetResID; /* resource ID of the required procset */
  169. unsigned long dwFlags; /* misc flags: has FontInfo, AddGlyphName2Unicode... */
  170. const UFLMemObj *pMem; /* UFL memory function pointer */
  171. const UFLStruct *pUFL; /* UFL common object pointer */
  172. /*
  173. * Data that is sharable among several instances
  174. */
  175. AFontStruct *pAFont; /* a font with a list of downloaded glyphs */
  176. /*
  177. * Data unique to the current font
  178. * A copy of a UFObj has a different name/encoding.
  179. */
  180. char *pszFontName; /* font name */
  181. unsigned long subfontNumber; /* subfont number of this font */
  182. long useMyGlyphName; /* If 1, use the glyph names passed in by client. */
  183. char *pszEncodeName; /* font encoding. If nil, then creat a font with names UFL likes. */
  184. unsigned char *pUpdatedEncoding; /* bits in Encoding Vector with correct name set */
  185. unsigned char *pEncodeNameList; /* Fix bug 274008 */
  186. unsigned short *pwCommonEncode; /* common encode list */
  187. unsigned short *pwExtendEncode; /* extended encode list */
  188. unsigned char *pMacGlyphNameList; /* Mac glyph name list */
  189. const UFLFontDataInfo *pFData; /* a pointer for access convenience */
  190. /*
  191. * Miscellenious
  192. */
  193. long lNumNT4SymGlyphs; /* Fix a GDI symbol font bug */
  194. UFLVPFInfo vpfinfo; /* Fix bug #287084, #309104, and #309482 */
  195. UFLBool bPatchQXPCFFCID; /* Fix bug #341904 */
  196. /*
  197. * %hostfont% support
  198. */
  199. UFLHANDLE hHostFontData; /* %hostfont% data handle */
  200. /*
  201. * UFO object type dependent methods
  202. */
  203. pfnUFODownloadIncr pfnDownloadIncr; /* incremental download function pointer */
  204. pfnUFOVMNeeded pfnVMNeeded; /* VM check function pointer */
  205. pfnUFOUndefineFont pfnUndefineFont; /* font undefine function pointer */
  206. pfnUFOCleanUp pfnCleanUp; /* object cleanup function pointer */
  207. pfnUFOCopy pfnCopy; /* object copy function pointer */
  208. } UFOStruct;
  209. /*
  210. * Number of glyphs in this font file - check against it for bounds.
  211. */
  212. #define UFO_NUM_GLYPHS(pUFObj) ((pUFObj)->pFData->cNumGlyphs)
  213. /*
  214. * Special font initialization status check
  215. */
  216. #define UFO_FONT_INIT2(pUFObj) ((pUFObj)->flState == kFontInit2)
  217. /*
  218. * Constant values for UFOStruct.ufoType
  219. */
  220. #define UFO_CFF 0
  221. #define UFO_TYPE1 1
  222. #define UFO_TYPE42 2
  223. #define UFO_TYPE3 3
  224. /*
  225. * UFO Function prototypes
  226. */
  227. UFLBool
  228. bUFOTestRestricted(
  229. const UFLMemObj *pMem,
  230. const UFLStruct *pSession,
  231. const UFLRequest *pRequest
  232. );
  233. UFOStruct * UFOInit(
  234. const UFLMemObj *pMem,
  235. const UFLStruct *pSession,
  236. const UFLRequest *pRequest
  237. );
  238. UFLErrCode UFODownloadIncr(
  239. const UFOStruct *aFont,
  240. const UFLGlyphsInfo *pGlyphs,
  241. unsigned long *pVMUsage,
  242. unsigned long *pFCUsage /* T32 FontCache tracking */
  243. );
  244. UFLErrCode UFOVMNeeded(
  245. const UFOStruct *aFont,
  246. const UFLGlyphsInfo *pGlyphs,
  247. unsigned long *pVMNeeded,
  248. unsigned long *pFCUsage /* T32 FontCache tracking */
  249. );
  250. UFLErrCode UFOUndefineFont(
  251. const UFOStruct *pFont
  252. );
  253. void UFOInitData(
  254. UFOStruct *pUFO,
  255. int ufoType,
  256. const UFLMemObj *pMem,
  257. const UFLStruct *pSession,
  258. const UFLRequest *pRequest,
  259. pfnUFODownloadIncr pfnDownloadIncr,
  260. pfnUFOVMNeeded pfnVMNeeded,
  261. pfnUFOUndefineFont pfnUndefineFont,
  262. pfnUFOCleanUp pfnCleanUp,
  263. pfnUFOCopy pfnCopy
  264. );
  265. void UFOCleanUpData(
  266. UFOStruct *pUFO
  267. );
  268. void UFOCleanUp(
  269. UFOStruct *aFont
  270. );
  271. UFOStruct *
  272. UFOCopyFont(
  273. const UFOStruct *aFont,
  274. const UFLRequest* pRequest
  275. );
  276. UFLErrCode
  277. UFOGIDsToCIDs(
  278. const UFOStruct *aFont,
  279. const short cGlyphs,
  280. const UFLGlyphID *pGIDs,
  281. unsigned short *pCIDs
  282. );
  283. /* fix bug 274008 & GoodName */
  284. UFLBool
  285. FindGlyphName(
  286. UFOStruct *pUFObj,
  287. const UFLGlyphsInfo *pGlyphs,
  288. short i,
  289. unsigned short wIndex,
  290. char **pGoodName
  291. );
  292. UFLBool
  293. ValidGlyphName(
  294. const UFLGlyphsInfo *pGlyphs,
  295. short i,
  296. unsigned short wIndex,
  297. char *pGoodName
  298. );
  299. UFLErrCode
  300. UpdateEncodingVector(
  301. UFOStruct *pUFO,
  302. const UFLGlyphsInfo *pGlyphs,
  303. short int sStart,
  304. short int sEnd
  305. );
  306. UFLErrCode
  307. UpdateCodeInfo(
  308. UFOStruct *pUFObj,
  309. const UFLGlyphsInfo *pGlyphs,
  310. UFLBool bT3T32Font // GoodName
  311. );
  312. UFLErrCode
  313. ReEncodePSFont(
  314. const UFOStruct *pUFO,
  315. const char *pszNewFontName,
  316. const char *pszNewEncodingName
  317. );
  318. UFLErrCode
  319. NewFont(
  320. UFOStruct *pUFO,
  321. unsigned long dwSize,
  322. const long cGlyphs
  323. );
  324. void
  325. vDeleteFont(
  326. UFOStruct *pUFO
  327. );
  328. UFOStruct *
  329. CopyFont(
  330. const UFOStruct *pUFO,
  331. const UFLRequest* pRequest
  332. );
  333. void
  334. VSetNumGlyphs(
  335. UFOStruct *pUFO,
  336. unsigned long cNumGlyphs
  337. );
  338. /* GoodName */
  339. unsigned short
  340. GetTablesFromTTFont(
  341. UFOStruct *pUFObj
  342. );
  343. /* GoodName */
  344. unsigned short
  345. ParseTTTablesForUnicode(
  346. UFOStruct *pUFObj,
  347. unsigned short gid,
  348. unsigned short *pUV,
  349. unsigned short wSize,
  350. TTparseFlag ParseFlag
  351. );
  352. UFLBool
  353. CheckGlyphName(
  354. UFOStruct *pUFObj,
  355. unsigned char *pszName
  356. );
  357. UFLBool
  358. HostFontValidateUFO(
  359. UFOStruct *pUFObj,
  360. char **ppHostFontName
  361. );
  362. #ifdef __cplusplus
  363. }
  364. #endif
  365. #endif