@@ -23,7 +23,7 @@ use core_graphics::context::{CGContext, CGContextRef};
23
23
use core_graphics:: font:: { CGGlyph , CGFont , CGFontRef } ;
24
24
use core_graphics:: geometry:: { CGPoint , CGRect , CGSize } ;
25
25
26
- use libc:: { self , size_t} ;
26
+ use libc:: { self , size_t, c_void } ;
27
27
use std:: mem;
28
28
use std:: ptr;
29
29
@@ -70,7 +70,7 @@ pub const kCTFontOptionsPreventAutoActivation: CTFontOptions = (1 << 0);
70
70
pub const kCTFontOptionsPreferSystemFont: CTFontOptions = ( 1 << 2 ) ;
71
71
72
72
#[ repr( C ) ]
73
- struct __CTFont ;
73
+ pub struct __CTFont ( c_void ) ;
74
74
75
75
pub type CTFontRef = * const __CTFont ;
76
76
@@ -193,23 +193,31 @@ impl CTFont {
193
193
194
194
// Names
195
195
pub fn family_name ( & self ) -> String {
196
- let value = get_string_by_name_key ( self , kCTFontFamilyNameKey) ;
197
- value. expect ( "Fonts should always have a family name." )
196
+ unsafe {
197
+ let value = get_string_by_name_key ( self , kCTFontFamilyNameKey) ;
198
+ value. expect ( "Fonts should always have a family name." )
199
+ }
198
200
}
199
201
200
202
pub fn face_name ( & self ) -> String {
201
- let value = get_string_by_name_key ( self , kCTFontSubFamilyNameKey) ;
202
- value. expect ( "Fonts should always have a face name." )
203
+ unsafe {
204
+ let value = get_string_by_name_key ( self , kCTFontSubFamilyNameKey) ;
205
+ value. expect ( "Fonts should always have a face name." )
206
+ }
203
207
}
204
208
205
209
pub fn unique_name ( & self ) -> String {
206
- let value = get_string_by_name_key ( self , kCTFontUniqueNameKey) ;
207
- value. expect ( "Fonts should always have a unique name." )
210
+ unsafe {
211
+ let value = get_string_by_name_key ( self , kCTFontUniqueNameKey) ;
212
+ value. expect ( "Fonts should always have a unique name." )
213
+ }
208
214
}
209
215
210
216
pub fn postscript_name ( & self ) -> String {
211
- let value = get_string_by_name_key ( self , kCTFontPostScriptNameKey) ;
212
- value. expect ( "Fonts should always have a PostScript name." )
217
+ unsafe {
218
+ let value = get_string_by_name_key ( self , kCTFontPostScriptNameKey) ;
219
+ value. expect ( "Fonts should always have a PostScript name." )
220
+ }
213
221
}
214
222
215
223
pub fn all_traits ( & self ) -> CTFontTraits {
@@ -357,12 +365,14 @@ pub fn debug_font_names(font: &CTFont) {
357
365
get_string_by_name_key ( font, key) . unwrap ( )
358
366
}
359
367
360
- println ! ( "kCTFontFamilyNameKey: {}" , get_key( font, kCTFontFamilyNameKey) ) ;
361
- println ! ( "kCTFontSubFamilyNameKey: {}" , get_key( font, kCTFontSubFamilyNameKey) ) ;
362
- println ! ( "kCTFontStyleNameKey: {}" , get_key( font, kCTFontStyleNameKey) ) ;
363
- println ! ( "kCTFontUniqueNameKey: {}" , get_key( font, kCTFontUniqueNameKey) ) ;
364
- println ! ( "kCTFontFullNameKey: {}" , get_key( font, kCTFontFullNameKey) ) ;
365
- println ! ( "kCTFontPostScriptNameKey: {}" , get_key( font, kCTFontPostScriptNameKey) ) ;
368
+ unsafe {
369
+ println ! ( "kCTFontFamilyNameKey: {}" , get_key( font, kCTFontFamilyNameKey) ) ;
370
+ println ! ( "kCTFontSubFamilyNameKey: {}" , get_key( font, kCTFontSubFamilyNameKey) ) ;
371
+ println ! ( "kCTFontStyleNameKey: {}" , get_key( font, kCTFontStyleNameKey) ) ;
372
+ println ! ( "kCTFontUniqueNameKey: {}" , get_key( font, kCTFontUniqueNameKey) ) ;
373
+ println ! ( "kCTFontFullNameKey: {}" , get_key( font, kCTFontFullNameKey) ) ;
374
+ println ! ( "kCTFontPostScriptNameKey: {}" , get_key( font, kCTFontPostScriptNameKey) ) ;
375
+ }
366
376
}
367
377
368
378
pub fn debug_font_traits ( font : & CTFont ) {
0 commit comments