emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix synthetic bold on macOS retina displays


From: Alan Third
Subject: [PATCH] Fix synthetic bold on macOS retina displays
Date: Mon, 29 Aug 2016 20:56:19 +0100
User-agent: Mutt/1.6.0 (2016-04-01)

* src/macfont.m (macfont_draw): Multiply the synthetic bold scaling
factor by the OS window backing scale factor.
---
 src/macfont.m | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/macfont.m b/src/macfont.m
index c799100..d9bad03 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2878,7 +2878,19 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor 
(no
       if (macfont_info->synthetic_bold_p && ! no_antialias_p)
         {
           CGContextSetTextDrawingMode (context, kCGTextFillStroke);
+
+          /* Stroke line width for text drawing is not correctly
+             scaled on Retina display/HiDPI mode when drawn to screen
+             (whereas it is correctly scaled when drawn to bitmaps),
+             and synthetic bold looks thinner on such environments.
+             Apple says there are no plans to address this issue
+             (rdar://11644870) currently.  So we add a workaround.  */
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+          CGContextSetLineWidth (context, synthetic_bold_factor * font_size
+                                 * [[FRAME_NS_VIEW(f) window] 
backingScaleFactor]);
+#else
           CGContextSetLineWidth (context, synthetic_bold_factor * font_size);
+#endif
           CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND (context, face, f);
         }
       if (no_antialias_p)
-- 

Not a lot to this. I hope you don’t mind that I stole your explanatory
comment completely.

We don’t (as far as I’m aware) have a neat way of checking versions at
run‐time, so I’ve just stuck to making it a compile‐time check.

-- 
Alan Third



reply via email to

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