mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
Better sorting of fonts
Rather than sorting fonts by the integer value of "traits", let's sort by the traits we are looking for specifically. Again, like many other things, totally correct handling of this stuff will have to wait for a good method of inspecting and correctly processing SFNT tables.
This commit is contained in:
parent
d0a9f5b943
commit
1b23bfe1fd
1 changed files with 17 additions and 4 deletions
|
@ -94,13 +94,26 @@ sortFontFacesArray(id fontArr1, id fontArr2, void *context)
|
|||
unsigned int traits2 = [[fontArr2 objectAtIndex: 3] unsignedIntValue];
|
||||
|
||||
// order first by weight
|
||||
if (weight1 > weight2)
|
||||
return NSOrderedDescending;
|
||||
if (weight1 < weight2)
|
||||
return NSOrderedAscending;
|
||||
if (traits1 < traits2)
|
||||
if (weight1 > weight2)
|
||||
return NSOrderedDescending;
|
||||
|
||||
// Italic next
|
||||
if ((traits1 & NSItalicFontMask) < (traits2 & NSItalicFontMask))
|
||||
return NSOrderedAscending;
|
||||
if (traits1 > traits2)
|
||||
if ((traits1 & NSItalicFontMask) > (traits2 & NSItalicFontMask))
|
||||
return NSOrderedDescending;
|
||||
|
||||
// now do condensed
|
||||
if ((traits1 & NSCondensedFontMask) < (traits2 & NSCondensedFontMask))
|
||||
return NSOrderedAscending;
|
||||
if ((traits1 & NSCondensedFontMask) > (traits2 & NSCondensedFontMask))
|
||||
return NSOrderedDescending;
|
||||
// ...and expanded
|
||||
if ((traits1 & NSExpandedFontMask) < (traits2 & NSExpandedFontMask))
|
||||
return NSOrderedAscending;
|
||||
if ((traits1 & NSExpandedFontMask) > (traits2 & NSExpandedFontMask))
|
||||
return NSOrderedDescending;
|
||||
|
||||
// Special case: "Regular" sorts before non-Regular, for many reasons.
|
||||
|
|
Loading…
Reference in a new issue