1 /**
2 DynamicFont renders vector font files at runtime.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.dynamicfont;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.font;
24 import godot.dynamicfontdata;
25 import godot.resource;
26 import godot.reference;
27 /**
28 DynamicFont renders vector font files at runtime.
29 
30 DynamicFont renders vector font files (such as TTF or OTF) dynamically at runtime instead of using a prerendered texture atlas like $(D BitmapFont). This trades the faster loading time of $(D BitmapFont)s for the ability to change font parameters like size and spacing during runtime. $(D DynamicFontData) is used for referencing the font file paths.
31 */
32 @GodotBaseClass struct DynamicFont
33 {
34 	enum string _GODOT_internal_name = "DynamicFont";
35 public:
36 @nogc nothrow:
37 	union { godot_object _godot_object; Font _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct _classBinding
42 	{
43 		__gshared:
44 		@GodotName("set_font_data") GodotMethod!(void, DynamicFontData) setFontData;
45 		@GodotName("get_font_data") GodotMethod!(DynamicFontData) getFontData;
46 		@GodotName("set_size") GodotMethod!(void, long) setSize;
47 		@GodotName("get_size") GodotMethod!(long) getSize;
48 		@GodotName("set_outline_size") GodotMethod!(void, long) setOutlineSize;
49 		@GodotName("get_outline_size") GodotMethod!(long) getOutlineSize;
50 		@GodotName("set_outline_color") GodotMethod!(void, Color) setOutlineColor;
51 		@GodotName("get_outline_color") GodotMethod!(Color) getOutlineColor;
52 		@GodotName("set_use_mipmaps") GodotMethod!(void, bool) setUseMipmaps;
53 		@GodotName("get_use_mipmaps") GodotMethod!(bool) getUseMipmaps;
54 		@GodotName("set_use_filter") GodotMethod!(void, bool) setUseFilter;
55 		@GodotName("get_use_filter") GodotMethod!(bool) getUseFilter;
56 		@GodotName("set_spacing") GodotMethod!(void, long, long) setSpacing;
57 		@GodotName("get_spacing") GodotMethod!(long, long) getSpacing;
58 		@GodotName("add_fallback") GodotMethod!(void, DynamicFontData) addFallback;
59 		@GodotName("set_fallback") GodotMethod!(void, long, DynamicFontData) setFallback;
60 		@GodotName("get_fallback") GodotMethod!(DynamicFontData, long) getFallback;
61 		@GodotName("remove_fallback") GodotMethod!(void, long) removeFallback;
62 		@GodotName("get_fallback_count") GodotMethod!(long) getFallbackCount;
63 	}
64 	bool opEquals(in DynamicFont other) const { return _godot_object.ptr is other._godot_object.ptr; }
65 	DynamicFont opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
66 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
67 	mixin baseCasts;
68 	static DynamicFont _new()
69 	{
70 		static godot_class_constructor constructor;
71 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("DynamicFont");
72 		if(constructor is null) return typeof(this).init;
73 		return cast(DynamicFont)(constructor());
74 	}
75 	@disable new(size_t s);
76 	/// 
77 	enum SpacingType : int
78 	{
79 		/**
80 		Spacing at the top.
81 		*/
82 		spacingTop = 0,
83 		/**
84 		Spacing at the bottom.
85 		*/
86 		spacingBottom = 1,
87 		/**
88 		Character spacing.
89 		*/
90 		spacingChar = 2,
91 		/**
92 		Space spacing.
93 		*/
94 		spacingSpace = 3,
95 	}
96 	/// 
97 	enum Constants : int
98 	{
99 		spacingTop = 0,
100 		spacingBottom = 1,
101 		spacingChar = 2,
102 		spacingSpace = 3,
103 	}
104 	/**
105 	
106 	*/
107 	void setFontData(DynamicFontData data)
108 	{
109 		checkClassBinding!(typeof(this))();
110 		ptrcall!(void)(_classBinding.setFontData, _godot_object, data);
111 	}
112 	/**
113 	
114 	*/
115 	Ref!DynamicFontData getFontData() const
116 	{
117 		checkClassBinding!(typeof(this))();
118 		return ptrcall!(DynamicFontData)(_classBinding.getFontData, _godot_object);
119 	}
120 	/**
121 	
122 	*/
123 	void setSize(in long data)
124 	{
125 		checkClassBinding!(typeof(this))();
126 		ptrcall!(void)(_classBinding.setSize, _godot_object, data);
127 	}
128 	/**
129 	
130 	*/
131 	long getSize() const
132 	{
133 		checkClassBinding!(typeof(this))();
134 		return ptrcall!(long)(_classBinding.getSize, _godot_object);
135 	}
136 	/**
137 	
138 	*/
139 	void setOutlineSize(in long size)
140 	{
141 		checkClassBinding!(typeof(this))();
142 		ptrcall!(void)(_classBinding.setOutlineSize, _godot_object, size);
143 	}
144 	/**
145 	
146 	*/
147 	long getOutlineSize() const
148 	{
149 		checkClassBinding!(typeof(this))();
150 		return ptrcall!(long)(_classBinding.getOutlineSize, _godot_object);
151 	}
152 	/**
153 	
154 	*/
155 	void setOutlineColor(in Color color)
156 	{
157 		checkClassBinding!(typeof(this))();
158 		ptrcall!(void)(_classBinding.setOutlineColor, _godot_object, color);
159 	}
160 	/**
161 	
162 	*/
163 	Color getOutlineColor() const
164 	{
165 		checkClassBinding!(typeof(this))();
166 		return ptrcall!(Color)(_classBinding.getOutlineColor, _godot_object);
167 	}
168 	/**
169 	
170 	*/
171 	void setUseMipmaps(in bool enable)
172 	{
173 		checkClassBinding!(typeof(this))();
174 		ptrcall!(void)(_classBinding.setUseMipmaps, _godot_object, enable);
175 	}
176 	/**
177 	
178 	*/
179 	bool getUseMipmaps() const
180 	{
181 		checkClassBinding!(typeof(this))();
182 		return ptrcall!(bool)(_classBinding.getUseMipmaps, _godot_object);
183 	}
184 	/**
185 	
186 	*/
187 	void setUseFilter(in bool enable)
188 	{
189 		checkClassBinding!(typeof(this))();
190 		ptrcall!(void)(_classBinding.setUseFilter, _godot_object, enable);
191 	}
192 	/**
193 	
194 	*/
195 	bool getUseFilter() const
196 	{
197 		checkClassBinding!(typeof(this))();
198 		return ptrcall!(bool)(_classBinding.getUseFilter, _godot_object);
199 	}
200 	/**
201 	
202 	*/
203 	void setSpacing(in long type, in long value)
204 	{
205 		checkClassBinding!(typeof(this))();
206 		ptrcall!(void)(_classBinding.setSpacing, _godot_object, type, value);
207 	}
208 	/**
209 	
210 	*/
211 	long getSpacing(in long type) const
212 	{
213 		checkClassBinding!(typeof(this))();
214 		return ptrcall!(long)(_classBinding.getSpacing, _godot_object, type);
215 	}
216 	/**
217 	Adds a fallback font.
218 	*/
219 	void addFallback(DynamicFontData data)
220 	{
221 		checkClassBinding!(typeof(this))();
222 		ptrcall!(void)(_classBinding.addFallback, _godot_object, data);
223 	}
224 	/**
225 	Sets the fallback font at index `idx`.
226 	*/
227 	void setFallback(in long idx, DynamicFontData data)
228 	{
229 		checkClassBinding!(typeof(this))();
230 		ptrcall!(void)(_classBinding.setFallback, _godot_object, idx, data);
231 	}
232 	/**
233 	Returns the fallback font at index `idx`.
234 	*/
235 	Ref!DynamicFontData getFallback(in long idx) const
236 	{
237 		checkClassBinding!(typeof(this))();
238 		return ptrcall!(DynamicFontData)(_classBinding.getFallback, _godot_object, idx);
239 	}
240 	/**
241 	Removes the fallback font at index `idx`.
242 	*/
243 	void removeFallback(in long idx)
244 	{
245 		checkClassBinding!(typeof(this))();
246 		ptrcall!(void)(_classBinding.removeFallback, _godot_object, idx);
247 	}
248 	/**
249 	Returns the number of fallback fonts.
250 	*/
251 	long getFallbackCount() const
252 	{
253 		checkClassBinding!(typeof(this))();
254 		return ptrcall!(long)(_classBinding.getFallbackCount, _godot_object);
255 	}
256 	/**
257 	The font size.
258 	*/
259 	@property long size()
260 	{
261 		return getSize();
262 	}
263 	/// ditto
264 	@property void size(long v)
265 	{
266 		setSize(v);
267 	}
268 	/**
269 	
270 	*/
271 	@property long outlineSize()
272 	{
273 		return getOutlineSize();
274 	}
275 	/// ditto
276 	@property void outlineSize(long v)
277 	{
278 		setOutlineSize(v);
279 	}
280 	/**
281 	
282 	*/
283 	@property Color outlineColor()
284 	{
285 		return getOutlineColor();
286 	}
287 	/// ditto
288 	@property void outlineColor(Color v)
289 	{
290 		setOutlineColor(v);
291 	}
292 	/**
293 	If `true` mipmapping is used.
294 	*/
295 	@property bool useMipmaps()
296 	{
297 		return getUseMipmaps();
298 	}
299 	/// ditto
300 	@property void useMipmaps(bool v)
301 	{
302 		setUseMipmaps(v);
303 	}
304 	/**
305 	If `true` filtering is used.
306 	*/
307 	@property bool useFilter()
308 	{
309 		return getUseFilter();
310 	}
311 	/// ditto
312 	@property void useFilter(bool v)
313 	{
314 		setUseFilter(v);
315 	}
316 	/**
317 	Extra spacing at the top in pixels.
318 	*/
319 	@property long extraSpacingTop()
320 	{
321 		return getSpacing(0);
322 	}
323 	/// ditto
324 	@property void extraSpacingTop(long v)
325 	{
326 		setSpacing(0, v);
327 	}
328 	/**
329 	Extra spacing at the bottom in pixels.
330 	*/
331 	@property long extraSpacingBottom()
332 	{
333 		return getSpacing(1);
334 	}
335 	/// ditto
336 	@property void extraSpacingBottom(long v)
337 	{
338 		setSpacing(1, v);
339 	}
340 	/**
341 	Extra character spacing in pixels.
342 	*/
343 	@property long extraSpacingChar()
344 	{
345 		return getSpacing(2);
346 	}
347 	/// ditto
348 	@property void extraSpacingChar(long v)
349 	{
350 		setSpacing(2, v);
351 	}
352 	/**
353 	Extra space spacing in pixels.
354 	*/
355 	@property long extraSpacingSpace()
356 	{
357 		return getSpacing(3);
358 	}
359 	/// ditto
360 	@property void extraSpacingSpace(long v)
361 	{
362 		setSpacing(3, v);
363 	}
364 	/**
365 	The font data.
366 	*/
367 	@property DynamicFontData fontData()
368 	{
369 		return getFontData();
370 	}
371 	/// ditto
372 	@property void fontData(DynamicFontData v)
373 	{
374 		setFontData(v);
375 	}
376 }