Test that we can create a new CTFont from the descriptor attributes.

This commit is contained in:
Jeff Muizelaar
2021-11-22 19:05:30 -05:00
parent 3d5df0a167
commit 1ad12536ec
+8
View File
@@ -691,6 +691,8 @@ fn macos_version() -> (i32, i32, i32) {
#[test]
fn copy_system_font() {
use crate::*;
let small = unsafe {
CTFont::wrap_under_create_rule(
CTFontCreateUIFontForLanguage(kCTFontSystemDetailFontType, 19., std::ptr::null())
@@ -712,6 +714,12 @@ fn copy_system_font() {
let ctfont = new_from_descriptor(&desc, 20.);
assert_eq!(big.postscript_name(), ctfont.postscript_name());
// check that we can construct a new version by attributes
let attr = desc.attributes();
let desc_from_attr = font_descriptor::new_from_attributes(&attr);
let font_from_attr = new_from_descriptor(&desc_from_attr, 19.);
assert_eq!(font_from_attr.postscript_name(), small.postscript_name());
// on newer versions of macos we can't construct by name anymore
if macos_version() < (10, 13, 0) {
let ui_font_by_name = new_from_name(&small.postscript_name(), 19.).unwrap();