MS Windows Emacs fixed-pitch got no anti-aliasing

I don’t know how it is on other operating systems, but on MS Windows 7, GNU Emacs 24.3.1 (latest version as of this writing) seems to have a bug that any text with fixed-pitch face is not anti-aliased, and when you select part of such text using the mouse, it shows some glitches in rendering.

But there is a fix.

1 Background

fixed-pitch is a name for face.

M-x describe-face RET fixed-pitch

fixed-pitch is also another name for monospace.

Vanilla Emacs shows text in monospace font, and I think the way it works is that the default face has a monospace font as its family attribute or its font attribute.

M-x describe-face RET default

Then when you want proportional font (called variable-pitch in Emacs speak) in a buffer, you enable variable-pitch-mode in that buffer. Then sometimes you want some parts of that buffer to be displayed in monospace, but not the whole buffer. That’s when you use the fixed-pitch face, by adding fixed-pitch to the inherit property of the face that is being used at those parts.

2 Fix 1

(if (eq system-type 'windows-nt)
    (set-face-attribute 'fixed-pitch nil :family
                        "Courier New"))

3 How fix 1 works

I saw

M-x describe-face RET fixed-pitch

and

M-x describe-face RET default

and compared. fixed-pitch had “Monospace” as family attribute, while default had “Courier New”, and then there were other differences. So I just had to copy all those attributes from default over to fixed-pitch, but I don’t know how Emacs font system works, so I decided to copy just one least scary looking and the most important-looking thing: the family attribute, and that seems to work.

4 Fix 2

Some people prefer other fonts than “Courier New”. They should use this Fix 2.

(if (eq system-type 'windows-nt)
    (set-face-attribute 'fixed-pitch nil :family
                        (face-attribute 'default :family)))

I find it odd that set-face-attribute and face-attribute take arguments in different order.

This entry was posted in Emacs and tagged , , , . Bookmark the permalink.

One Response to MS Windows Emacs fixed-pitch got no anti-aliasing

  1. Pingback: monospace font in tables and source code blocks in org-mode, proportional font in other parts | Yoo Box

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s