unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ben Bonfil <bonfil@gmail.com>
To: 28222@debbugs.gnu.org
Subject: bug#28222: [PATCH] Use thin font smoothing in macOS
Date: Thu, 24 Aug 2017 13:20:26 +0200	[thread overview]
Message-ID: <CAJFi9==t_hyBL=_BMPvrFNxz2uH4Th8Z1xDF52YwS1YtOGr=jw@mail.gmail.com> (raw)


[-- 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)


             reply	other threads:[~2017-08-24 11:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 11:20 Ben Bonfil [this message]
2017-08-25  2:44 ` bug#28222: [PATCH] Use thin font smoothing in macOS 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJFi9==t_hyBL=_BMPvrFNxz2uH4Th8Z1xDF52YwS1YtOGr=jw@mail.gmail.com' \
    --to=bonfil@gmail.com \
    --cc=28222@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).