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.

332 lines
8.6 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: lfntobj.hxx
  3. *
  4. * The logical font user object and memory object.
  5. *
  6. * The logical font:
  7. * ----------------
  8. *
  9. * o represents "wish list" of font attributes
  10. *
  11. * o a logical font may map to one or more realized fonts
  12. *
  13. * o multiple DCs may have the same logical font selected simultaneously
  14. *
  15. * o except for stock fonts, logical fonts are not shared between
  16. * processes
  17. *
  18. * o concerned with creation, deletion, selection, and realization:
  19. *
  20. * o logical fonts are created by calling CreateFont or
  21. * CreateFontIndirect at the API
  22. *
  23. * o logical fonts are selected into a DC by calling SelectObject at
  24. * the API
  25. *
  26. * o logical fonts are deleted by calling DeleteObject at the API
  27. *
  28. * o logical fonts are lazily mapped/realized (realization postponed to
  29. * the last possible moment)
  30. *
  31. * o text out time
  32. *
  33. * o querying the metrics of currently selected font
  34. *
  35. * o etc.
  36. *
  37. * o supports the following APIs:
  38. *
  39. * o CreateFont/CreateFontIndirect
  40. *
  41. * o DeleteObject
  42. *
  43. *
  44. * Created: 25-Oct-1990 13:13:03
  45. * Author: Gilman Wong [gilmanw]
  46. *
  47. * Copyright (c) 1990-1999 Microsoft Corporation
  48. \**************************************************************************/
  49. #ifndef _LFNTOBJ_
  50. #define _LFNTOBJ_
  51. #define TSIM_UNDERLINE1 0x00000020 // single underline
  52. #define TSIM_UNDERLINE2 0x00000040 // double underline
  53. #define TSIM_STRIKEOUT 0x00000080 // strike out
  54. #ifndef GDIFLAGS_ONLY // used for gdikdx
  55. struct MAPCACHE
  56. {
  57. HDEV hdev;
  58. EFLOAT efM11;
  59. EFLOAT efM12;
  60. EFLOAT efM21;
  61. EFLOAT efM22;
  62. HPFEC hpfec;
  63. ULONG iFont;
  64. FLONG flSim;
  65. POINTL ptlSim;
  66. FLONG flAboutMatch;
  67. ULONG iBitmapFormat; // pdc->dclevel->pSurface->so.iBitmapFormat
  68. };
  69. #endif // GDIFLAGS_ONLY used for gdikdx
  70. #define MAXCACHEENTRIES 3
  71. /**************************************************************************\
  72. * LFONT flags.
  73. *
  74. * Allowed properties of a LFONT:
  75. *
  76. * Aliased -- an aliased LFONT is device specific. An aliased LFONT
  77. * represents a SET OF LFONTs. The specfic member of the set
  78. * represented in any given instance is dependent upon the
  79. * the device (i.e., varies with DC).
  80. *
  81. * Stock -- a stock LFONT.
  82. *
  83. * Undeletable -- flag is set for non-stock fonts which are undeletable
  84. * (like USERSRV cached fonts).
  85. *
  86. *
  87. * Aliased Stock
  88. * -----------------
  89. * 0 0 user (app) defined LFONT
  90. * 0 1 stock font
  91. * 1 0 NOT ALLOWED
  92. * 1 1 aliased stock font
  93. *
  94. \**************************************************************************/
  95. #define LF_FLAG_ALIASED 0x00000001
  96. #define LF_FLAG_STOCK 0x00000002
  97. /*********************************Class************************************\
  98. * class LFONT : public OBJECT
  99. *
  100. * Logical font object
  101. *
  102. * lft LFONT type. An enumerated type.
  103. *
  104. * fl LFONT flags.
  105. *
  106. * elfw The attributes of this logical font.
  107. *
  108. * cMapsInCache Number of entries in the font mapping cache.
  109. *
  110. * mapcache Cache of font mappings.
  111. *
  112. * History:
  113. * 25-Oct-1990 -by- Gilman Wong [gilmanw]
  114. * Wrote it.
  115. \**************************************************************************/
  116. #ifndef GDIFLAGS_ONLY // used for gdikdx
  117. class LFONT : public OBJECT /* lfnt */
  118. {
  119. public:
  120. // state
  121. LFTYPE lft; // font type
  122. FLONG fl; // flags
  123. // Font mapping cache
  124. INT cMapsInCache;
  125. MAPCACHE mapcache[MAXCACHEENTRIES];
  126. WCHAR wcCapFacename[LF_FACESIZE];
  127. // data
  128. ULONG cjElfw_; // size of ENUMLOGFONTEXDVW appended at the end
  129. ENUMLOGFONTEXW elfw; // logical font attributes, really
  130. };
  131. typedef LFONT *PLFONT;
  132. EFLOAT efCvtTenths(LONG l);
  133. /**************************************************************************\
  134. * Allowed Bit fields for flAboutMatch, returned by *
  135. * LFONTOBJ::ppfeMapFont() *
  136. \**************************************************************************/
  137. #define MAPFONT_FOUND_NAME 0x00000001 // facename matched
  138. #define MAPFONT_ALTFACE_USED 0x00000002 // alternate facename matched
  139. /*********************************Class************************************\
  140. * class LFONTOBJ
  141. *
  142. * User object for logical fonts.
  143. *
  144. * History:
  145. * 25-Oct-1990 -by- Gilman Wong [gilmanw]
  146. * Wrote it.
  147. \**************************************************************************/
  148. BOOL bDeleteFont(HLFONT,BOOL);
  149. class PFE;
  150. class LFONTOBJ /* lfo */
  151. {
  152. public:
  153. PLFONT plfnt; // pointer to logical font object
  154. public:
  155. // Constructors -- lock LFONT object.
  156. LFONTOBJ (HLFONT hlfnt, PDEVOBJ* ppdo = (PDEVOBJ *) NULL);
  157. ~LFONTOBJ ()
  158. {
  159. if (plfnt != NULL)
  160. {
  161. DEC_SHARE_REF_CNT_LAZY_DEL_LOGFONT(plfnt);
  162. }
  163. }
  164. BOOL bValid () { return(plfnt != NULL); }
  165. HLFONT hlfnt () { return((HLFONT) plfnt->hGet()); }
  166. FLONG fl() { return(plfnt->fl); }
  167. // hrfntRealizeFont -- return HRFONT that matches the LFONT.
  168. PFE *ppfeMapFont(XDCOBJ& dco,
  169. FLONG* pflSim,
  170. POINTL *pptlSim,
  171. FLONG *pflAboutMatch,
  172. BOOL bIndexFont = FALSE
  173. );
  174. // plfw -- return pointer to LOGFONTW structure.
  175. PLOGFONTW plfw()
  176. {
  177. return (&(plfnt->elfw.elfLogFont));
  178. }
  179. ENUMLOGFONTEXDVW * pelfw()
  180. {
  181. return ((ENUMLOGFONTEXDVW *)(&(plfnt->elfw)));
  182. }
  183. ULONG cjElfw() { return plfnt->cjElfw_; }
  184. // gets the escapement in tenths of degrees and converts the
  185. // to the corresponding EFLOAT that our efSine and efCosine routines
  186. // understand
  187. LONG lEscapement()
  188. {
  189. return (plfnt->elfw.elfLogFont.lfEscapement);
  190. }
  191. #ifdef FE_SB
  192. ULONG ulOrientation()
  193. {
  194. return (plfnt->elfw.elfLogFont.lfOrientation);
  195. }
  196. LONG lWidth()
  197. {
  198. return (plfnt->elfw.elfLogFont.lfWidth);
  199. }
  200. LONG lHeight()
  201. {
  202. return (plfnt->elfw.elfLogFont.lfHeight);
  203. }
  204. LONG lWidth( LONG lWidth )
  205. {
  206. LONG lSave = plfnt->elfw.elfLogFont.lfWidth;
  207. plfnt->elfw.elfLogFont.lfWidth = lWidth;
  208. return( lSave );
  209. }
  210. LONG lHeight( LONG lHeight )
  211. {
  212. LONG lSave = plfnt->elfw.elfLogFont.lfHeight;
  213. plfnt->elfw.elfLogFont.lfHeight = lHeight;
  214. return( lSave );
  215. }
  216. ULONG ulOrientation( ULONG ulOrientation )
  217. {
  218. ULONG ulSave = plfnt->elfw.elfLogFont.lfOrientation;
  219. plfnt->elfw.elfLogFont.lfOrientation = ulOrientation;
  220. return( ulSave );
  221. }
  222. LONG lEscapement( LONG lEscapement )
  223. {
  224. LONG lSave = plfnt->elfw.elfLogFont.lfEscapement;
  225. plfnt->elfw.elfLogFont.lfEscapement = lEscapement;
  226. return( lSave );
  227. }
  228. FLONG flEudcFontItalicSimFlags( BOOL bNonSimItalic, BOOL bSimItalic )
  229. {
  230. FLONG fl = 0L;
  231. if (!bNonSimItalic && /* font is already italicalized ? */
  232. plfnt->elfw.elfLogFont.lfItalic && /* italized style is requested ? */
  233. bSimItalic ) /* can do italic simulation ? */
  234. {
  235. fl |= FO_SIM_ITALIC;
  236. }
  237. return (fl);
  238. }
  239. FLONG flEudcFontBoldSimFlags( USHORT usNonSimWeight )
  240. {
  241. LONG lWish = plfnt->elfw.elfLogFont.lfWeight;
  242. LONG lPen = (LONG)usNonSimWeight - (( lWish ) ? ( lWish ) : FW_NORMAL);
  243. FLONG fl = 0L;
  244. if( lPen < 0 )
  245. {
  246. fl |= FO_SIM_BOLD;
  247. }
  248. return (fl);
  249. }
  250. #endif
  251. // flSimulationFlags -- returns the text simulation flags
  252. FLONG flSimulationFlags()
  253. {
  254. FLONG fl = 0L;
  255. if (plfnt->elfw.elfLogFont.lfUnderline)
  256. fl |= TSIM_UNDERLINE1;
  257. if (plfnt->elfw.elfLogFont.lfStrikeOut)
  258. fl |= TSIM_STRIKEOUT;
  259. return (fl);
  260. }
  261. #if DBG
  262. // vDump -- debugging info.
  263. VOID vDump (); // LFNTOBJ.CXX
  264. #endif
  265. };
  266. typedef LFONTOBJ *PLFONTOBJ;
  267. #endif // GDIFLAGS_ONLY used for gdikdx
  268. #endif