tags:

views:

66

answers:

1

I'm using fixed size pixel fonts in emacs when writing code. When specifying font sizes in emacs, it wants the font size in points. Since I use my .emacs file on several different machines with varying monitor sizes, it means that when the font looks great on one machine, it's typically blurry or too large on another. I've worked around this in my .emacs by checking the actual monitor size in pixels, but the right way to do this would be to specify the fontsize in pixels, or have a small lisp stub that calculates the proper point size from a given pixel size, assuming the dpi values are available from within emacs.

Suggestions? Update Sep 26

I'm on Linux (Ubuntu 10.04, x64).

My current hackish solution is:

(if (>= (x-display-pixel-height) 1200)
(custom-set-faces
 '(default ((t (:stipple nil :background "black" :foreground "cornsilk" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :family "proggycleanttsz"))))))

Only the height attribute is different from where I already set it earlier in the .emacs file. On another machine I have to set it to 90 to get it "pixel perfect". I tried putting in a:

(set-frame-font "proggycleanttsz")

instead, but that isn't working. When I look back on my earlier attempts, I see that I now use the truetype version of the font, which means that the subject of the question is not entirely right, but anyway, it looks very much like pixel font, but only at the exact right size. Not sure how this works with truetype.

A: 

As mentioned in the comments to your question, if you are on linux, XFT is what you want, so use something like (set-frame-font "Terminus-8") in your .emacs would work well.

Borbus mentions ~/.Xresources - I think you can use Emacs*font: Font-name in ~/.Xdefaults.

I had a quick look on your profile to try and determine the operating system you use, but I couldn't guess. Some more information might be good (OS, emacs version)

davidb
The OS is Emacs ;)
aaronasterling
You're just tempting some vi/vim user to come in with the ubiquitous "... lacking a decent text editor" statement :P
davidb
I'm on Linux (Ubuntu 10.04, x64). My current hackish solution is like this:
Marius Kjeldahl
Sorry, see answers in the original question.
Marius Kjeldahl