Skip to content

Commit f527a1f

Browse files
author
bors-servo
authored
Auto merge of #57 - algesten:cascade, r=jdm
CTFontCopyDefaultCascadeListForLanguages This adds `cascade_list_for_languages` to get apple's built in font fallbacks chains per font/language list combo. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-text-rs/57) <!-- Reviewable:end -->
2 parents 9648cb5 + 66b4970 commit f527a1f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/font.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use font_descriptor::{CTFontDescriptor, CTFontDescriptorRef, CTFontOrientation};
1313
use font_descriptor::{CTFontSymbolicTraits, CTFontTraits, SymbolicTraitAccessors, TraitAccessors};
1414

15+
use core_foundation::array::{CFArray, CFArrayRef};
1516
use core_foundation::base::{CFIndex, CFOptionFlags, CFTypeID, CFRelease, CFRetain, CFTypeRef, TCFType};
1617
use core_foundation::data::{CFData, CFDataRef};
1718
use core_foundation::dictionary::CFDictionaryRef;
@@ -378,6 +379,15 @@ pub fn debug_font_traits(font: &CTFont) {
378379
// println!("kCTFontSlantTrait: {}", traits.normalized_slant());
379380
}
380381

382+
pub fn cascade_list_for_languages(font: &CTFont, language_pref_list: &CFArray) -> CFArray {
383+
unsafe {
384+
let font_collection_ref =
385+
CTFontCopyDefaultCascadeListForLanguages(font.as_concrete_TypeRef(),
386+
language_pref_list.as_concrete_TypeRef());
387+
TCFType::wrap_under_create_rule(font_collection_ref)
388+
}
389+
}
390+
381391
#[link(name = "ApplicationServices", kind = "framework")]
382392
extern {
383393
/*
@@ -453,6 +463,8 @@ extern {
453463
fn CTFontCopyName(font: CTFontRef, nameKey: CFStringRef) -> CFStringRef;
454464
//fn CTFontCopyLocalizedName(font: CTFontRef, nameKey: CFStringRef,
455465
// language: *CFStringRef) -> CFStringRef;
466+
fn CTFontCopyDefaultCascadeListForLanguages(font: CTFontRef, languagePrefList: CFArrayRef) -> CFArrayRef;
467+
456468

457469
/* Working With Encoding */
458470
//fn CTFontCopyCharacterSet

0 commit comments

Comments
 (0)