140 lines
5.1 KiB
HTML
140 lines
5.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
|
<html>
|
|
<head>
|
|
<title>Fonts and Text</title>
|
|
<link href="style.css" rel="stylesheet" type="text/css">
|
|
</head>
|
|
<body background="images/back.gif">
|
|
<!--START-->
|
|
|
|
<H3>Fonts and text</H3>
|
|
|
|
In games you sometimes need to draw texts. To draw a text you have to specify the
|
|
font to use. Fonts can be defined by creating font resources (either in the
|
|
<I>Game Maker</I> program or using the functions to create resources). There
|
|
are different functions to draw texts in different way. In each function you
|
|
specify the position of the text on the screen. There are two functions to
|
|
set the horizontal and vertical alignment of the text with respect to that
|
|
position.
|
|
|
|
<P>
|
|
For text drawing the following functions exist:
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>draw_set_font(font)</b></tt>
|
|
Sets the font that will be used
|
|
when drawing text. Use -1 to set the default font (Arial 12).<br>
|
|
<tt><b>draw_set_halign(halign)</b></tt>
|
|
Sets the horizontal alignment
|
|
used when drawing text. Choose one of the following constants as values:
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>fa_left</b></tt><br>
|
|
<tt><b>fa_center</b></tt><br>
|
|
<tt><b>fa_right</b></tt>
|
|
</blockquote>
|
|
|
|
<p>
|
|
<tt><b>draw_set_valign(valign)</b></tt>
|
|
Sets the vertical alignment
|
|
used when drawing text. Choose one of the following constants as values:
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>fa_top</b></tt><br>
|
|
<tt><b>fa_middle</b></tt><br>
|
|
<tt><b>fa_bottom</b></tt>
|
|
</blockquote>
|
|
|
|
<p>
|
|
<tt><b>draw_text(x,y,string)</b></tt>
|
|
Draws the string at position (x,y), using the drawing color and alpha. A # symbol or
|
|
carriage return chr(13) or linefeed chr(10) are interpreted as newline characters. In this
|
|
way you can draw multi-line texts. (Use \# to get the # symbol itself.)<br>
|
|
<tt><b>draw_text_ext(x,y,string,sep,w)</b></tt>
|
|
Similar to the previous routine but you
|
|
can specify two more things. First of all, <tt>sep</tt> indicates the separation distance between
|
|
the lines of text in a multiline text. Use -1 to get the default distance. Use <tt>w</tt> to
|
|
indicate the width of the text in pixels. Lines that are longer than this width are split-
|
|
up at spaces or - signs. Use -1 to not split up lines.<br>
|
|
<tt><b>string_width(string)</b></tt>
|
|
Width of the string in the current font as it would be
|
|
drawn using the <tt>draw_text()</tt> function.
|
|
Can be used for precisely positioning graphics.<br>
|
|
<tt><b>string_height(string)</b></tt>
|
|
Height of the string in the current font as it
|
|
would be drawn using the <tt>draw_text()</tt> function.<br>
|
|
<tt><b>string_width_ext(string,sep,w)</b></tt>
|
|
Width of the string in the current font as it would be drawn using
|
|
the <tt>draw_text_ext()</tt> function. Can be used for precisely
|
|
positioning graphics.<br>
|
|
<tt><b>string_height_ext(string,sep,w)</b></tt>
|
|
Height of the string in the current font
|
|
as it would be drawn using the <tt>draw_text_ext()</tt> function.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
The following routines allow you to draw scaled and rotated text and also to
|
|
use gradient colors on texts. <b><i>These functions are only available in
|
|
the Pro Edition!</i></b>
|
|
|
|
<p>
|
|
<blockquote>
|
|
<tt><b>draw_text_transformed(x,y,string,xscale,yscale,angle)</b></tt>
|
|
Draws the string at
|
|
position (x,y) in the same way as above, but scale it horizontally and vertically
|
|
with the indicated factors and rotate it counter-clockwise over <tt>angle</tt> degrees.<br>
|
|
<tt><b>draw_text_ext_transformed(x,y,string,sep,w,xscale,yscale,angle)</b></tt>
|
|
Combines the function <tt>draw_text_ext</tt> and <tt>draw_text_transformed</tt>.
|
|
It makes it possible to draw a multi-line text rotated and scaled.<br>
|
|
<tt><b>draw_text_color(x,y,string,c1,c2,c3,c4,alpha)</b></tt>
|
|
Draws the string at position (x,y) like above. The four colors specify
|
|
the colors of the top-left, top-right, bottom-right, and bottom-left corner
|
|
of the text. <tt>alpha</tt> is the alpha transparency to be used (0-1).<br>
|
|
<tt><b>draw_text_ext_color(x,y,string,sep,w,c1,c2,c3,c4,alpha)</b></tt>
|
|
Similar to <tt>draw_text_ext()</tt> but with colored vertices.<br>
|
|
<tt><b>draw_text_transformed_color(x,y,string,xscale,yscale,angle,c1,c2,c3,c4,alpha)</b></tt>
|
|
Similar to <tt>draw_text_transformed()</tt> but with colored vertices.<br>
|
|
<tt><b>draw_text_ext_transformed_color(x,y,string,sep,w,xscale,yscale,angle,c1,c2,c3,c4,alpha)</b></tt>
|
|
Similar to <tt>draw_text_ext_transformed()</tt> but with colored vertices.<br>
|
|
</blockquote>
|
|
|
|
<p>
|
|
|
|
|
|
<!--END-->
|
|
</body>
|
|
</html>
|
|
|
|
<!-- KEYWORDS
|
|
fonts
|
|
text
|
|
drawing text
|
|
text orientation
|
|
aligning text
|
|
rotated text
|
|
|
|
draw_set_font()
|
|
draw_set_halign()
|
|
fa_left
|
|
fa_center
|
|
fa_right
|
|
draw_set_valign()
|
|
fa_top
|
|
fa_middle
|
|
fa_bottom
|
|
draw_text()
|
|
draw_text_ext()
|
|
string_width()
|
|
string_height()
|
|
string_width_ext()
|
|
string_height_ext()
|
|
draw_text_transformed()
|
|
draw_text_ext_transformed()
|
|
draw_text_color()
|
|
draw_text_ext_color()
|
|
draw_text_transformed_color()
|
|
draw_text_ext_transformed_color()
|
|
|
|
--> |