From 4b7f335c113bf32ecd1a81a5bdc4e5c0899e233b Mon Sep 17 00:00:00 2001 From: Adrian Robert Date: Sun, 14 Jun 2009 18:58:38 +0000 Subject: [PATCH] * nsfont.m (ns_attribute_value): Remove. (ns_attribute_fvalue): Incorporate code from ns_attribute_value. (ns_has_attribute): Shrink the normal range. (ns_findfonts): Don't worry about requested spec in determining need for synthItal. --- src/ChangeLog | 8 ++++++++ src/nsfont.m | 24 ++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ab357bda4ce..8b3ebdc763e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2009-06-14 Adrian Robert + + * nsfont.m (ns_attribute_value): Remove. + (ns_attribute_fvalue): Incorporate code from ns_attribute_value. + (ns_has_attribute): Shrink the normal range. + (ns_findfonts): Don't worry about requested spec in determining + need for synthItal. + 2009-06-14 Seiji Zenitani * xdisp.c [USE_MAC_TOOLBAR]: Remove obsolete definition for Mac Carbon. diff --git a/src/nsfont.m b/src/nsfont.m index dde21ccd019..c5e73604e7a 100644 --- a/src/nsfont.m +++ b/src/nsfont.m @@ -106,21 +106,15 @@ ns_get_family (Lisp_Object font_spec) } -/* Return NSNumber or nil if attr is not set. */ -static NSNumber -*ns_attribute_value (NSFontDescriptor *fdesc, NSString *trait) -{ - NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute]; - NSNumber *val = [tdict objectForKey: trait]; - return val; -} - - -/* Return 0 if attr not set, else value (which might also be 0). */ +/* Return 0 if attr not set, else value (which might also be 0). + On Leopard 0 gets returned even on descriptors where the attribute + was never set, so there's no way to distinguish between unspecified + and set to not have. Callers should assume 0 means unspecified. */ static float ns_attribute_fvalue (NSFontDescriptor *fdesc, NSString *trait) { - NSNumber *val = ns_attribute_value (fdesc, trait); + NSDictionary *tdict = [fdesc objectForKey: NSFontTraitsAttribute]; + NSNumber *val = [tdict objectForKey: trait]; return val == nil ? 0.0 : [val floatValue]; } @@ -130,7 +124,7 @@ static BOOL ns_has_attribute (NSFontDescriptor *fdesc, NSString *trait) { float v = ns_attribute_fvalue (fdesc, trait); - return v < -0.25 || v > 0.25; + return v < -0.05 || v > 0.05; } @@ -502,9 +496,7 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch) /* Add synthItal member if needed. */ family = [fdesc objectForKey: NSFontFamilyAttribute]; - if (family != nil && !foundItal && XINT (Flength (list)) > 0 - && (ns_attribute_value (fdesc, NSFontSlantTrait) == nil - || ns_has_attribute (fdesc, NSFontSlantTrait))) + if (family != nil && !foundItal && XINT (Flength (list)) > 0) { NSFontDescriptor *sDesc = [[[NSFontDescriptor new] fontDescriptorWithSymbolicTraits: NSFontItalicTrait] -- 2.39.2