|
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,25 @@ 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_axis(&self) -> Option<CFArray<CFDictionary<CFString, CFType>>> { |
| 136 | + unsafe { |
| 137 | + let axes = CGFontCopyVariationAxes(self.as_ptr()); |
| 138 | + if axes.is_null() { |
| 139 | + return None; |
| 140 | + } |
| 141 | + Some(TCFType::wrap_under_create_rule(axes)) |
| 142 | + } |
| 143 | + } |
125 | 144 | }
|
126 | 145 |
|
127 | 146 | #[link(name = "CoreGraphics", kind = "framework")]
|
@@ -153,4 +172,6 @@ extern {
|
153 | 172 |
|
154 | 173 | fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef;
|
155 | 174 | fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef;
|
| 175 | + fn CGFontCopyVariations(font: ::sys::CGFontRef) -> CFDictionaryRef; |
| 176 | + fn CGFontCopyVariationAxes(font: ::sys::CGFontRef) -> CFArrayRef; |
156 | 177 | }
|
0 commit comments