@@ -180,6 +180,18 @@ pub fn new_from_descriptor(desc: &CTFontDescriptor, pt_size: f64) -> CTFont {
180
180
}
181
181
}
182
182
183
+ pub fn new_from_descriptor_and_options ( desc : & CTFontDescriptor , pt_size : f64 , options : CTFontOptions ) -> CTFont {
184
+ unsafe {
185
+ let font_ref = CTFontCreateWithFontDescriptorAndOptions (
186
+ desc. as_concrete_TypeRef ( ) ,
187
+ pt_size as CGFloat ,
188
+ ptr:: null ( ) ,
189
+ options,
190
+ ) ;
191
+ CTFont :: wrap_under_create_rule ( font_ref)
192
+ }
193
+ }
194
+
183
195
pub fn new_from_buffer ( buffer : & [ u8 ] ) -> Result < CTFont , ( ) > {
184
196
let ct_font_descriptor = create_font_descriptor ( buffer) ?;
185
197
Ok ( new_from_descriptor ( & ct_font_descriptor, 16.0 ) )
@@ -198,6 +210,19 @@ pub fn new_from_name(name: &str, pt_size: f64) -> Result<CTFont, ()> {
198
210
}
199
211
}
200
212
213
+ pub fn new_from_name_and_options ( name : & str , pt_size : f64 , options : CTFontOptions ) -> Result < CTFont , ( ) > {
214
+ unsafe {
215
+ let name: CFString = name. parse ( ) . unwrap ( ) ;
216
+ let font_ref =
217
+ CTFontCreateWithNameAndOptions ( name. as_concrete_TypeRef ( ) , pt_size as CGFloat , ptr:: null ( ) , options) ;
218
+ if font_ref. is_null ( ) {
219
+ Err ( ( ) )
220
+ } else {
221
+ Ok ( CTFont :: wrap_under_create_rule ( font_ref) )
222
+ }
223
+ }
224
+ }
225
+
201
226
pub fn new_ui_font_for_language (
202
227
ui_type : CTFontUIFontType ,
203
228
size : f64 ,
@@ -611,13 +636,23 @@ extern "C" {
611
636
size : CGFloat ,
612
637
matrix : * const CGAffineTransform ,
613
638
) -> CTFontRef ;
614
- //fn CTFontCreateWithNameAndOptions
639
+ fn CTFontCreateWithNameAndOptions (
640
+ name : CFStringRef ,
641
+ size : CGFloat ,
642
+ matrix : * const CGAffineTransform ,
643
+ options : CTFontOptions ,
644
+ ) -> CTFontRef ;
615
645
fn CTFontCreateWithFontDescriptor (
616
646
descriptor : CTFontDescriptorRef ,
617
647
size : CGFloat ,
618
648
matrix : * const CGAffineTransform ,
619
649
) -> CTFontRef ;
620
- //fn CTFontCreateWithFontDescriptorAndOptions
650
+ fn CTFontCreateWithFontDescriptorAndOptions (
651
+ descriptor : CTFontDescriptorRef ,
652
+ size : CGFloat ,
653
+ matrix : * const CGAffineTransform ,
654
+ options : CTFontOptions ,
655
+ ) -> CTFontRef ;
621
656
fn CTFontCreateUIFontForLanguage (
622
657
uiType : CTFontUIFontType ,
623
658
size : CGFloat ,
0 commit comments