summaryrefslogtreecommitdiff
path: root/html/en/func/vectortext.html
blob: 84ca12843d35499188bf5bee3b63e09d225e07a5 (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!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 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 accepts strings with multiple lines using <font>'\n'</font>. It is ESSENTIAL to 
      call <font><strong>cdVectorTextSize</strong></font> or <font><strong>cdVectorCharSize</strong></font>
      before using this function.</p>
	<p>The <strong>wdCanvasVectorText</strong> is the only function that 
	actually depends on World Coordinates. The other Vector Text functions 
	although use the &quot;<strong>wd</strong>&quot; prefix they do not depend on World 
	Coordinates. They are kept with these names for backward compatibility. The 
	correct prefix would be &quot;<strong>cdf</strong>&quot;.</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); [in C]

canvas:VectorTextDirection(x1, y1, x2, y2: number) [in Lua]
canvas:wVectorTextDirection(x1, y1, x2, y2: number) [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. 
	It is independent from the transformation matrix.</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) -&gt; (old_matrix: table) [in Lua]&nbsp;</pre>
    <p>Defines a transformation matrix with 6 elements. If the matrix is NULL, no 
      transformation is set. The default 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>
  <p>It has the same effect of the <strong>
  cdCanvasTransform,</strong> but notice that the indices are different.</p>
    <pre class="function"><span class="mainFunction">void <a name="cdVectorTextSize">cdCanvasVectorTextSize</a>(cdCanvas* canvas, int width, int height, const char * text); [in C]</span>
void wdCanvasVectorTextSize(cdCanvas* canvas, double width, double height, const char* text); [in C]

canvas:VectorTextSize(width, height: number, text: string) [in Lua]
canvas:wVectorTextSize(width, height: number, text: string) [in Lua]</pre>
    <p>Modifies the font size of the vector text so that it fits the string in 
      the box defined by <b><tt>width</tt></b> and <b><tt>height</tt></b>.</p>
    <pre class="function"><span class="mainFunction">double <a name="cdVectorCharSize">cdCanvasVectorCharSize</a>(cdCanvas* canvas, int size); [in C]</span>
double wdCanvasVectorCharSize(cdCanvas* canvas, double size); [in C]

canvas:VectorCharSize(size: number) -&gt; (old_size: number) [in Lua]
canvas:wVectorCharSize(size: number) -&gt; (old_size: number) [in Lua]</pre>
    <p>Modifies the font size by specifying the height of the characters. 
      Returns the previous value. <strong><tt>CD_QUERY</tt></strong> returns the 
      current value.</p>
    <pre class="function"><span class="mainFunction">void <a name="cdVectorFontSize">cdCanvasVectorFontSize</a>(cdCanvas* canvas, double size_x, double size_x); [in C]</span>

canvas:VectorFontSize(size_x, size_y: number) [in Lua]</pre>
    <p>Directly modifies the font size. Set size_x==size_y to maintain the 
	original aspect ratio of the font.</p>
    <pre class="function"><span class="mainFunction">void <a name="cdGetVectorFontSize">cdCanvasGetVectorFontSize</a>(cdCanvas* canvas, double *size_x, double *size_x); [in C]</span>

canvas:GetVectorFontSize() -&gt; (size_x, size_y: number) [in Lua]</pre>
    <p>Returns the font size. 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">char* <a name="cdVectorFont">cdCanvasVectorFont</a>(cdCanvas* canvas, const char *filename); [in C]</span>

canvas:VectorFont(filename: string) -&gt; (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>&quot;, 
    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 *width, int *height); [in C]</span>
void wdCanvasGetVectorTextSize(cdCanvas* canvas, const char* text, double *width, double *height); [in C]

canvas:GetVectorTextSize(text: string) -&gt; (width, height: number) [in Lua]
canvas:wGetVectorTextSize(text: string) -&gt; (width, height: number) [in Lua]</pre>
    <p>Returns the text size independent from orientation. 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 x, int y, int *rect); [in C]</span>
void wdCanvasGetVectorTextBounds(cdCanvas* canvas, char* text, double x, double y, double *rect); [in C]

canvas:GetVectorTextBounds(text: string, x, y: number) -&gt; (rect: table) [in Lua]
canvas:wGetVectorTextBounds(text: string, x, y: number) -&gt; (rect: table) [in Lua] </pre>

  <p>Returns the oriented bounding rectangle occupied by a text at a given 
	position. The rectangle has the same dimentions returned by <strong>
	GetVectorTextSize</strong>. The rectangle corners are returned in counter-clock wise 
  order starting with the bottom left corner, arranged (x0,y0,x1,y1,x2,y2,x3,y3).</p>


<pre class="function"><span class="mainFunction">void <a name="cdGetVectorTextBox">cdCanvasGetVectorTextBox</a>(cdCanvas* canvas, int x, int y, const char* text, int *xmin, int *xmax, int *ymin, int *ymax); [in C]</span>
void wdCanvasGetVectorTextBox(cdCanvas* canvas, double x, double y, const char* text, double *xmin, double *xmax, double *ymin, double *ymax); [in C]

canvas:GetVectorTextBox(x, y: number, text: string) -&gt; (xmin, xmax, ymin, ymax: number) [in Lua]
canvas:wGetVectorTextBox(x, y: number, text: string) -&gt; (xmin, xmax, ymin, ymax: number) [in Lua]</pre>

  <p>Returns the horizontal bounding rectangle occupied by a text at a given 
	position. If 
	orientation is not 0 then its area is always larger than the area of the 
	rectangle returned by <strong>GetVectorTextBounds</strong>. It is not necessary 
  to provide all return pointers, you can provide only the desired values and <i><tt>NULL</tt></i> for the others.</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>