开发者

Emacs font sizes in pixels for fixed size pixel fonts?

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.


I've been using

(set-frame-font "font-name:pixelsize=16")

for a while now. Works fine with Emacs 25 on Linux. This style of font name is documented for MS Windows, but I've been using it for years with Linux.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜