Implement stub for [UIFont systemFontOfSize:]

This commit is contained in:
hikari_no_yume
2023-01-16 17:22:38 +01:00
parent f341da0aeb
commit 2acaf60e4c
3 changed files with 35 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ use crate::export_c_func;
pub mod ui_accelerometer;
pub mod ui_application;
pub mod ui_device;
pub mod ui_font;
pub mod ui_nib;
pub mod ui_responder;
pub mod ui_screen;

View File

@@ -0,0 +1,33 @@
//! `UIFont`.
use crate::frameworks::core_graphics::CGFloat;
use crate::objc::{autorelease, id, objc_classes, ClassExports, HostObject};
struct UIFontHostObject {
_size: CGFloat,
}
impl HostObject for UIFontHostObject {}
pub const CLASSES: ClassExports = objc_classes! {
(env, this, _cmd);
// For now this is a singleton (the only instance is returned by mainScreen),
// so there are hardcoded assumptions related to that.
@implementation UIFont: NSObject
+ (id)systemFontOfSize:(CGFloat)font_size {
// TODO: actually load and render fonts
let new = env.objc.alloc_object(
this,
Box::new(UIFontHostObject {
_size: font_size,
}),
&mut env.mem
);
autorelease(env, new)
}
@end
};

View File

@@ -24,6 +24,7 @@ pub const CLASS_LISTS: &[super::ClassExports] = &[
opengles::eagl::CLASSES,
uikit::ui_accelerometer::CLASSES,
uikit::ui_application::CLASSES,
uikit::ui_font::CLASSES,
uikit::ui_nib::CLASSES,
uikit::ui_responder::CLASSES,
uikit::ui_screen::CLASSES,