diff options
author | Po Lu <luangruo@yahoo.com> | 2022-05-05 17:01:53 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-05-05 17:01:53 +0800 |
commit | 30caeb789659441f8feb76b24f3d0b1f60125085 (patch) | |
tree | 1a107350480aacd4008b45faefb79587556aeeec | |
parent | 1bfea2ae6948fab9b1e0d7530d10173def070f79 (diff) | |
download | emacs-30caeb789659441f8feb76b24f3d0b1f60125085.tar.gz |
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.
-rw-r--r-- | src/macfont.m | 2 | ||||
-rw-r--r-- | src/nsterm.m | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/macfont.m b/src/macfont.m index 35648df06c6..4dd55e77469 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 8e8d5c969be..fef7f0dc6c8 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); |