render_text.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <html>
  2. <head>
  3. <title>Bitmap Font Generator - Documentation</title>
  4. </head>
  5. <body>
  6. <h1>Bitmap Font Generator - Documentation</h1>
  7. <p><a href="../documentation.html">Back to main page</a></p>
  8. <p><img src="measures.png" align="right"></p>
  9. <h2>How to interpret the values in the font descriptor file</h2>
  10. <p>The image to the right illustrates some of the values found in the
  11. <A href="file_format.html">font descriptor file</a>. The two dotted lines
  12. shows the <tt>lineHeight</tt>, i.e. how far the cursor should be moved
  13. vertically when moving to the next line.</p>
  14. <p>The <tt>base</tt> value is how far from the top of the cell height the
  15. base of the characters in the font should be placed. Characters can of course
  16. extend above or below this base line, which is entirely up to the font design.</p>
  17. <p>The filled red dot marks the current cursor position, and the hollow red dot
  18. marks the position of the cursor after drawing the character. You get to this
  19. position by moving the cursor horizontally with the <tt>xadvance</tt> value. If
  20. kerning pairs are used the cursor should also be moved accordingly.</p>
  21. <p>The <tt>yoffset</tt> gives the distance from the top of the cell height to
  22. the top of the character. A negative value here would mean that the character
  23. extends above the cell height. The <tt>xoffset</tt> gives the horizontal offset
  24. that should be added to the cursor position to find the left position where the
  25. character should be drawn. A negative value here would mean that the character
  26. slightly overlaps the previous character. Observe that these values shouldn't
  27. be used to move the cursor position.</p>
  28. <p>The green rectangle illustrates the quad that should be copied from the texture
  29. to the screen when rendering the character. The <tt>width</tt> and <tt>height</tt>
  30. gives the size of this rectangle, and <tt>x</tt> and <tt>y</tt> gives the position
  31. of the rectangle in the texture.</p>
  32. <h2>Rendering colored text with outline</h2>
  33. <p>When the bitmap font has been generated with a baked outline, i.e. the outline is
  34. pre-generated in the font texture, the text is best rendered in two passes to avoid
  35. the outline for a character to overlap the previous character.</p>
  36. <p>In the first pass the application should use only the alpha channel of the font
  37. texture as the transparency value when rendering the border.</p>
  38. <p>In the second pass the application should use only the color channels of the font
  39. texture as the transparency value to render the characters over the border.</p>
  40. <p>With a two-pass rendering like this it is also very easy to apply different colors
  41. to the border and the internal characters dynamically without the need to pre-color
  42. the font in the texture. The application simply needs to multiply the transparency value
  43. the desired color before blending it to the screen.</p>
  44. </body>
  45. </html>