Subject: bug#18876: 24.4; ns-antialias-text broken in 24.4

From: Scott Wheeler <[email-masked]>
Date: Tue, 28 Oct 2014 17:27:55 +0100

In previous emacs versions evaluating the following line would disable
antialiased fonts:

(setq ns-antialias-text nil)

That was broken in 24.4.  I'm attaching a patch that both fixes the
behavior and disables "synthetic bold", which looks pretty terrible with
antialiasing disabled.

I reported this on the emacs-devel list, but didn't receive any replies:

http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00833.html

commit c735f7e4af9375bba17e133a0d7b69a79ef604f1
Author: Scott Wheeler <[email-masked]>
Date:   Thu Oct 23 15:32:32 2014 +0200

    Disable synthetic bold when antialiased fonts are disabled

diff --git a/src/macfont.m b/src/macfont.m
index ee86d9b..cb2d0be 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2517,6 +2517,7 @@ macfont_open (struct frame * f, Lisp_Object entity, int pixel_size)
       && FONT_SLANT_NUMERIC (entity) == FONT_SLANT_SYNTHETIC_ITALIC)
     macfont_info->synthetic_italic_p = 1;
   if (!(sym_traits & MAC_FONT_TRAIT_BOLD)
+      && !NILP (ns_antialias_text)
       && FONT_WEIGHT_NUMERIC (entity) == FONT_WEIGHT_SYNTHETIC_BOLD)
     macfont_info->synthetic_bold_p = 1;
   if (sym_traits & MAC_FONT_TRAIT_MONO_SPACE)

commit aded58804f19f286a15b46f87f7835919f9c2efc
Author: Scott Wheeler <[email-masked]>
Date:   Thu Oct 23 03:13:14 2014 +0200

    Check to see if the user has explicitly disabled anti-aliasing

diff --git a/src/macfont.m b/src/macfont.m
index 69bde9f..ee86d9b 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2768,7 +2768,8 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
       CGFloat advance_delta = 0;
       int y_draw = -s->ybase;
       int no_antialias_p =
-	(macfont_info->antialias == MACFONT_ANTIALIAS_OFF
+	(NILP (ns_antialias_text)
+         || macfont_info->antialias == MACFONT_ANTIALIAS_OFF
 	 || (macfont_info->antialias == MACFONT_ANTIALIAS_DEFAULT
 	     && font_size <= macfont_antialias_threshold));

In GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
 of 2014-10-25 on Erik
Windowing system distributor `Apple', version 10.3.1343
Configured using:
 `configure --prefix=/usr/local/Cellar/emacs/24.4
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/24.4/share/info/emacs --without-dbus
 --without-gnutls --with-ns --disable-ns-self-contained'

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LC_COLLATE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  global-git-gutter+-mode: t
  git-gutter+-mode: t
  shell-dirtrack-mode: t
  projectile-global-mode: t
  projectile-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-global-mode: t
  smartparens-mode: t
  global-auto-complete-mode: t
  auto-complete-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
t t @ g r u n g e - n o u v e a u . n e t <tab> <backspace> 
<backspace> <backspace> <backspace> <down> I SPC l 
i k e SPC c h e e s e <down> <down> D o SPC y o u SPC 
w a n t SPC t o SPC t o u c h m <backspace> SPC m y 
SPC m o n k e y ? <return> <return> - S c o t t C-c 
C-c s-b <escape> <escape> <escape> b s-z C-x b <tab> 
<tab> m a i l <tab> <return> s-k s-b p e r <escape> 
<escape> <escape> s-p p e r s o n a l <escape> <escape> 
<escape> C-x C-f p e r s o n <tab> <return> <down> 
<down> <down> <down> <down> s-v C-a <up> <tab> <C-right> 
<C-right> <C-right> <C-right> <C-right> <C-right> <C-right> 
<C-backspace> <C-backspace> <C-backspace> s c o t t 
@ d i r e c t <C-backspace> d i r e c t e d e d g e 
. c o m C-x C-s C-a <S-down> <S-up> <S-down> s-x <up> 
<up> <up> <up> s-v C-x C-s <down> <down> <down> <down> 
<down> <backspace> C-x C-s s-a <escape> x e v a l <tab> 
b u f <tab> <return> <escape> x m a i l <return> s 
c o t t @ g r u n g e - n o u v e a u n <backspace> 
. n e t <tab> <backspace> <backspace> <backspace> <backspace> 
<down> t e s t <down> C-a <down> t e s t C-c C-c s-k 
s-k <escape> x e m <backspace> <backspace> b u g <tab> 
<tab> <C-backspace> <C-backspace> e m a c <tab> b u 
<tab> <C-backspace> <C-backspace> r e p o <tab> r t 
<tab> <return>

Recent messages:
Sending...
Opening TLS connection to `secure.emailsrvr.com'...
Opening TLS connection with `gnutls-cli --insecure -p 465 secure.emailsrvr.com'...failed
Opening TLS connection with `gnutls-cli --insecure -p 465 secure.emailsrvr.com --protocols ssl3'...failed
Opening TLS connection with `openssl s_client -connect secure.emailsrvr.com:465 -no_ssl2 -ign_eof'...done
Opening TLS connection to `secure.emailsrvr.com'...done
Sending email 
Sending email done
Sending...done
Making completion list... [2 times]

Load-path shadows:
/Users/scott/.emacs.d/.cask/24.4.1/elpa/magit-90141016/magit hides /usr/local/share/emacs/site-lisp/magit

Features:
(shadow sort emacsbug network-stream starttls tls mail-extr smtpmail
sendmail vc-git flymake git-gutter+ git-commit-mode server log-edit
easy-mmode message rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log tramp tramp-compat auth-source
eieio byte-opt bytecomp byte-compile cconv eieio-core gnus-util mm-util
mail-prsvr password-cache tramp-loaddefs trampver shell pcomplete
format-spec projectile ibuf-ext ibuffer pkg-info find-func grep compile
comint ansi-color ring grizzl grizzl-read grizzl-core
highlight-indentation yasnippet help-mode cl smartparens-ruby
smartparens-config smartparens thingatpt rvm auto-complete-config
auto-complete popup maxframe edmacro kmacro kde-emacs kde-emacs-bindings
dirvars kde-emacs-utils imenu klaralv kdab-qstring kde-emacs-general
sourcepair kde-emacs-core kde-emacs-compat kde-emacs-vars cc-mode
cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs pallet advice cask help-fns cl-macs gv cask-bootstrap
package-build json lisp-mnt shut-up epl git commander cl-loaddefs cl-lib
f dash s ucs-normalize package epg-config time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
cocoa ns multi-tty emacs)

Memory information:
((conses 16 365198 51386)
 (symbols 48 33333 33)
 (miscs 40 62 418)
 (strings 32 59615 23186)
 (string-bytes 1 1730922)
 (vectors 16 49616)
 (vector-slots 8 923815 19812)
 (floats 8 427 674)
 (intervals 56 762 15)
 (buffers 960 15))