Turn off anti-alias for font in Emacs 23 - emacs

How to I disable anti-aliasing for fonts in the Windows version of Emacs 23?
Thanks.

You can specify the antialias=none option for your fonts, as stated in GNU Emacs Manual

As I couldn't find a satisfactory answer to this one for a long time, I thought it wouldn't hurt to add this link to this discussion, as the above does not generally work on Linux:
http://keyboardconnoisseur.blogspot.com/2011/04/turning-off-antialiasing-for-specific.html
The problem is that under Linux, emacs doesn't seem to be doing a lot of font handling at all, and you need to disable the antialiasing elsewhere.

If others were searching for how to disable anti-aliasing in OS X, you can run
defaults write org.gnu.Emacs AppleAntiAliasingThreshold 999

Never have run Mac OS X, so usable only for Linux + Windows:
(defvar my-preferred-font
(cond
((eq window-system 'x)
"-misc-fixed-medium-r-normal--14-*-*-*-c-*-iso10646-1")
((eq window-system 'w32)
"Courier New-10:antialias=none")
(t nil)))
(when my-preferred-font
(set-frame-font my-preferred-font)
(set-fontset-font "fontset-default" 'latin my-preferred-font)
(set-fontset-font "fontset-default" 'phonetic my-preferred-font)
(set-fontset-font "fontset-default" 'cyrillic my-preferred-font)
(set-fontset-font "fontset-default" 'greek my-preferred-font))
Whose uses only ASCII it is enough to follow official suggestion:
(add-to-list 'default-frame-alist '(font . "Courier New-10:antialias=none"))
I work with cyrillic, greek and IPA texts so need to define defaults for fontsets...

Related

Org LaTeX preview is fuzzy on retina displays

I have been using Emacs 24.4 for all my math/scientific notes. org-latex-preview is fantastic for this! But recently, I upgraded to a macbook pro with retina display, and I now see that all my equations in org-mode are... fuzzy. Is there a setting I can change to up-res these?
Here is a screenshot:
Thanks!
A couple of years back, I decided to fix this and wrote a patch to add dvisvgm as a render option for latex previews. While this worked great, I never submitted it (no time or knowledge on how to officially patch org).
Today, I was thrilled to discover that org-mode v9.0.6, now has this feature!
To activate, first check that you have dvisvgm on your system. Then update org-mode and add the following line to your init.el file:
(setq org-latex-create-formula-image-program 'dvisvgm)
And presto!
I found a solution that works a little more generally for all inline images. First make sure any generated images are created with a scale factor of 2. For example for LaTeX code blocks and inline LaTeX snippets this works by
(plist-put org-format-latex-options :scale 2)
Then you make org scale all inlined images back.
For LaTeX code blocks we can advise org--create-inline-image like so:
(defun my/image-scale-advice (image)
(let* ((factor (image-property image :scale))
(new-factor (if factor
(/ factor 2.0)
0.5)))
(image--set-property image :scale new-factor)
image))
(advice-add 'org--create-inline-image :filter-return #'my/image-scale-advice)
This divides any already existing scaling-factor by 2 or sets a scaling factor of 0.5 if none is present.
For inline LaTeX snippets we can advise org--make-preview-overlay like so:
(defun my/overlay-scale-advice (beg end image &optional imagetype)
(mapc (lambda (ov) (if (equal (overlay-get ov 'org-overlay-type) 'org-latex-overlay)
(overlay-put ov
'display
(list 'image :type (or (intern imagetype) 'png) :file image :ascent 'center :scale 0.5))))
(overlays-at beg)))
(advice-add 'org--make-preview-overlay :after #'my/overlay-scale-advice)
This should result in much crispier inline images on Retina displays.
By default orgmode latex preview do not support retina, so on mac with retina screen, latex preview will be fuzzy.
However, we can hack org.el to achieve the function. Just follow steps below:
get the proper version of emacs
To instead use the Yamamoto Mitsuharu version of Emacs 25.1 (with more mac-specific features):
brew tap railwaycat/emacsmacport
brew install emacs-mac
and finally link it to your Applications folder:
brew linkapps emacs-mac
this version emacs will support retina image display.
change org-format-latex-options
change scale from 1.0 to 2.0, to generate 2x size image.
delete org.elc
add function to org.el
(defun galaxy-compose-image-filename-2x(image-file-name)
(concat (file-name-directory image-file-name) (file-name-base image-file-name) "#2x." (file-name-extension image-file-name)))
and eval the function.
modify function org-format-latex
change fragment:
(unless (file-exists-p movefile)
(org-create-formula-image value movefile options forbuffer processing-type)
to
(unless (file-exists-p movefile)
(org-create-formula-image value movefile options forbuffer processing-type)
(setq filename-2x (galaxy-compose-image-filename-2x movefile))
(rename-file movefile filename-2x)
(call-process-shell-command "convert" nil nil nil nil (concat "\"" filename-2x "\" -scale \"50%\" -quality \"100%\"" ) (concat "\"" movefile "\"" )))
and eval the function.
Now, you can preview latex with 2x size image for mac retina screen.
I have tried the
emacs-mac-port
If I create 2 files foo.png foo#2x.png on the same dir ,this will work.

Bold attribute doesn't work

I'm trying to make font in Emacs a little bolder. I use Inconsolata and here is a snippet from my .emacs:
(when window-system
(set-face-attribute 'default
nil
:font "Inconsolata"
:height 120
:weight 'bold) ; <- this line does not affect rendering
(require 'color-theme-solarized)
(color-theme-solarized-dark)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
I know that Inconsolata can be rendered bold, but for some reason Emacs always renders it with normal weight. Maybe I should enable something before trying to change font?
Unfortunately, original Inconsolata does not have bold variant, applications emulate Inconsolata Bold by increasing character width. This is why one can use 'bold' variant of Inconsolata in some of them.
According to this Wikipedia article:
when Inconsolata was added to Google Fonts, it was fully hinted and a bold variant was added
So it is important which version of the font one uses. I've removed original Inconsolata and installed Google Fonts this way (Arch Linux):
# yaourt -S ttf-google-fonts-git
If you encounter such a problem, try searching for a similar package for your Linux distribution.
(when window-system
(set-face-attribute 'default
nil
:font "Inconsolata"
:height 120
:bold t)
(require 'color-theme-solarized)
(color-theme-solarized-dark)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
Old thread, but I ended up here trying to find update of what I'm
doing now (haven't found yet)... but this simple trick may be
useful (year 2019 linux X, emacs 26.1 Gtk+3, and xft fonts):
emacs -xrm Xft.embolden:true -fn Inconsolata-14
This makes all variabts (regular, italics, bold, bolditalics)
(even) bolder when such variants exist. -fn Inconsolate-15:weight=bold affected only regular for me (without that -xrm ... option).

What causes this graphical error in emacs with linum-mode on OS X?

I get this graphical error with linum-mode in my Emacs. I tried upgrading from 23 to 24 (via git) and I've tried both with various supplied binaries online and with my home-compiled version. What I'm really interested in is where to start diagnosing the problem.
The problem goes away if I scroll the torn line numbers off screen and back in.
I have experienced the same problem and spent quite some time trying to resolve it. The graphical error is a result of a clash between linum-mode and how the fringe is rendered. Unfortunately, I was unable to resolve the problem in linum.el, and the fringe display code is part of the C-source.
It can still be done! The easiest way to fix it is to just turn off the fringe.
M-x fringe-mode RET none RET
To make the fringe permanently stay off, I recommend customizing the settings with M-x customize-group RET fringe because some compiled versions of Emacs for Mac OS X have their own fringe settings that can override parts of your .emacs file.
I don't really need those line wrap indicators, so not having a fringe doesn't bother me. However, I did miss a slight separation between the line numbers and the buffer text. I followed the advice of a post on the Emacs Wiki to get that spacing back. In version 0.9x of linum, change line 160 from
(setq width (max width (length str)))
to
(setq width (max width (+ (length str) 1)))
The inspiration for this change is here: http://www.emacswiki.org/emacs/LineNumbers
There are arguments at the source link to set the linum-format variable instead of modifying linum.el. While I understand where they are coming from, most color-themes these days would color the extra space and not provide what I am looking for (a separation of about a space that is the background color). If you do edit linum.el, make sure to run
M-x emacs-lisp-byte-compile-and-load
to make the changes persistent. You can see the result of this by looking at the space before the cursor in the picture found here: http://i.stack.imgur.com/TxyMr.png (I don't have enough reputation to embed images).
No more graphical artifacts!
I had the same problem and I figured out a solution and while it's not the prettiest, due to an extra space to the left of the line number, it's much more elegant than changing the linum.el. Here is the pertinent part of my ~/.emacs:
;; Linum mode
(global-linum-mode t)
;; Offset the number by two spaces to work around some weird fringe glitch
(setq linum-format " %d ")
This removes the fringe overlay issue and does not have any other impact other than offsetting the line number.
to make a separation between the line numbers and the buffer text, the follow change will be better:
In version 0.9x of linum, change line 150 from
(concat "%" (number-to-string w) "d")))))
to
(concat "%" (number-to-string w) "d ")))))
This make the separation have the same background color with line numbers'.
This is how I have it setup in my .emacs and I don't have the problem, although I also don't use emacs with gtk or any other gui.
(linum-mode +1)
(setq linum-format "%d ")
You might want to hack around with (setq linum-format) to see if you can get good results. Also don't forget to browse emacswiki on linum.
The problem was still here on emacs 24.4, OS X 10.10.1.
The solution I worked out:
after loading the theme of your choice:
(load-theme 'whatever)
(set-face-attribute 'fringe nil :background (face-background 'default))

How to check which Emacs I am using?

I have two Emacs (Aquamacs and text-based Emacs) on my Mac.
In my .emacs file, I can check if I'm using Aquamacs with ...
(boundp 'aquamacs-version)
How can I check if I'm using text based emacs?
EDIT
Jürgen Hötzel's answer works, but for text based emacs, using
(unless (null window-system) ...)
is better as (window-system) is not defined.
M-x emacs-version
ad some more characters here......
Sorry, from .emacs, just call
(emacs-version)
I know this question was answered a long time ago, but I found another answer by typing emacs --help. This gives a list of options in which you can find emacs --version.
In my case, emacs --version prints: GNU Emacs 24.3.1.
I have only tested this solution on Linux with my current version of Emacs. I do not know if the same solution applies to Windows, or to older versions of Emacs, but in theory it should.
(if (window-system)
"window-based"
"text-based")
Or, you could use this:
(if (or (eq window-system 'ns)
(eq window-system 'mac))
(message "hello, world!"))
It will only print "hello, world!" when you run a graphical Emacs in OS X.
Errr... (not (boundp 'aquamacs-version)), perhaps?

How to setup custom font in emacs?

I would like to use Proggy font for my programming in Emacs.
How can I set it up?
Please note it is a bitmap font.
you can use:
(set-default-font "ProggyClean")
which is deprecated and should be
(set-frame-font "ProggyClean")
from Emacs 23.1 on in you .emacs or you can do M-x: customize-face: default and set ProggyClean as "Font Family".
Just sticking set-default-font in your .emacs won't work across multiple frames - each new frame will go back to the old default. Customize does work with multiple frames, but I've never managed to get it to work properly across different platforms (and different platforms have different font settings even for the same font).
So! This is what I've got in my .emacs. It works in linux, win32 and cygwin, and works with multiple frames (and hence emacs client).
(defconst win32p (eq system-type 'windows-nt) "Are we running on a Windows system?")
(defconst cygwinp (eq system-type 'cygwin) "Are we running on Cygwin?")
(defconst linuxp (or (eq system-type 'gnu/linux) (eq system-type 'linux)) "Are we running on Linux?")
;;font setups
(defvar vsc-little-font "" "*My lovely little font")
(when linuxp
(setq vsc-little-font "ProggyTinyTT-8"))
(when cygwinp
(setq vsc-little-font "ProggyTinyTT-16"))
(when win32p
(setq vsc-little-font "-outline-ProggyTinyTT-normal-r-normal-normal-16-120-96-96-c-*-iso8859-1"))
(add-to-list 'default-frame-alist (cons 'font vsc-little-font))
(add-to-list 'initial-frame-alist (cons 'font vsc-little-font))