|
7 | 7 | // option. This file may not be copied, modified, or distributed
|
8 | 8 | // except according to those terms.
|
9 | 9 |
|
| 10 | +use std::ptr; |
10 | 11 | use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType};
|
| 12 | +use core_foundation::array::{CFArray, CFArrayRef}; |
| 13 | +use core_foundation::data::{CFData, CFDataRef}; |
11 | 14 | use core_foundation::string::{CFString, CFStringRef};
|
12 | 15 | use data_provider::CGDataProvider;
|
13 | 16 | use geometry::CGRect;
|
@@ -91,6 +94,21 @@ impl CGFont {
|
91 | 94 | CGFontGetUnitsPerEm(self.as_ptr())
|
92 | 95 | }
|
93 | 96 | }
|
| 97 | + |
| 98 | + pub fn copy_table_tags(&self) -> CFArray<u32> { |
| 99 | + unsafe { |
| 100 | + TCFType::wrap_under_create_rule(CGFontCopyTableTags(self.as_ptr())) |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + pub fn copy_table_for_tag(&self, tag: u32) -> Option<CFData> { |
| 105 | + let data_ref = unsafe { CGFontCopyTableForTag(self.as_ptr(), tag) }; |
| 106 | + if data_ref != ptr::null() { |
| 107 | + Some(unsafe { TCFType::wrap_under_create_rule(data_ref) }) |
| 108 | + } else { |
| 109 | + None |
| 110 | + } |
| 111 | + } |
94 | 112 | }
|
95 | 113 |
|
96 | 114 | #[link(name = "CoreGraphics", kind = "framework")]
|
@@ -118,4 +136,7 @@ extern {
|
118 | 136 | advances: *mut c_int)
|
119 | 137 | -> bool;
|
120 | 138 | fn CGFontGetUnitsPerEm(font: ::sys::CGFontRef) -> c_int;
|
| 139 | + |
| 140 | + fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef; |
| 141 | + fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef; |
121 | 142 | }
|
0 commit comments