1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
4
<title>Castle Game Engine: CastleGLBitmapFonts: Class TGLBitmapFontAbstract</title>
5
<meta name="generator" content="PasDoc 0.12.1">
6
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
7
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
10
<table class="container"><tr><td class="navigation">
11
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
12
<a name="TGLBitmapFontAbstract"></a><h1 class="cio">Class TGLBitmapFontAbstract</h1>
13
<table class="sections wide_list">
15
<td><a class="section" href="#PasDoc-Description">Description</a></td><td><a class="section" href="#PasDoc-Hierarchy">Hierarchy</a></td><td>Fields</td><td><a class="section" href="#PasDoc-Methods">Methods</a></td><td><a class="section" href="#PasDoc-Properties">Properties</a></td></tr></table>
16
<a name="PasDoc-Description"></a><h2 class="unit">Unit</h2>
18
<a href="CastleGLBitmapFonts.html">CastleGLBitmapFonts</a></p>
19
<h2 class="declaration">Declaration</h2>
20
<p class="declaration">
21
<code>type TGLBitmapFontAbstract = class(TObject)</code></p>
22
<h2 class="description">Description</h2>
24
Abstract class for all OpenGL bitmap fonts.</p>
25
<a name="PasDoc-Hierarchy"></a><h2 class="hierarchy">Hierarchy</h2>
26
<ul class="hierarchy"><li class="ancestor">TObject</li>
27
<li class="thisitem">TGLBitmapFontAbstract</li></ul><h2 class="overview">Overview</h2>
28
<a name="PasDoc-Methods"></a><h3 class="summary">Methods</h3>
29
<table class="summary wide_list">
31
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
32
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintAndMove">PrintAndMove</a></b>(const s: string); virtual; abstract;</code></td>
35
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
36
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#Print">Print</a></b>(const s: string);</code></td>
39
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
40
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextWidth">TextWidth</a></b>(const s: string): integer; virtual; abstract;</code></td>
43
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
44
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeight">TextHeight</a></b>(const s: string): integer; virtual; abstract;</code></td>
47
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
48
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeightBase">TextHeightBase</a></b>(const s: string): integer; virtual; abstract;</code></td>
51
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
52
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#Descend">Descend</a></b>: integer; virtual;</code></td>
55
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
56
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#BreakLines">BreakLines</a></b>(const unbroken: string; broken: TStrings; maxLineWidth: integer); overload;</code></td>
59
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
60
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#BreakLines">BreakLines</a></b>(unbroken, broken: TStrings; maxLineWidth: integer); overload;</code></td>
63
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
64
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#BreakLines">BreakLines</a></b>(broken: TStrings; maxLineWidth: integer; FirstToBreak: integer); overload;</code></td>
67
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
68
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#MaxTextWidth">MaxTextWidth</a></b>(SList: TStringList; const Tags: boolean = false): integer;</code></td>
71
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
72
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a></b>(strs: TStrings; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const RasterX0: Integer = 0; const RasterY0: Integer = 0); overload;</code></td>
75
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
76
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a></b>(const strs: array of string; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const RasterX0: Integer = 0; const RasterY0: Integer = 0); overload;</code></td>
79
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
80
<td class="itemcode"><code>function <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintBrokenString">PrintBrokenString</a></b>(const s: string; MaxLineWidth, RasterX0, RasterY0: Integer; RasterPositionsFirst: boolean; BonusVerticalSpace: Integer): Integer;</code></td>
83
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
84
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStringsBox">PrintStringsBox</a></b>(const strs: array of string; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const InsideCol, BorderCol, TextCol: <a href="CastleGLUtils.html#TVector4f">TVector4f</a>; BoxPixelMargin: integer); overload;</code></td>
87
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
88
<td class="itemcode"><code>procedure <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStringsBox">PrintStringsBox</a></b>(strs: TStringList; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const InsideCol, BorderCol, TextCol: <a href="CastleGLUtils.html#TVector4f">TVector4f</a>; BoxPixelMargin: integer); overload;</code></td>
91
<a name="PasDoc-Properties"></a><h3 class="summary">Properties</h3>
92
<table class="summary wide_list">
94
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
95
<td class="itemcode"><code>property <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a></b>: integer read FRowHeight;</code></td>
98
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
99
<td class="itemcode"><code>property <b><a href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeightBase">RowHeightBase</a></b>: Integer read FRowHeightBase;</code></td>
102
<h2 class="description">Description</h2>
103
<h3 class="detail">Methods</h3>
104
<table class="detail wide_list">
106
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
107
<td class="itemcode"><a name="PrintAndMove"></a><code>procedure <b>PrintAndMove</b>(const s: string); virtual; abstract;</code></td>
111
Draw text at the current OpenGL raster position, and move the raster position at the end. This way you can immediately call another <code>PrintAndMove</code> again, to add something at the end.
113
<p>May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it moves raster position.</p>
116
<table class="detail wide_list">
118
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
119
<td class="itemcode"><a name="Print"></a><code>procedure <b>Print</b>(const s: string);</code></td>
123
Draw text at the current OpenGL raster position. In contrast to <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintAndMove">PrintAndMove</a>, raster position is not changed.
125
<p>May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix.</p>
128
<table class="detail wide_list">
130
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
131
<td class="itemcode"><a name="TextWidth"></a><code>function <b>TextWidth</b>(const s: string): integer; virtual; abstract;</code></td>
136
<table class="detail wide_list">
138
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
139
<td class="itemcode"><a name="TextHeight"></a><code>function <b>TextHeight</b>(const s: string): integer; virtual; abstract;</code></td>
144
<table class="detail wide_list">
146
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
147
<td class="itemcode"><a name="TextHeightBase"></a><code>function <b>TextHeightBase</b>(const s: string): integer; virtual; abstract;</code></td>
151
The height (above the baseline) of the text. This doesn't take into account height of the text below the baseline (for example letter "y" has the tail below the baseline in most fonts).</p>
154
<table class="detail wide_list">
156
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
157
<td class="itemcode"><a name="Descend"></a><code>function <b>Descend</b>: integer; virtual;</code></td>
161
How low the text may go below the baseline. By default this returns <code><a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeight">TextHeight</a>('y')-<a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeight">TextHeight</a>('a')</code>, which is suitable for normal fonts.</p>
164
<table class="detail wide_list">
166
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
167
<td class="itemcode"><a name="BreakLines"></a><code>procedure <b>BreakLines</b>(const unbroken: string; broken: TStrings; maxLineWidth: integer); overload;</code></td>
171
Break lines (possibly break one long string into more strings) to fit the text with given MaxLineWidth.
173
<p>This takes into account current font information (works also for non-monospace fonts, of course), and converts your Unbroken text into Broken text, such that <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextWidth">TextWidth</a> of the longest Broken line fits within MaxLineWidth.
175
<p>Tries to break on white characters. If not possible (there's a long stream of non-white characters that really has to be broken), it will break in the middle of normal (non-white) characters. The only situation when we have to fail, and the resulting Broken text is wider than required MaxLineWidth, is when <i>a single character in your font</i> is wider than MaxLineWidth. In such case, there's really no solution, and we'll just let such character stay.
177
<p>If you use the overloaded version where Unbroken is just a string, then note that already existing newlines (<a class="normal" href="CastleUtils.html#NL">NL</a>) inside Unbroken will be correctly preserved.
179
<p>If you use the overloaded version with separate Unbroken and Broken parameters, then the previous Broken contents are not modified. We only append to Broken new strings, coming from Unbroken text. The overloaded version that takes only Broken parameter (no Unbroken parameter) simply modifies it's Broken parameter (from the line FirstToBreak).
184
<table class="detail wide_list">
186
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
187
<td class="itemcode"><a name="BreakLines"></a><code>procedure <b>BreakLines</b>(unbroken, broken: TStrings; maxLineWidth: integer); overload;</code></td>
192
<table class="detail wide_list">
194
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
195
<td class="itemcode"><a name="BreakLines"></a><code>procedure <b>BreakLines</b>(broken: TStrings; maxLineWidth: integer; FirstToBreak: integer); overload;</code></td>
200
<table class="detail wide_list">
202
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
203
<td class="itemcode"><a name="MaxTextWidth"></a><code>function <b>MaxTextWidth</b>(SList: TStringList; const Tags: boolean = false): integer;</code></td>
207
Largest width of the line of text in given list.
210
<h6 class="description_section">Parameters</h6>
211
<dl class="parameters">
213
<dd>Indicates that strings inside SList use HTML-like tags, the same as interpreted by <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a>. If your SList uses these tags (for example, you plan to call later <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a> with the same SList and Tags = <code>True</code>) then make sure you pass Tags = <code>True</code> to this method. Otherwise, <code>MaxTextWidth</code> will treat tags text (like <code><font ...></code>) like a normal text, usually making the width incorrectly large.</dd>
217
<table class="detail wide_list">
219
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
220
<td class="itemcode"><a name="PrintStrings"></a><code>procedure <b>PrintStrings</b>(strs: TStrings; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const RasterX0: Integer = 0; const RasterY0: Integer = 0); overload;</code></td>
224
Print all strings from the list. glRasterPos2i(RasterX0, RasterY0) is the position of the last string, each previous string will be <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a> + BonusVerticalSpace higher.
226
<p>Note that BonusVerticalSpace can be < 0 (as well as > 0), this may be sometimes useful if you really want to squeeze more text into some size. Still, make sure that (<a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a> + BonusVerticalSpace) is > 0.
228
<p>Previous OpenGL raster position value will be ignored and then modified by this method.
230
<p>May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it moves raster position.
235
<h6 class="description_section">Parameters</h6>
236
<dl class="parameters">
238
<dd>Enable some HTML-like tags to mark font changes inside the text. For now, these can only be used to surround whole lines (so you have to place opening tag at the beginnig of line, and closing tag at the end of line). And for now, the only tag handled is <code><font color="#rrggbb"></code> that changes line color to specified RGB. Close with <code></font></code>.
240
<p>This functionality may be enhanced in the future (feature requests and patches welcome). Don't expect full HTML implementation inside, but some small set of useful tags may be doable and comfortable to use. Not necessarily replicating some (old version of) HTML standard.</dd>
244
<table class="detail wide_list">
246
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
247
<td class="itemcode"><a name="PrintStrings"></a><code>procedure <b>PrintStrings</b>(const strs: array of string; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const RasterX0: Integer = 0; const RasterY0: Integer = 0); overload;</code></td>
252
<table class="detail wide_list">
254
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
255
<td class="itemcode"><a name="PrintBrokenString"></a><code>function <b>PrintBrokenString</b>(const s: string; MaxLineWidth, RasterX0, RasterY0: Integer; RasterPositionsFirst: boolean; BonusVerticalSpace: Integer): Integer;</code></td>
259
Print the string, broken such that it fits within MaxLineWidth. The string is broken into many lines using <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#BreakLines">BreakLines</a>, so the original newlines insides are correctly used, and the length of lines fits inside MaxLineWidth.
261
<p>The strings are printed on the screen, just like by <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a> (with Tags = always false for now, since our string breaking cannot omit tags). If RasterPositionsFirst then the RasterX0, RasterY0 determine the position of the first (top) line, otherwise they determine the position of the last (bottom) line.
263
<p>BonusVerticalSpace has the same meaning as for <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a>: it adds an additional space between lines (if positive) or forces the lines to be more tightly squeezed (if negative). Always make sure that (<a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a> + BonusVerticalSpace) > 0.
265
<p>Returns the number of lines printed, that is the number of lines after breaking the text into lines. This may be useful e.g. to calculate the height of the printed text.
267
<p>May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix.</p>
270
<table class="detail wide_list">
272
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
273
<td class="itemcode"><a name="PrintStringsBox"></a><code>procedure <b>PrintStringsBox</b>(const strs: array of string; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const InsideCol, BorderCol, TextCol: <a href="CastleGLUtils.html#TVector4f">TVector4f</a>; BoxPixelMargin: integer); overload;</code></td>
277
Print all strings from the list, and draw a box with frames around it.
279
<p>The text is printed like by <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a>.
281
<p>The position of the text and box is determined by the current modelview matrix. The left-bottom box corner is at raster position 0, 0. The current raster position when this method is called doesn't matter. So your only way to move this box is to modify modelview matrix.
283
<p>BonusVerticalSpace has the same interpretation as for <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#PrintStrings">PrintStrings</a>: additional space between lines (if positive) or forces the lines to be more tightly squeezed (if negative). Always make sure that (<a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a> + BonusVerticalSpace) > 0.
285
<p>The box background inside has color InsideCol. The box frame has color BorderCol. The text has color TextCol.
287
<p>BoxPixelMargin is the distance (in pixels) between text and the box frame.
289
<p>We assume that moving by 1 in modelview matrix is equal to moving 1 pixel. In other words, we assume you have normal 2D orthographic projection with the dimensions equal to pixel dimensions.
291
<p>May require 1 free slot on the attributes stack. May only be called when current matrix is modelview. Doesn't modify any OpenGL state or matrix, except it modifies the raster position.
296
<table class="detail wide_list">
298
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
299
<td class="itemcode"><a name="PrintStringsBox"></a><code>procedure <b>PrintStringsBox</b>(strs: TStringList; const Tags: boolean; BonusVerticalSpace: <a href="CastleGLUtils.html#TGLint">TGLint</a>; const InsideCol, BorderCol, TextCol: <a href="CastleGLUtils.html#TVector4f">TVector4f</a>; BoxPixelMargin: integer); overload;</code></td>
304
<h3 class="detail">Properties</h3>
305
<table class="detail wide_list">
307
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
308
<td class="itemcode"><a name="RowHeight"></a><code>property <b>RowHeight</b>: integer read FRowHeight;</code></td>
312
Height of a row of text in this font. This may be calculated as simply <code><a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeight">TextHeight</a>('Wy')</code> for most normal fonts.</p>
315
<table class="detail wide_list">
317
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
318
<td class="itemcode"><a name="RowHeightBase"></a><code>property <b>RowHeightBase</b>: Integer read FRowHeightBase;</code></td>
322
Height (above the baseline) of a row of text in this font. Similar to <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeightBase">TextHeightBase</a> and <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#TextHeight">TextHeight</a>, note that <code>RowHeightBase</code> is generally smaller than <a class="normal" href="CastleGLBitmapFonts.TGLBitmapFontAbstract.html#RowHeight">RowHeight</a>, because <code>RowHeightBase</code> doesn't care how low the letter may go below the baseline.</p>
325
<hr noshade size="1"><span class="appinfo"><em>Generated by <a href="http://pasdoc.sourceforge.net/">PasDoc 0.12.1</a> on 2013-02-04 20:26:50</em>
327
</td></tr></table></body></html>