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
152
153
154
155
156
157
158
159
160
161
162
163
use super::*;
/// The FontMetrics class.
/// [`FontMetrics`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics)
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct FontMetrics {
inner: Any,
}
impl FromVal for FontMetrics {
fn from_val(v: &Any) -> Self {
FontMetrics {
inner: Any::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for FontMetrics {
type Target = Any;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for FontMetrics {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for FontMetrics {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for FontMetrics {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<FontMetrics> for Any {
fn from(s: FontMetrics) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&FontMetrics> for Any {
fn from(s: &FontMetrics) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(FontMetrics);
impl FontMetrics {
/// Getter of the `width` attribute.
/// [`FontMetrics.width`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/width)
pub fn width(&self) -> f64 {
self.inner.get("width").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `advances` attribute.
/// [`FontMetrics.advances`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/advances)
pub fn advances(&self) -> TypedArray<f64> {
self.inner.get("advances").as_::<TypedArray<f64>>()
}
}
impl FontMetrics {
/// Getter of the `boundingBoxLeft` attribute.
/// [`FontMetrics.boundingBoxLeft`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/boundingBoxLeft)
pub fn bounding_box_left(&self) -> f64 {
self.inner.get("boundingBoxLeft").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `boundingBoxRight` attribute.
/// [`FontMetrics.boundingBoxRight`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/boundingBoxRight)
pub fn bounding_box_right(&self) -> f64 {
self.inner.get("boundingBoxRight").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `height` attribute.
/// [`FontMetrics.height`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/height)
pub fn height(&self) -> f64 {
self.inner.get("height").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `emHeightAscent` attribute.
/// [`FontMetrics.emHeightAscent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/emHeightAscent)
pub fn em_height_ascent(&self) -> f64 {
self.inner.get("emHeightAscent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `emHeightDescent` attribute.
/// [`FontMetrics.emHeightDescent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/emHeightDescent)
pub fn em_height_descent(&self) -> f64 {
self.inner.get("emHeightDescent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `boundingBoxAscent` attribute.
/// [`FontMetrics.boundingBoxAscent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/boundingBoxAscent)
pub fn bounding_box_ascent(&self) -> f64 {
self.inner.get("boundingBoxAscent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `boundingBoxDescent` attribute.
/// [`FontMetrics.boundingBoxDescent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/boundingBoxDescent)
pub fn bounding_box_descent(&self) -> f64 {
self.inner.get("boundingBoxDescent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `fontBoundingBoxAscent` attribute.
/// [`FontMetrics.fontBoundingBoxAscent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/fontBoundingBoxAscent)
pub fn font_bounding_box_ascent(&self) -> f64 {
self.inner.get("fontBoundingBoxAscent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `fontBoundingBoxDescent` attribute.
/// [`FontMetrics.fontBoundingBoxDescent`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/fontBoundingBoxDescent)
pub fn font_bounding_box_descent(&self) -> f64 {
self.inner.get("fontBoundingBoxDescent").as_::<f64>()
}
}
impl FontMetrics {
/// Getter of the `dominantBaseline` attribute.
/// [`FontMetrics.dominantBaseline`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/dominantBaseline)
pub fn dominant_baseline(&self) -> Baseline {
self.inner.get("dominantBaseline").as_::<Baseline>()
}
}
impl FontMetrics {
/// Getter of the `baselines` attribute.
/// [`FontMetrics.baselines`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/baselines)
pub fn baselines(&self) -> TypedArray<Baseline> {
self.inner.get("baselines").as_::<TypedArray<Baseline>>()
}
}
impl FontMetrics {
/// Getter of the `fonts` attribute.
/// [`FontMetrics.fonts`](https://developer.mozilla.org/en-US/docs/Web/API/FontMetrics/fonts)
pub fn fonts(&self) -> TypedArray<Font> {
self.inner.get("fonts").as_::<TypedArray<Font>>()
}
}