From b9173dc296f964cab904fc5eae02344e1b59eed2 Mon Sep 17 00:00:00 2001 From: Adrian Robert Date: Sun, 2 Aug 2009 15:37:07 +0000 Subject: [PATCH] * nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has no family set. (nsfont_open): Handle case when entity has no family. --- src/ChangeLog | 6 ++++++ src/nsfont.m | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 989831d6763..a33144b7a33 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-08-02 Adrian Robert + + * nsfont.m (ns_descriptor_to_entity): Handle case when descriptor has + no family set. + (nsfont_open): Handle case when entity has no family. + 2009-07-29 Adrian Robert * nsfont.m (ns_findfonts): Fix 2009-07-24 change to return only one diff --git a/src/nsfont.m b/src/nsfont.m index a4c4444069b..46c50aa96d3 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -166,9 +166,16 @@ ns_descriptor_to_entity (NSFontDescriptor *desc, Lisp_Object extra, char *style) Lisp_Object font_entity = font_make_entity (); /* NSString *psName = [desc postscriptName]; */ NSString *family = [desc objectForKey: NSFontFamilyAttribute]; - char *escapedFamily = strdup ([family UTF8String]); unsigned int traits = [desc symbolicTraits]; + char *escapedFamily; + /* Shouldn't happen, but on Tiger fallback desc gets name but no family. */ + if (family == nil) + family = [desc objectForKey: NSFontNameAttribute]; + if (family == nil) + family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; + + escapedFamily = strdup ([family UTF8String]); ns_escape_name (escapedFamily); ASET (font_entity, FONT_TYPE_INDEX, Qns); @@ -669,6 +676,8 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size) synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)), 9); family = ns_get_family (font_entity); + if (family == nil) + family = [[NSFont userFixedPitchFontOfSize: 0] familyName]; /* Should be > 0.23 as some font descriptors (e.g. Terminus) set to that when setting family in ns_spec_to_descriptor(). */ if (ns_attribute_fvalue (fontDesc, NSFontWeightTrait) > 0.50) -- 2.39.2