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
This commit is contained in:
@@ -242,7 +242,7 @@ mod tests {
|
||||
use crate::string::{CFString, CFStringRef};
|
||||
|
||||
let cf_string = CFString::from_static_string("alongerstring");
|
||||
let array: CFArray = CFArray::from_CFTypes(&[cf_string.clone()]).into_untyped();
|
||||
let array: CFArray = CFArray::from_CFTypes(std::slice::from_ref(&cf_string)).into_untyped();
|
||||
|
||||
let cf_strings = array
|
||||
.iter()
|
||||
|
||||
@@ -96,7 +96,7 @@ impl CFPropertyListSubClass for crate::boolean::CFBoolean {}
|
||||
impl CFPropertyListSubClass for crate::number::CFNumber {}
|
||||
|
||||
declare_TCFType! {
|
||||
/// A CFPropertyList struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
|
||||
/// A `CFPropertyList` struct. This is superclass to [`CFData`], [`CFString`], [`CFArray`],
|
||||
/// [`CFDictionary`], [`CFDate`], [`CFBoolean`], and [`CFNumber`].
|
||||
///
|
||||
/// This superclass type does not have its own `CFTypeID`, instead each instance has the `CFTypeID`
|
||||
|
||||
@@ -438,6 +438,10 @@ impl CTFont {
|
||||
CTFontGetVerticalTranslationsForGlyphs(self.0, orientation, glyphs, translations, count)
|
||||
}
|
||||
|
||||
pub fn has_table(&self, tag: u32) -> bool {
|
||||
unsafe { CTFontHasTable(self.0, tag as CTFontTableTag) }
|
||||
}
|
||||
|
||||
pub fn get_font_table(&self, tag: u32) -> Option<CFData> {
|
||||
unsafe {
|
||||
let result = CTFontCopyTable(
|
||||
@@ -805,6 +809,8 @@ extern "C" {
|
||||
) -> CFDataRef;
|
||||
|
||||
fn CTFontGetTypeID() -> CFTypeID;
|
||||
|
||||
fn CTFontHasTable(font: CTFontRef, table: CTFontTableTag) -> bool;
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -44,7 +44,7 @@ impl CTRun {
|
||||
unsafe { CTRunGetGlyphCount(self.0) }
|
||||
}
|
||||
|
||||
pub fn glyphs(&self) -> Cow<[CGGlyph]> {
|
||||
pub fn glyphs(&self) -> Cow<'_, [CGGlyph]> {
|
||||
unsafe {
|
||||
// CTRunGetGlyphsPtr can return null under some not understood circumstances.
|
||||
// If it does the Apple documentation tells us to allocate our own buffer and call
|
||||
@@ -64,7 +64,7 @@ impl CTRun {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn positions(&self) -> Cow<[CGPoint]> {
|
||||
pub fn positions(&self) -> Cow<'_, [CGPoint]> {
|
||||
unsafe {
|
||||
// CTRunGetPositionsPtr can return null under some not understood circumstances.
|
||||
// If it does the Apple documentation tells us to allocate our own buffer and call
|
||||
@@ -112,7 +112,7 @@ impl CTRun {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn string_indices(&self) -> Cow<[CFIndex]> {
|
||||
pub fn string_indices(&self) -> Cow<'_, [CFIndex]> {
|
||||
unsafe {
|
||||
// CTRunGetStringIndicesPtr can return null under some not understood circumstances.
|
||||
// If it does the Apple documentation tells us to allocate our own buffer and call
|
||||
|
||||
Reference in New Issue
Block a user