diff options
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2015-08-25 11:06:27 +0900 |
---|---|---|
committer | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2015-08-25 11:06:27 +0900 |
commit | 1229e61ab8fe7143fbe7d8a2686a6521627b77a2 (patch) | |
tree | 133f615bd250f9b0cf8b1123cc12fadf474ca0c5 /src/macfont.m | |
parent | 7b5290da89e927ba01ac51e1eaaffd828503285f (diff) | |
download | emacs-1229e61ab8fe7143fbe7d8a2686a6521627b77a2.tar.gz |
* src/macfont.m (macfont_create_family_with_symbol): Accept localized names.
Diffstat (limited to 'src/macfont.m')
-rw-r--r-- | src/macfont.m | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/src/macfont.m b/src/macfont.m index 02dc46824e9..d0d7252f350 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -1038,49 +1038,44 @@ static CFStringRef macfont_create_family_with_symbol (Lisp_Object symbol) { CFStringRef result = NULL, family_name; - CFComparatorFunction family_name_comparator; + CFDictionaryRef attributes = NULL; + FontDescriptorRef pat_desc = NULL; if (macfont_get_family_cache_if_present (symbol, &result)) return result ? CFRetain (result) : NULL; family_name = cfstring_create_with_string_noencode (SYMBOL_NAME (symbol)); - if (family_name == NULL) - return NULL; - + if (family_name) { - family_name_comparator = CTFontManagerCompareFontFamilyNames; + attributes = + CFDictionaryCreate (NULL, + (const void **) &MAC_FONT_FAMILY_NAME_ATTRIBUTE, + (const void **) &family_name, 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFRelease (family_name); } - - if ((*family_name_comparator) (family_name, CFSTR ("LastResort"), NULL) - == kCFCompareEqualTo) - result = CFSTR ("LastResort"); - else + if (attributes) { - CFIndex i, count; - CFArrayRef families = macfont_copy_available_families_cache (); + pat_desc = mac_font_descriptor_create_with_attributes (attributes); + CFRelease (attributes); + } + if (pat_desc) + { + FontDescriptorRef desc = + mac_font_descriptor_create_matching_font_descriptor (pat_desc, NULL); - if (families) + if (desc) { - count = CFArrayGetCount (families); - i = CFArrayBSearchValues (families, CFRangeMake (0, count), - (const void *) family_name, - family_name_comparator, NULL); - if (i < count) - { - CFStringRef name = CFArrayGetValueAtIndex (families, i); - - if ((*family_name_comparator) (name, family_name, NULL) - == kCFCompareEqualTo) - result = CFRetain (name); - } - CFRelease (families); + result = + mac_font_descriptor_copy_attribute (desc, + MAC_FONT_FAMILY_NAME_ATTRIBUTE); + CFRelease (desc); } + macfont_set_family_cache (symbol, result); + CFRelease (pat_desc); } - CFRelease (family_name); - - macfont_set_family_cache (symbol, result); - return result; } |