1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
<!doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Vector Text</title>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>
<body>
<h2 align="center">Vector Text</h2>
<p>It is a text that uses a font created only with line segments. It is very
useful to be scaled and very fast. You must set the text size before drawing
any text. The functions ignore the new line character "\n"; only the <font>wdMultiLineVectorText</font>
function will consider this character. The default direction is horizontal from
left to right.</p>
<p align="center"><font size="4">Vector Text Parameters</font><br>
<img src="../../img/vector_text.gif" align="middle" border="2" width="101" height="91"></p>
<p>All vector text drawing in all drivers are simulated using other CD
primitives.</p>
<hr>
<pre class="function"><span class="mainFunction">void <a name="cdVectorText">cdCanvasVectorText</a>(cdCanvas* canvas, int x, int y, const char* text); [in C]</span>
void wdCanvasVectorText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C]
canvas:VectorText(x, y: number, text: string) [in Lua]
canvas:wVectorText(x, y: number, text: string) (WC) [in Lua]</pre>
<p>Draws a vector text in position <tt><b>(x,y)</b></tt>, respecting the
alignment defined by <font><strong>cdTextAlignment</strong></font>. It ignores
the configuration <font><strong>cdBackOpacity</strong></font>, being always
transparent. It also ignores strings with multiple lines. It is ESSENTIAL to
call <font><strong>cdVectorTextSize</strong></font> or <font><strong>cdVectorCharSize</strong></font>
before using <font><strong>cdVectorText</strong></font> or <font><strong>cdMultiLineVetorText</strong></font>.</p>
<pre class="function"><span class="mainFunction">void <a name="cdMultiLineVectorText">cdCanvasMultiLineVectorText</a>(cdCanvas* canvas, int x, int y, const char* text); [in C]</span>
void wdCanvasMultiLineVectorText(cdCanvas* canvas, double x, double y, const char* text); (WC) [in C]
canvas:MultiLineVectorText(x, y: number, text: string) [in Lua]
canvas:wMultiLineVectorText(x, y: number, text: string) (WC) [in Lua]</pre>
<p>Draws a vector text with several lines in position <b><tt>(x,y)</tt></b>,
respecting the alignment defined by <font><strong>cdTextAlignment</strong></font>.
It ignores the configuration <font><strong>cdBackOpacity</strong></font>, being
always transparent. Lines are broken by characters <font>"\n"</font>. Each line
respects the scale defined in <font><strong>cdVectorTextSize</strong></font> or <font>
<strong>cdVectorCharSize</strong></font>. This function's purpose is to make
function <strong><font>cdVectorText</font></strong> more efficient, not being
concerned with multiple lines.</p>
<h3>Attributes</h3>
<pre class="function"><span class="mainFunction">void <a name="cdVectorTextDirection">cdCanvasVectorTextDirection</a>(cdCanvas* canvas, int x1, int y1, int x2, int y2); [in C]</span>
void wdCanvasVectorTextDirection(cdCanvas* canvas, double x1, double y1, double x2, double y2); (WC) [in C]
canvas:VectorTextDirection(x1, y1, x2, y2: number) [in Lua]
canvas:wVectorTextDirection(x1, y1, x2, y2: number) (WC) [in Lua]</pre>
<p>Defines the text direction by means of two points, <b><tt>(x1,y1)</tt></b> and <b>
<tt>(x2,y2)</tt></b>. The default direction is horizontal from left to right.</p>
<pre class="function"><span class="mainFunction">double* <a name="cdVectorTextTransform">cdCanvasVectorTextTransform</a>(cdCanvas* canvas, const double* matrix); [in C]</span>
canvas:VectorTextTransform(matrix: table) -> (old_matrix: table) [in Lua] </pre>
<p>Defines a transformation matrix with 6 elements. If the matrix is NULL, no
transformation is set. The default direction is no transformation. The origin
is the left bottom corner of matrix. It returns the previous matrix, and the
returned vector is only valid until the following call to the function.</p>
<p>The matrix contains scale, rotation and translation elements. It is applied after
computing the position and orientation normal to the vector text. We can
describe the elements as follows:</p>
<pre>|x'| | scl_x*cos(ang) -sin(ang) trans_x | |x| | 3 4 5|
|y'| = | sin(ang) scl_y*cos(ang) trans_y | * |y| with indices | 0 1 2|
|1|</pre>
<pre class="function"><span class="mainFunction">void <a name="cdVectorTextSize">cdCanvasVectorTextSize</a>(cdCanvas* canvas, int w, int h, const char * text); [in C]</span>
void wdCanvasVectorTextSize(cdCanvas* canvas, double size_x, double size_y, const char* text); (WC) [in C]
canvas:VectorTextSize(w, h: number, text: string) [in Lua]
canvas:wVectorTextSize(w, h: number, text: string) (WC) [in Lua]</pre>
<p>Modifies the scale of the vector text so that it corresponds to the string of
the bounding box defined by <b><tt>w</tt></b> and <b><tt>h</tt></b>. It ignores
strings with multiple lines.</p>
<pre class="function"><span class="mainFunction">double <a name="cdVectorCharSize">cdCanvasVectorCharSize</a>(cdCanvas* canvas, int size); [in C]</span>
double wdCanvasVectorCharSize(double size); (WC) [in C]
canvas:VectorCharSize(size: number) -> (old_size: number) [in Lua]
canvas:wVectorCharSize(size: number) -> (old_size: number) (WC) [in Lua]</pre>
<p>Sets the height of the characters and adjusts the width according to it.
Returns the previous value. <strong><tt>CD_QUERY</tt></strong> returns the
current value.</p>
<pre class="function"><span class="mainFunction">char* <a name="cdVectorFont">cdCanvasVectorFont</a>(cdCanvas* canvas, const char *filename); [in C]</span>
canvas:VectorFont(filename: string) -> (fontname: string) [in Lua]</pre>
<p>Replaces the current vector font with a font stored in a file with a given
name. Returns the name of the font loaded or NULL, if it fails. If <font>filename</font>
is NULL, it activates the default font "<b>Simplex II</b>" (There is no file
associated to this font, it is an embedded font). The library will attempt to
load a font from the current directory, if it fails then it will try the
directory defined by the environment variable "<strong><tt>CDDIR</tt></strong>",
if it fails, it will attempt to
load it using the <font>filename</font> as a string containing the font as
if the file was loaded into that string, if it fails again the font is reset
to the default font and returns NULL. The file format is
compatible with the GKS file format (text mode).</p>
<h3>Properties</h3>
<pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextSize">cdCanvasGetVectorTextSize</a>(cdCanvas* canvas, const char* text, int *w, int *h); [in C]</span>
void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *x, double *y); (WC) [in C]
canvas:GetVectorTextSize(text: string) -> (w, h: number) [in Lua]
canvas:wGetVectorTextSize(text: string) -> (w, h: number) (WC) [in Lua]</pre>
<p>Queries the string's bounding box. Ignores strings with multiple lines. It is
not necessary to provide all return pointers, you can provide only the desired
values and <font>NULL</font> for the others.</p>
<pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextBounds">cdCanvasGetVectorTextBounds</a>(cdCanvas* canvas, char* text, int px, int py, int *rect); [in C]</span>
void wdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect); (WC) [in C]
canvas:GetVectorTextBounds(text: string, px,py: number) -> (rect: table) [in Lua]
canvas:wGetVectorTextBounds(text: string, px,py: number) -> (rect: table) (WC) [in Lua] </pre>
<p>Returns the bounding rectangle of the text specified in the current vector
font, alignment and direction. Eight values are returned, corresponding to
pairs (x,y) of the rectangle's vertices ordered conter-clockwise, starting by
the bottom left corner.</p>
<h3>Character Codes</h3>
<p>The old GKS format contains ASCII codes so a convertion from ANSI to ASCII is
done when possible, unmapped characters are left unchanged, but some rearrage
was necessary to acomodate the convertion.
</p>
<p>The default vector font was changed from the original Simplex II to contain
all ANSI accented characters. So some ASCII characters were replaced.</p>
<p>Bellow is the character code table of the default font.</p>
<p style="TEXT-ALIGN: center">
<img src="../../img/vectorfont_default.png" width="717" height="977"><br>
<strong>Default Font</strong></p>
<p>The original Simplex II font is available in the file
"cd/etc/vectorfont00.txt". Bellow is the character code table of the original
font (the table displays the characters after the convertion from ANSI to
ASCII):</p>
<p style="TEXT-ALIGN: center">
<img src="../../img/vectorfont_simplex2.png" width="723" height="978"><br>
<strong>Original Simplex II</strong></p>
</body>
</html>
|