|
7 | 7 | // option. This file may not be copied, modified, or distributed
|
8 | 8 | // except according to those terms.
|
9 | 9 |
|
10 |
| -use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType}; |
| 10 | +use core_foundation::base::{CFRelease, CFRetain, CFType, CFTypeID, TCFType}; |
11 | 11 | use core_foundation::array::{CFArray, CFArrayRef};
|
12 | 12 | use core_foundation::data::{CFData, CFDataRef};
|
13 | 13 | use core_foundation::number::CFNumber;
|
@@ -122,6 +122,24 @@ impl CGFont {
|
122 | 122 | None
|
123 | 123 | }
|
124 | 124 | }
|
| 125 | + |
| 126 | + pub fn copy_variations(&self) -> Option<CFDictionary<CFString, CFNumber>> { |
| 127 | + let variations = unsafe { CGFontCopyVariations(self.as_ptr()) }; |
| 128 | + if !variations.is_null() { |
| 129 | + Some(unsafe { TCFType::wrap_under_create_rule(variations) }) |
| 130 | + } else { |
| 131 | + None |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + pub fn copy_variation_axes(&self) -> Option<CFArray<CFDictionary<CFString, CFType>>> { |
| 136 | + let axes = unsafe { CGFontCopyVariationAxes(self.as_ptr()) }; |
| 137 | + if !axes.is_null() { |
| 138 | + Some(unsafe { TCFType::wrap_under_create_rule(axes) }) |
| 139 | + } else { |
| 140 | + None |
| 141 | + } |
| 142 | + } |
125 | 143 | }
|
126 | 144 |
|
127 | 145 | #[link(name = "CoreGraphics", kind = "framework")]
|
@@ -153,4 +171,6 @@ extern {
|
153 | 171 |
|
154 | 172 | fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef;
|
155 | 173 | fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef;
|
| 174 | + fn CGFontCopyVariations(font: ::sys::CGFontRef) -> CFDictionaryRef; |
| 175 | + fn CGFontCopyVariationAxes(font: ::sys::CGFontRef) -> CFArrayRef; |
156 | 176 | }
|
0 commit comments