emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 30caeb7896: Fix font weight reporting on macOS


From: Po Lu
Subject: master 30caeb7896: Fix font weight reporting on macOS
Date: Thu, 5 May 2022 05:02:03 -0400 (EDT)

branch: master
commit 30caeb789659441f8feb76b24f3d0b1f60125085
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix font weight reporting on macOS
    
    * src/macfont.m (macfont_store_descriptor_attributes): Fix
    numeric values for the addition of `medium'.
    
    * src/nsterm.m (ns_font_desc_to_font_spec): Adjust accordingly.
    (ns_create_font_panel_buttons): Try to fix button width.
---
 src/macfont.m |  2 +-
 src/nsterm.m  | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/macfont.m b/src/macfont.m
index 35648df06c..4dd55e7746 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -847,7 +847,7 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef 
desc,
           {{FONT_WEIGHT_INDEX, kCTFontWeightTrait,
             {{-0.4, 50},       /* light */
              {-0.24, 87.5},    /* (semi-light + normal) / 2 */
-             {0, 100},         /* normal */
+             {0, 80},          /* normal */
              {0.24, 140},      /* (semi-bold + normal) / 2 */
              {0.4, 200},       /* bold */
              {CGFLOAT_MAX, CGFLOAT_MAX}},
diff --git a/src/nsterm.m b/src/nsterm.m
index 8e8d5c969b..fef7f0dc6c 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6092,10 +6092,26 @@ ns_font_desc_to_font_spec (NSFontDescriptor *desc, 
NSFont *font)
 
       tem = [dict objectForKey: NSFontWeightTrait];
 
+#ifdef NS_IMPL_GNUSTEP
       if (tem != nil)
        lweight = ([tem floatValue] > 0
                   ? Qbold : ([tem floatValue] < -0.4f
                              ? Qlight : Qnormal));
+#else
+      if (tem != nil)
+       {
+         if ([tem floatValue] >= 0.4)
+           lweight = Qbold;
+         else if ([tem floatValue] >= 0.24)
+           lweight = Qmedium;
+         else if ([tem floatValue] >= 0)
+           lweight = Qnormal;
+         else if ([tem floatValue] >= -0.24)
+           lweight = Qsemi_light;
+         else
+           lweight = Qlight;
+       }
+#endif
 
       tem = [dict objectForKey: NSFontWidthTrait];
 
@@ -6127,6 +6143,7 @@ ns_create_font_panel_buttons (id target, SEL select, SEL 
cancel_action)
 
   prototype = [[NSButtonCell alloc] init];
   [prototype setBezelStyle: NSBezelStyleRounded];
+  [prototype setTitle: @"Cancel"];
   cell_size = [prototype cellSize];
   frame = NSMakeRect (0, 0, cell_size.width * 2,
                      cell_size.height);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]