1 /*
2     Ming, an SWF output library
3     Copyright (C) 2002  Opaque Industries - http://www.opaque.net/
4 
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9 
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Lesser General Public License for more details.
14 
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19 
20 #include <math.h>
21 
22 #include "ming.h"
23 #include "text_util.h"
24 #include "movie.h"
25 #include "blocks/text.h"
26 #include "blocks/font.h"
27 #include "blocks/textfield.h"
28 #include "libming.h"
29 
30 
31 void
SWFText_setHeight(SWFText text,float height)32 SWFText_setHeight(SWFText text, float height)
33 {
34 	SWFText_setScaledHeight(text, (int)rint(Ming_scale*height));
35 }
36 
37 
38 void
SWFText_setSpacing(SWFText text,float spacing)39 SWFText_setSpacing(SWFText text, float spacing)
40 {
41 	SWFText_setScaledSpacing(text, (int)rint(Ming_scale*spacing));
42 }
43 
44 
45 void
SWFText_moveTo(SWFText text,float x,float y)46 SWFText_moveTo(SWFText text, float x, float y)
47 {
48 	SWFText_scaledMoveTo(text, (int)rint(Ming_scale*x), (int)rint(Ming_scale*y));
49 }
50 
51 
52 float
SWFText_getStringWidth(SWFText text,const char * string)53 SWFText_getStringWidth(SWFText text, const char *string)
54 {
55 	return SWFText_getScaledStringWidth(text, string)/Ming_scale;
56 }
57 
58 
59 float
SWFText_getUTF8StringWidth(SWFText text,const char * string)60 SWFText_getUTF8StringWidth(SWFText text, const char *string)
61 {
62 	return SWFText_getScaledUTF8StringWidth(text, string)/Ming_scale;
63 }
64 
65 
66 float
SWFText_getWideStringWidth(SWFText text,const unsigned short * string)67 SWFText_getWideStringWidth(SWFText text, const unsigned short *string)
68 {
69 	return SWFText_getScaledWideStringWidth(text, string)/Ming_scale;
70 }
71 
72 
73 float
SWFText_getAscent(SWFText text)74 SWFText_getAscent(SWFText text)
75 {
76 	return SWFText_getScaledAscent(text)/Ming_scale;
77 }
78 
79 
80 float
SWFText_getDescent(SWFText text)81 SWFText_getDescent(SWFText text)
82 {
83 	return SWFText_getScaledDescent(text)/Ming_scale;
84 }
85 
86 
87 float
SWFText_getLeading(SWFText text)88 SWFText_getLeading(SWFText text)
89 {
90 	return SWFText_getScaledLeading(text)/Ming_scale;
91 }
92 
93 
94 float
SWFFont_getStringWidth(SWFFont font,const char * string)95 SWFFont_getStringWidth(SWFFont font, const char *string)
96 {
97 	return SWFFont_getScaledStringWidth(font, string) / Ming_scale;
98 }
99 
100 
101 float
SWFFont_getUTF8StringWidth(SWFFont font,const char * string)102 SWFFont_getUTF8StringWidth(SWFFont font, const char *string)
103 {
104 	return SWFFont_getScaledUTF8StringWidth(font, string) / Ming_scale;
105 }
106 
107 
108 float
SWFFont_getWideStringWidth(SWFFont font,const unsigned short * string,int len)109 SWFFont_getWideStringWidth(SWFFont font, const unsigned short *string, int len)
110 {
111 	return SWFFont_getScaledWideStringWidth(font, string, len) / Ming_scale;
112 }
113 
114 
115 float
SWFFont_getAscent(SWFFont font)116 SWFFont_getAscent(SWFFont font)
117 {
118 	return SWFFont_getScaledAscent(font)/Ming_scale;
119 }
120 
121 
122 float
SWFFont_getDescent(SWFFont font)123 SWFFont_getDescent(SWFFont font)
124 {
125 	return SWFFont_getScaledDescent(font)/Ming_scale;
126 }
127 
128 
129 float
SWFFont_getLeading(SWFFont font)130 SWFFont_getLeading(SWFFont font)
131 {
132 	return SWFFont_getScaledLeading(font)/Ming_scale;
133 }
134 
135 
136 void
SWFTextField_setBounds(SWFTextField field,float width,float height)137 SWFTextField_setBounds(SWFTextField field, float width, float height)
138 {
139 	SWFTextField_setScaledBounds(field, (int)rint(Ming_scale*width),
140 						 (int)rint(Ming_scale*height));
141 }
142 
143 
144 void
SWFTextField_setHeight(SWFTextField field,float height)145 SWFTextField_setHeight(SWFTextField field, float height)
146 {
147 	SWFTextField_setScaledFontHeight(field, (int)rint(Ming_scale*height));
148 }
149 
150 
151 void
SWFTextField_setFieldHeight(SWFTextField field,float height)152 SWFTextField_setFieldHeight(SWFTextField field, float height)
153 {
154 	SWFTextField_setScaledFieldHeight(field, (int)rint(Ming_scale*height));
155 }
156 
157 
158 void
SWFTextField_setLeftMargin(SWFTextField field,float leftMargin)159 SWFTextField_setLeftMargin(SWFTextField field, float leftMargin)
160 {
161 	SWFTextField_setScaledLeftMargin(field, (int)rint(Ming_scale*leftMargin));
162 }
163 
164 
165 void
SWFTextField_setRightMargin(SWFTextField field,float rightMargin)166 SWFTextField_setRightMargin(SWFTextField field, float rightMargin)
167 {
168 	SWFTextField_setScaledRightMargin(field, (int)rint(Ming_scale*rightMargin));
169 }
170 
171 
172 void
SWFTextField_setIndentation(SWFTextField field,float indentation)173 SWFTextField_setIndentation(SWFTextField field, float indentation)
174 {
175 	SWFTextField_setScaledIndentation(field, (int)rint(Ming_scale*indentation));
176 }
177 
178 
179 void
SWFTextField_setLineSpacing(SWFTextField field,float lineSpacing)180 SWFTextField_setLineSpacing(SWFTextField field, float lineSpacing)
181 {
182 	SWFTextField_setScaledLineSpacing(field, (int)rint(Ming_scale*lineSpacing));
183 }
184 
185 
186 void
SWFTextField_setPadding(SWFTextField field,float padding)187 SWFTextField_setPadding(SWFTextField field, float padding)
188 {
189 	SWFTextField_setScaledPadding(field, (int)rint(Ming_scale*padding));
190 }
191 
192 
193 /*
194  * Local variables:
195  * tab-width: 2
196  * c-basic-offset: 2
197  * End:
198  */
199