Skip to content

Commit 987123d

Browse files
authored
Auto merge of #443 - jrmuizel:cg-variation, r=kvark
Expose CGFontCopyVariations and CGFontCopyVariationAxes
2 parents 78634a7 + d940352 commit 987123d

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

core-graphics/src/font.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
use core_foundation::base::{CFRelease, CFRetain, CFTypeID, TCFType};
10+
use core_foundation::base::{CFRelease, CFRetain, CFType, CFTypeID, TCFType};
1111
use core_foundation::array::{CFArray, CFArrayRef};
1212
use core_foundation::data::{CFData, CFDataRef};
1313
use core_foundation::number::CFNumber;
@@ -122,6 +122,24 @@ impl CGFont {
122122
None
123123
}
124124
}
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+
}
125143
}
126144

127145
#[link(name = "CoreGraphics", kind = "framework")]
@@ -153,4 +171,6 @@ extern {
153171

154172
fn CGFontCopyTableTags(font: ::sys::CGFontRef) -> CFArrayRef;
155173
fn CGFontCopyTableForTag(font: ::sys::CGFontRef, tag: u32) -> CFDataRef;
174+
fn CGFontCopyVariations(font: ::sys::CGFontRef) -> CFDictionaryRef;
175+
fn CGFontCopyVariationAxes(font: ::sys::CGFontRef) -> CFArrayRef;
156176
}

0 commit comments

Comments
 (0)