Skip to content

Commit c6d7268

Browse files
authored
Auto merge of #480 - jrmuizel:system-font, r=mstange
Test that we can create a new CTFont from the descriptor attributes. None
2 parents 92bae14 + 1ad1253 commit c6d7268

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core-text/src/font.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ fn macos_version() -> (i32, i32, i32) {
691691

692692
#[test]
693693
fn copy_system_font() {
694+
use crate::*;
695+
694696
let small = unsafe {
695697
CTFont::wrap_under_create_rule(
696698
CTFontCreateUIFontForLanguage(kCTFontSystemDetailFontType, 19., std::ptr::null())
@@ -712,6 +714,12 @@ fn copy_system_font() {
712714
let ctfont = new_from_descriptor(&desc, 20.);
713715
assert_eq!(big.postscript_name(), ctfont.postscript_name());
714716

717+
// check that we can construct a new version by attributes
718+
let attr = desc.attributes();
719+
let desc_from_attr = font_descriptor::new_from_attributes(&attr);
720+
let font_from_attr = new_from_descriptor(&desc_from_attr, 19.);
721+
assert_eq!(font_from_attr.postscript_name(), small.postscript_name());
722+
715723
// on newer versions of macos we can't construct by name anymore
716724
if macos_version() < (10, 13, 0) {
717725
let ui_font_by_name = new_from_name(&small.postscript_name(), 19.).unwrap();

0 commit comments

Comments
 (0)