# HG changeset patch # User Adrian Robert # Date 1248113645 0 # Node ID 73ea181d96b6c8c7fbe5413b63281e5aa474ac8e # Parent 740cb01b8b8f8f0b46277e68afb2a9e05841104b * 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. (ns_get_covering_families): Retain scriptToFamilies. diff -r 740cb01b8b8f -r 73ea181d96b6 src/nsfont.m --- a/src/nsfont.m Mon Jul 20 16:40:24 2009 +0000 +++ b/src/nsfont.m Mon Jul 20 18:14:05 2009 +0000 @@ -119,15 +119,6 @@ } -/* Return whether font has attribute set to non-standard value. */ -static BOOL -ns_has_attribute (NSFontDescriptor *fdesc, NSString *trait) -{ - float v = ns_attribute_fvalue (fdesc, trait); - return v < -0.05 || v > 0.05; -} - - /* Converts FONT_WEIGHT, FONT_SLANT, FONT_WIDTH, plus family and script/lang to NSFont descriptor. Information under extra only needed for matching. */ #define STYLE_REF 100 @@ -490,7 +481,7 @@ list = Fcons (ns_descriptor_to_entity (desc, AREF (font_spec, FONT_EXTRA_INDEX), NULL), list); - if (ns_has_attribute (desc, NSFontSlantTrait)) + if (fabs (ns_attribute_fvalue (desc, NSFontSlantTrait)) > 0.05) foundItal = YES; } @@ -666,9 +657,11 @@ synthItal = !NILP (tem) && !strncmp ("synthItal", SDATA (SYMBOL_NAME (tem)), 9); family = ns_get_family (font_entity); - if (ns_has_attribute (fontDesc, NSFontWeightTrait)) + /* 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) traits |= NSBoldFontMask; - if (ns_has_attribute (fontDesc, NSFontSlantTrait)) + if (fabs (ns_attribute_fvalue (fontDesc, NSFontSlantTrait) > 0.05)) traits |= NSItalicFontMask; /* see http://cocoadev.com/forums/comments.php?DiscussionID=74 */