Revision: 28211
          http://sourceforge.net/p/bibdesk/svn/28211
Author:   hofman
Date:     2023-04-09 14:14:23 +0000 (Sun, 09 Apr 2023)
Log Message:
-----------
Use weight 4 for default name for Light SF font, as weight 3 is also used for 
Thin font.

Modified Paths:
--------------
    trunk/bibdesk/NSFont_BDSKExtensions.m

Modified: trunk/bibdesk/NSFont_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/NSFont_BDSKExtensions.m       2023-04-07 13:54:15 UTC (rev 
28210)
+++ trunk/bibdesk/NSFont_BDSKExtensions.m       2023-04-09 14:14:23 UTC (rev 
28211)
@@ -62,6 +62,7 @@
         } else if ([fontName isEqualToString:@"_system_font_b"]) {
             font =  [NSFont boldSystemFontOfSize:pointSize > 0 ? pointSize : 
12.0];
         } else {
+            NSString *familyName = [[NSFont systemFontOfSize:0.0] familyName];
             NSFontTraitMask traits = 0;
             NSInteger weight = 5;
             NSInteger i, nameLength = [fontName length];
@@ -83,7 +84,11 @@
             }
             if (i < nameLength)
                 weight = [[fontName substringFromIndex:i] integerValue] ?: 5;
-            font = [[NSFontManager sharedFontManager] fontWithFamily:[[NSFont 
systemFontOfSize:0.0] familyName] traits:traits weight:weight size:pointSize];
+            // weight 4 indicates Light SF font, see next method
+            if (weight == 4 && [familyName 
isEqualToString:@".AppleSystemUIFont"])
+                font = [NSFont fontWithName:(traits & NSItalicFontMask) ? 
@".AppleSystemUIFontLightItalic" : (traits & NSCondensedFontMask) ? 
@".AppleSystemUIFontCondensed-Light" : @".AppleSystemUIFontLight" 
size:pointSize];
+            else
+                font = [[NSFontManager sharedFontManager] 
fontWithFamily:familyName traits:traits weight:weight size:pointSize];
             // for some reason NSFontManager ignores the condensed trait in 
the method above
             if ((traits & NSCondensedFontMask) != 0)
                 font = [[NSFontManager sharedFontManager] convertFont:font 
toHaveTrait:NSCondensedFontMask];
@@ -115,6 +120,9 @@
         NSFontManager *fm = [NSFontManager sharedFontManager];
         NSInteger weight = [fm weightOfFont:self];
         NSFontTraitMask traits = [fm traitsOfFont:self];
+        // in SF, Light and Thin both have weight 3, so we use 4 for Light to 
distinguish
+        if (weight == 3 && [[self familyName] 
isEqualToString:@".AppleSystemUIFont"] && [fontName containsString:@"Light"])
+            weight = 4;
         fontName = @"_system_font_";
         // don't add "b", as that overrides the weight
         if ((traits & NSItalicFontMask))

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to