Skip to content

Commit 83caa0d

Browse files
committed
Revert unnecessary changes
1 parent e036a35 commit 83caa0d

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

crates/mac_core/src/font.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ cfty! {
8585

8686
impl CTFont {
8787
/// Create a new font from a [`CTFontDescriptor`] and a size to render at.
88-
/// Returns `None` if CoreText cannot create the font (rare, but possible).
89-
pub fn new_descriptor(descriptor: &CTFontDescriptor, size: f64) -> Option<CTFont> {
88+
pub fn new_descriptor(descriptor: &CTFontDescriptor, size: f64) -> CTFont {
9089
// SAFETY: Provided descriptor is guaranteed valid. Any size will work. Null matrix is always
9190
// allowed.
9291
let ptr = unsafe {
@@ -96,8 +95,9 @@ impl CTFont {
9695
ptr::null_mut(),
9796
)
9897
};
98+
let ptr = NonNull::new(ptr.cast_mut()).unwrap();
9999
// SAFETY: If non-null, pointer from CTFontCreateWithFontDescriptor is a new, owned CTFont.
100-
NonNull::new(ptr.cast_mut()).map(|ptr| unsafe { CTFont::new_owned(ptr) })
100+
unsafe { CTFont::new_owned(ptr) }
101101
}
102102

103103
/// Get an attribute of this font, if present

crates/xetex_layout/src/c_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct GlyphBBox {
3030
pub type Fixed = i32;
3131
/// cbindgen:ignore
3232
#[cfg(target_os = "macos")]
33-
pub type Fixed = i32;
33+
pub type Fixed = u32;
3434
pub type OTTag = u32;
3535
pub type GlyphID = u16;
3636
/// cbindgen:ignore

crates/xetex_layout/src/font.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,13 @@ impl Font {
358358
CFDictionary::new([(FontAttribute::CascadeList.to_str(), empty_cascade_list)]);
359359

360360
*descriptor = descriptor.copy_with_attrs(&attributes);
361-
*font_ref = Some(
362-
CTFont::new_descriptor(descriptor, self.point_size as f64 * 72.0 / 72.27).ok_or(())?,
363-
);
361+
*font_ref = Some(CTFont::new_descriptor(
362+
descriptor,
363+
self.point_size as f64 * 72.0 / 72.27,
364+
));
364365
let mut index = 0;
365-
let pathname =
366-
get_file_name_from_ct_font(font_ref.as_ref().unwrap(), &mut index).ok_or(())?;
367-
let pathname_str = pathname.to_str().map_err(|_| ())?;
368-
self.initialize_ft(pathname_str, index as usize)
366+
let pathname = get_file_name_from_ct_font(font_ref.as_ref().unwrap(), &mut index).unwrap();
367+
self.initialize_ft(pathname.to_str().unwrap(), index as usize)
369368
}
370369

371370
pub(crate) fn ft_face(&self) -> std::sync::MutexGuard<'_, ft::Face> {

crates/xetex_layout/src/manager/mac.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ impl MacBackend {
5555
}
5656

5757
fn add_font_and_siblings_to_caches(&self, maps: &mut FontMaps, font: &CTFontDescriptor) {
58-
let Some(font) = CTFont::new_descriptor(font, 10.0) else {
59-
return;
60-
};
58+
let font = CTFont::new_descriptor(font, 10.0);
6159
let attr = font.attr(FontAttribute::FamilyName).unwrap();
6260
// SAFETY: CFString has no generic parameters
6361
let family = unsafe { attr.downcast::<CFString>() }.unwrap();
@@ -81,9 +79,7 @@ impl FontManagerBackend for MacBackend {
8179
fn get_platform_font_desc<'a>(&'a self, font: &'a PlatformFontRef) -> Cow<'a, CStr> {
8280
let mut path = Cow::Borrowed(c"[unknown]");
8381

84-
let Some(ct_font) = CTFont::new_descriptor(font, 0.0) else {
85-
return path;
86-
};
82+
let ct_font = CTFont::new_descriptor(font, 0.0);
8783
let url = ct_font
8884
.attr(FontAttribute::URL)
8985
// SAFETY: CFUrl has no generic parameters
@@ -158,9 +154,7 @@ impl FontManagerBackend for MacBackend {
158154

159155
names.ps_name = Some(ps_name.get_cstring());
160156

161-
let Some(font) = CTFont::new_descriptor(&font, 0.0) else {
162-
return names;
163-
};
157+
let font = CTFont::new_descriptor(&font, 0.0);
164158
append_name_to_list(&font, &mut names.full_names, FontNameKey::Full);
165159
append_name_to_list(&font, &mut names.family_names, FontNameKey::Family);
166160
append_name_to_list(&font, &mut names.style_names, FontNameKey::Style);

0 commit comments

Comments
 (0)