Skip to content

Commit ab22f7a

Browse files
core-text: Add has_table method wrapping CTFontHasTable (#739)
* core-text:Add has_table method wrapping CTFontHasTable * Fix Build by make lifetimes explicit * fix clippy lints in array.rs and propertylist.rs
1 parent 0bcad1e commit ab22f7a

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

core-foundation/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ mod tests {
242242
use crate::string::{CFString, CFStringRef};
243243

244244
let cf_string = CFString::from_static_string("alongerstring");
245-
let array: CFArray = CFArray::from_CFTypes(&[cf_string.clone()]).into_untyped();
245+
let array: CFArray = CFArray::from_CFTypes(std::slice::from_ref(&cf_string)).into_untyped();
246246

247247
let cf_strings = array
248248
.iter()

core-foundation/src/propertylist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl CFPropertyListSubClass for crate::boolean::CFBoolean {}
9696
impl CFPropertyListSubClass for crate::number::CFNumber {}
9797

9898
declare_TCFType! {
99-
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
99+
/// A `CFPropertyList` struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
100100
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
101101
///
102102
/// This superclass type does not have its own `CFTypeID`, instead each instance has the `CFTypeID`

core-text/src/font.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ impl CTFont {
438438
CTFontGetVerticalTranslationsForGlyphs(self.0, orientation, glyphs, translations, count)
439439
}
440440

441+
pub fn has_table(&self, tag: u32) -> bool {
442+
unsafe { CTFontHasTable(self.0, tag as CTFontTableTag) }
443+
}
444+
441445
pub fn get_font_table(&self, tag: u32) -> Option<CFData> {
442446
unsafe {
443447
let result = CTFontCopyTable(
@@ -805,6 +809,8 @@ extern "C" {
805809
) -> CFDataRef;
806810

807811
fn CTFontGetTypeID() -> CFTypeID;
812+
813+
fn CTFontHasTable(font: CTFontRef, table: CTFontTableTag) -> bool;
808814
}
809815

810816
#[test]

core-text/src/run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl CTRun {
4444
unsafe { CTRunGetGlyphCount(self.0) }
4545
}
4646

47-
pub fn glyphs(&self) -> Cow<[CGGlyph]> {
47+
pub fn glyphs(&self) -> Cow<'_, [CGGlyph]> {
4848
unsafe {
4949
// CTRunGetGlyphsPtr can return null under some not understood circumstances.
5050
// If it does the Apple documentation tells us to allocate our own buffer and call
@@ -64,7 +64,7 @@ impl CTRun {
6464
}
6565
}
6666

67-
pub fn positions(&self) -> Cow<[CGPoint]> {
67+
pub fn positions(&self) -> Cow<'_, [CGPoint]> {
6868
unsafe {
6969
// CTRunGetPositionsPtr can return null under some not understood circumstances.
7070
// If it does the Apple documentation tells us to allocate our own buffer and call
@@ -112,7 +112,7 @@ impl CTRun {
112112
}
113113
}
114114

115-
pub fn string_indices(&self) -> Cow<[CFIndex]> {
115+
pub fn string_indices(&self) -> Cow<'_, [CFIndex]> {
116116
unsafe {
117117
// CTRunGetStringIndicesPtr can return null under some not understood circumstances.
118118
// If it does the Apple documentation tells us to allocate our own buffer and call

0 commit comments

Comments
 (0)