1 | <HTML> |
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
3 | <!-- Created on , 12 2006 by texi2html 1.64 --> |
---|
4 | <!-- |
---|
5 | Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) |
---|
6 | Karl Berry <karl@freefriends.org> |
---|
7 | Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
8 | and many others. |
---|
9 | Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de> |
---|
10 | Send bugs and suggestions to <texi2html@mathematik.uni-kl.de> |
---|
11 | |
---|
12 | --> |
---|
13 | <HEAD> |
---|
14 | <TITLE>OGRE Manual v1.2.0 ('Dagon'): Font Definition Scripts</TITLE> |
---|
15 | |
---|
16 | <META NAME="description" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Font Definition Scripts"> |
---|
17 | <META NAME="keywords" CONTENT="OGRE Manual v1.2.0 ('Dagon'): Font Definition Scripts"> |
---|
18 | <META NAME="resource-type" CONTENT="document"> |
---|
19 | <META NAME="distribution" CONTENT="global"> |
---|
20 | <META NAME="Generator" CONTENT="texi2html 1.64"> |
---|
21 | <LINK TYPE="text/css" rel="stylesheet" href="../style.css"> |
---|
22 | </HEAD> |
---|
23 | |
---|
24 | <BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"> |
---|
25 | |
---|
26 | <A NAME="SEC222"></A> |
---|
27 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
28 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_35.html#SEC217"> < </A>]</TD> |
---|
29 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> Up </A>]</TD> |
---|
30 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_37.html#SEC225"> > </A>]</TD> |
---|
31 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
32 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
33 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
34 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
35 | </TR></TABLE> |
---|
36 | <HR SIZE=1> |
---|
37 | <H2> 3.5 Font Definition Scripts </H2> |
---|
38 | <!--docid::SEC222::--> |
---|
39 | <P> |
---|
40 | |
---|
41 | Ogre uses texture-based fonts to render the TextAreaOverlayElement. You can also use the Font object for your own purpose if you wish. The final form of a font is a Material object generated by the font, and a set of 'glyph' (character) texture coordinate information.<BR><BR> |
---|
42 | </P><P> |
---|
43 | |
---|
44 | There are 2 ways you can get a font into OGRE: |
---|
45 | <OL> |
---|
46 | <LI>Design a font texture yourself using an art package or font generator tool |
---|
47 | <LI>Ask OGRE to generate a font texture based on a truetype font |
---|
48 | </OL> |
---|
49 | <P> |
---|
50 | |
---|
51 | The former gives you the most flexibility and the best performance (in terms of startup times), but the latter is convenient if you want to quickly use a font without having to generate the texture yourself. I suggest prototyping using the latter and change to the former for your final solution.<BR><BR> |
---|
52 | </P><P> |
---|
53 | |
---|
54 | All font definitions are held in .fontdef files, which are parsed by the system at startup time. Each .fontdef file can contain multiple font definitions. The basic fomat of an entry in the .fontdef file is: |
---|
55 | <TABLE><tr><td> </td><td class=example><pre><font_name> |
---|
56 | { |
---|
57 | type <image | truetype> |
---|
58 | source <image file | truetype font file> |
---|
59 | ... |
---|
60 | ... custom attributes depending on type |
---|
61 | } |
---|
62 | </pre></td></tr></table></P><P> |
---|
63 | |
---|
64 | <A NAME="SEC223"></A> |
---|
65 | <H2> Using an existing font texture </H2> |
---|
66 | <!--docid::SEC223::--> |
---|
67 | <P> |
---|
68 | |
---|
69 | If you have one or more artists working with you, no doubt they can produce you a very nice font texture. OGRE supports full colour font textures, or alternatively you can keep them monochrome / greyscale and use TextArea's colouring feature. Font textures should always have an alpha channel, preferably an 8-bit alpha channel such as that supported by TGA and PNG files, because it can result in much nicer edges. To use an existing texture, here are the settings you need: |
---|
70 | <DL COMPACT> |
---|
71 | <DT>type image |
---|
72 | <DD>This just tells OGRE you want a pre-drawn font. |
---|
73 | <DT>source <filename> |
---|
74 | <DD>This is the name of the image file you want to load. This will be loaded from the standard TextureManager resource locations and can be of any type OGRE supports, although JPEG is not recommended because of the lack of alpha and the lossy compression. I recommend PNG format which has both good lossless compression and an 8-bit alpha channel. |
---|
75 | <DT>glyph <character> <u1> <v1> <u2> <v2> |
---|
76 | <DD>This provides the texture coordinates for the specified character. You must repeat this for every character you have in the texture. The first 2 numbers are the x and y of the top-left corner, the second two are the x and y of the bottom-right corner. Note that you really should use a common height for all characters, but widths can vary because of proportional fonts. |
---|
77 | </DL> |
---|
78 | <P> |
---|
79 | |
---|
80 | A note for Windows users: I recommend using BitmapFontBuilder (<A HREF="http://www.lmnopc.com/bitmapfontbuilder/">http://www.lmnopc.com/bitmapfontbuilder/</A>), a free tool which will generate a texture and export character widths for you, you can find a tool for converting the binary output from this into 'glyph' lines in the Tools folder.<BR> |
---|
81 | </P><P> |
---|
82 | |
---|
83 | <A NAME="SEC224"></A> |
---|
84 | <H2> Generating a font texture </H2> |
---|
85 | <!--docid::SEC224::--> |
---|
86 | <P> |
---|
87 | |
---|
88 | You can also generate font textures on the fly using truetype fonts. I don't recommend heavy use of this in production work because rendering the texture can take a several seconds per font which adds to the loading times. However it is a very nice way of quickly getting text output in a font of your choice.<BR><BR> |
---|
89 | </P><P> |
---|
90 | |
---|
91 | Here are the attributes you need to supply: |
---|
92 | <DL COMPACT> |
---|
93 | <DT>type truetype |
---|
94 | <DD>Tells OGRE to generate the texture from a font |
---|
95 | <DT>source <ttf file> |
---|
96 | <DD>The name of the ttf file to load. This will be searched for in the common resource locations and in any resource locations added to FontManager. |
---|
97 | <DT>size <size_in_points> |
---|
98 | <DD>The size at which to generate the font, in standard points. Note this only affects how big the characters are in the font texture, not how big they are on the screen. You should tailor this depending on how large you expect to render the fonts because generating a large texture will result in blurry characters when they are scaled very small (because of the mipmapping), and conversely generating a small font will result in blocky characters if large text is rendered. |
---|
99 | <DT>resolution <dpi> |
---|
100 | <DD>The resolution in dots per inch, this is used in conjunction with the point size to determine the final size. 72 / 96 dpi is normal. |
---|
101 | <DT>antialias_colour <true|false> |
---|
102 | <DD>This is an optional flag, which defaults to 'false'. The generator will antialias the font by default using the alpha component of the texture, which will look fine if you use alpha blending to render your text (this is the default assumed by TextAreaOverlayElement for example). If, however you wish to use a colour based blend like add or modulate in your own code, you should set this to 'true' so the colour values are anitaliased too. If you set this to true and use alpha blending, you'll find the edges of your font are antialiased too quickly resulting in a 'thin' look to your fonts, because not only is the alpha blending the edges, the colour is fading too. Leave this option at the default if in doubt. |
---|
103 | </DL> |
---|
104 | <BR><BR> |
---|
105 | You can also create new fonts at runtime by using the FontManager if you wish. |
---|
106 | <P> |
---|
107 | |
---|
108 | <A NAME="Mesh Tools"></A> |
---|
109 | <HR SIZE=1> |
---|
110 | <TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> |
---|
111 | <TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_35.html#SEC217"> < </A>]</TD> |
---|
112 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_13.html#SEC22"> Up </A>]</TD> |
---|
113 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_37.html#SEC225"> > </A>]</TD> |
---|
114 | <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD> |
---|
115 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_toc.html#SEC_Contents">Contents</A>]</TD> |
---|
116 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD> |
---|
117 | <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="manual_abt.html#SEC_About"> ? </A>]</TD> |
---|
118 | </TR></TABLE> |
---|
119 | <BR> |
---|
120 | <FONT SIZE="-1"> |
---|
121 | This document was generated |
---|
122 | by <I>Steve Streeting</I> on <I>, 12 2006</I> |
---|
123 | using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html |
---|
124 | "><I>texi2html</I></A> |
---|
125 | |
---|
126 | </BODY> |
---|
127 | </HTML> |
---|