setfont.htm 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
  5. <TITLE>SetFont</TITLE>
  6. <LINK TYPE="text/css" REL="stylesheet" HREF="../fpdf.css">
  7. </HEAD>
  8. <BODY>
  9. <H2>SetFont</H2>
  10. <TT>SetFont(<B>string</B> family [, <B>string</B> style [, <B>float</B> size]])</TT>
  11. <H4 CLASS='st'>Version</H4>
  12. 1.0
  13. <H4 CLASS='st'>Description</H4>
  14. Sets the font used to print character strings. It is mandatory to call this method
  15. at least once before printing text or the resulting document would not be valid.
  16. <BR>
  17. The font can be either a standard one or a font added via the AddFont() method. Standard fonts
  18. use Windows encoding cp1252 (Western Europe).
  19. <BR>
  20. The method can be called before the first page is created and the font is retained from page
  21. to page.
  22. <BR>
  23. If you just wish to change the current font size, it is simpler to call SetFontSize().
  24. <BR>
  25. <BR>
  26. <B>Note:</B> the font metric files must be accessible. They are searched successively in:
  27. <UL>
  28. <LI>The directory defined by the <TT>FPDF_FONTPATH</TT> constant (if this constant is defined)
  29. <LI>The <TT>font</TT> directory located in the directory containing <TT>fpdf.php</TT> (if it exists)
  30. <LI>The directories accessible through <TT>include()</TT>
  31. </UL>
  32. Example defining <TT>FPDF_FONTPATH</TT> (note the mandatory trailing slash):
  33. <BR>
  34. <BR>
  35. <TABLE WIDTH="100%" BGCOLOR="#E0E0E0"><TR><TD>
  36. <TT>
  37. define('FPDF_FONTPATH','/home/www/font/');<BR>
  38. require('fpdf.php');
  39. </TT>
  40. </TD></TR></TABLE><BR>
  41. If the file corresponding to the requested font is not found, the error "Could not include
  42. font metric file" is issued.
  43. <H4 CLASS='st'>Parameters</H4>
  44. <TT><U>family</U></TT>
  45. <BLOCKQUOTE>
  46. Family font. It can be either a name defined by AddFont() or one of the standard families (case
  47. insensitive):
  48. <UL>
  49. <LI><TT>Courier</TT> (fixed-width)
  50. <LI><TT>Helvetica</TT> or <TT>Arial</TT> (synonymous; sans serif)
  51. <LI><TT>Times</TT> (serif)
  52. <LI><TT>Symbol</TT> (symbolic)
  53. <LI><TT>ZapfDingbats</TT> (symbolic)
  54. </UL>
  55. It is also possible to pass an empty string. In that case, the current family is retained.
  56. </BLOCKQUOTE>
  57. <TT><U>style</U></TT>
  58. <BLOCKQUOTE>
  59. Font style. Possible values are (case insensitive):
  60. <UL>
  61. <LI>empty string: regular
  62. <LI><TT>B</TT>: bold
  63. <LI><TT>I</TT>: italic
  64. <LI><TT>U</TT>: underline
  65. </UL>
  66. or any combination. The default value is regular.
  67. Bold and italic styles do not apply to <TT>Symbol</TT> and <TT>ZapfDingbats</TT>.
  68. </BLOCKQUOTE>
  69. <TT><U>size</U></TT>
  70. <BLOCKQUOTE>
  71. Font size in points.
  72. <BR>
  73. The default value is the current size. If no size has been specified since the beginning of
  74. the document, the value taken is 12.
  75. </BLOCKQUOTE>
  76. <H4 CLASS='st'>Example</H4>
  77. <TABLE WIDTH="100%" BGCOLOR="#E0E0E0"><TR><TD>
  78. <TT>
  79. //Times regular 12<BR>
  80. $pdf-&gt;SetFont('Times');<BR>
  81. //Arial bold 14<BR>
  82. $pdf-&gt;SetFont('Arial','B',14);<BR>
  83. //Removes bold<BR>
  84. $pdf-&gt;SetFont('');<BR>
  85. //Times bold, italic and underlined 14<BR>
  86. $pdf-&gt;SetFont('Times','BIU');
  87. </TT>
  88. </TD></TR></TABLE><BR>
  89. <H4 CLASS='st'>See also</H4>
  90. <A HREF="addfont.htm">AddFont()</A>,
  91. <A HREF="setfontsize.htm">SetFontSize()</A>,
  92. <A HREF="cell.htm">Cell()</A>,
  93. <A HREF="multicell.htm">MultiCell()</A>,
  94. <A HREF="write.htm">Write()</A>.
  95. <HR STYLE="margin-top:1.2em">
  96. <DIV ALIGN="CENTER"><A HREF="index.htm">Index</A></DIV>
  97. </BODY>
  98. </HTML>