all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#28222: [PATCH] Use thin font smoothing in macOS
@ 2017-08-24 11:20 Ben Bonfil
  2017-08-25  2:44 ` Richard Stallman
  2017-08-25 16:13 ` Alan Third
  0 siblings, 2 replies; 10+ messages in thread
From: Ben Bonfil @ 2017-08-24 11:20 UTC (permalink / raw)
  To: 28222


[-- Attachment #1.1: Type: text/plain, Size: 212 bytes --]

Hello,

Attached is a small patch that enables thin font smoothing on macOS, just
like in iTerm2.
It is toggled by a new variable called ns-use-thin-smoothing.

Tested only on macOS Sierra (10.12.6)

Thanks,
Ben

[-- Attachment #1.2: Type: text/html, Size: 347 bytes --]

[-- Attachment #2: 0001-Enable-thin-font-smoothing-in-macOS.patch --]
[-- Type: application/octet-stream, Size: 1644 bytes --]

From ba01cb956284193d41b9cf6b3a260385fa367039 Mon Sep 17 00:00:00 2001
From: Ben Bonfil <bonfil@gmail.com>
Date: Thu, 24 Aug 2017 12:59:50 +0200
Subject: [PATCH] Enable thin font smoothing in macOS

* src/nsterm.m (syms_of_nsterm): Define var ns-use-thin-smoothing.
* src/macfont.m (macfont_draw): Use font smoothing.
---
 src/macfont.m | 5 +++++
 src/nsterm.m  | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/src/macfont.m b/src/macfont.m
index 19145f92c0..8a4d0fa481 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2888,6 +2888,11 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
       if (no_antialias_p)
         CGContextSetShouldAntialias (context, false);
 
+      if (!NILP (ns_use_thin_smoothing)) {
+          CGContextSetShouldSmoothFonts(context, YES);
+          CGContextSetFontSmoothingStyle(context, 16);
+      }
+
       CGContextSetTextMatrix (context, atfm);
       CGContextSetTextPosition (context, text_position.x, text_position.y);
 
diff --git a/src/nsterm.m b/src/nsterm.m
index 22f8efd6b9..ff3329d1ce 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -9133,6 +9133,10 @@ Convert an X font name (XLFD) to an NS font name.
                "Non-nil (the default) means to render text antialiased.");
   ns_antialias_text = Qt;
 
+  DEFVAR_LISP ("ns-use-thin-smoothing", ns_use_thin_smoothing,
+               "Non-nil turns on a font smoothing method that produces thinner strokes.");
+  ns_use_thin_smoothing = Qnil;
+
   DEFVAR_LISP ("ns-confirm-quit", ns_confirm_quit,
                "Whether to confirm application quit using dialog.");
   ns_confirm_quit = Qnil;
-- 
2.11.0 (Apple Git-81)


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-29 16:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 11:20 bug#28222: [PATCH] Use thin font smoothing in macOS Ben Bonfil
2017-08-25  2:44 ` Richard Stallman
2017-08-25  7:29   ` Alan Third
2017-08-25 19:09     ` Richard Stallman
2017-08-25 16:13 ` Alan Third
2017-08-25 16:58   ` Ben Bonfil
2017-08-25 20:02     ` Alan Third
2017-08-26  7:27       ` Eli Zaretskii
2017-08-29 10:09       ` Ben Bonfil
2017-08-29 16:27         ` Alan Third

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.