Skip to content

Commit d7879eb

Browse files
authored
core-graphics: Add more metrics functions to CGFont (#661)
1 parent dd284a0 commit d7879eb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

core-graphics/src/font.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ impl CGFont {
102102
}
103103
}
104104

105+
pub fn ascent(&self) -> c_int {
106+
unsafe { CGFontGetAscent(self.as_ptr()) }
107+
}
108+
109+
pub fn descent(&self) -> c_int {
110+
unsafe { CGFontGetDescent(self.as_ptr()) }
111+
}
112+
113+
pub fn leading(&self) -> c_int {
114+
unsafe { CGFontGetLeading(self.as_ptr()) }
115+
}
116+
117+
pub fn cap_height(&self) -> c_int {
118+
unsafe { CGFontGetCapHeight(self.as_ptr()) }
119+
}
120+
121+
pub fn x_height(&self) -> c_int {
122+
unsafe { CGFontGetXHeight(self.as_ptr()) }
123+
}
124+
105125
pub fn get_units_per_em(&self) -> c_int {
106126
unsafe { CGFontGetUnitsPerEm(self.as_ptr()) }
107127
}
@@ -170,6 +190,12 @@ extern "C" {
170190
count: size_t,
171191
advances: *mut c_int,
172192
) -> bool;
193+
194+
fn CGFontGetAscent(font: crate::sys::CGFontRef) -> c_int;
195+
fn CGFontGetDescent(font: crate::sys::CGFontRef) -> c_int;
196+
fn CGFontGetLeading(font: crate::sys::CGFontRef) -> c_int;
197+
fn CGFontGetCapHeight(font: crate::sys::CGFontRef) -> c_int;
198+
fn CGFontGetXHeight(font: crate::sys::CGFontRef) -> c_int;
173199
fn CGFontGetUnitsPerEm(font: crate::sys::CGFontRef) -> c_int;
174200

175201
fn CGFontCopyTableTags(font: crate::sys::CGFontRef) -> CFArrayRef;

0 commit comments

Comments
 (0)