1 module skia.SKFontStyle;
2 
3 import skia.SKObject;
4 import skia.Definitions;
5 import skia.SkiaApi;
6 import std.concurrency : initOnce;
7 
8 class SKFontStyle : SKObject, ISKSkipObjectRegistration {
9 	// private static const SKFontStyle normal;
10 	// private static const SKFontStyle bold;
11 	// private static const SKFontStyle italic;
12 	// private static const SKFontStyle boldItalic;
13 
14 	static SKFontStyle normal() {
15 		__gshared SKFontStyle inst;
16 		return initOnce!inst(new SKFontStyleStatic(SKFontStyleWeight.Normal,
17 				SKFontStyleWidth.Normal, SKFontStyleSlant.Upright));
18 	}
19 
20 	static SKFontStyle bold() {
21 		__gshared SKFontStyle inst;
22 		return initOnce!inst(new SKFontStyleStatic(SKFontStyleWeight.Bold,
23 				SKFontStyleWidth.Normal, SKFontStyleSlant.Upright));
24 	}
25 
26 	static SKFontStyle italic() {
27 		__gshared SKFontStyle inst;
28 		return initOnce!inst(new SKFontStyleStatic(SKFontStyleWeight.Normal,
29 				SKFontStyleWidth.Normal, SKFontStyleSlant.Italic));
30 	}
31 
32 	static SKFontStyle boldItalic() {
33 		__gshared SKFontStyle inst;
34 		return initOnce!inst(new SKFontStyleStatic(SKFontStyleWeight.Bold,
35 				SKFontStyleWidth.Normal, SKFontStyleSlant.Italic));
36 	}
37 
38 	// static SKFontStyle ()
39 	// {
40 	// 	normal = new SKFontStyleStatic (SKFontStyleWeight.Normal, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);
41 	// 	bold = new SKFontStyleStatic (SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);
42 	// 	italic = new SKFontStyleStatic (SKFontStyleWeight.Normal, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic);
43 	// 	boldItalic = new SKFontStyleStatic (SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Italic);
44 	// }
45 
46 	this(void* handle, bool owns) {
47 		super(handle, owns);
48 	}
49 
50 	this() {
51 		this(SKFontStyleWeight.Normal, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);
52 	}
53 
54 	this(SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) {
55 		this(cast(int) weight, cast(int) width, slant);
56 	}
57 
58 	this(int weight, int width, SKFontStyleSlant slant) {
59 		this(SkiaApi.sk_fontstyle_new(weight, width, slant), true);
60 	}
61 
62 	protected override void Dispose(bool disposing) {
63 		return super.Dispose(disposing);
64 	}
65 
66 	protected override void DisposeNative() {
67 		return SkiaApi.sk_fontstyle_delete(cast(sk_fontstyle_t*) Handle);
68 	}
69 
70 	int Weight() {
71 		return SkiaApi.sk_fontstyle_get_weight(cast(sk_fontstyle_t*) Handle);
72 	}
73 
74 	int Width() {
75 		return SkiaApi.sk_fontstyle_get_width(cast(sk_fontstyle_t*) Handle);
76 	}
77 
78 	SKFontStyleSlant Slant() {
79 		return SkiaApi.sk_fontstyle_get_slant(cast(sk_fontstyle_t*) Handle);
80 	}
81 
82 	static SKFontStyle Normal() {
83 		return normal;
84 	}
85 
86 	static SKFontStyle Bold() {
87 		return bold;
88 	}
89 
90 	static SKFontStyle Italic() {
91 		return italic;
92 	}
93 
94 	static SKFontStyle BoldItalic() {
95 		return boldItalic;
96 	}
97 
98 	//
99 
100 	static SKFontStyle GetObject(void* handle) {
101 		return handle is null ? null : new SKFontStyle(handle, true);
102 	}
103 
104 }
105 
106 private final class SKFontStyleStatic : SKFontStyle {
107 	this(SKFontStyleWeight weight, SKFontStyleWidth width, SKFontStyleSlant slant) {
108 		super(weight, width, slant);
109 		IgnorePublicDispose = true;
110 	}
111 }