Emacs 固定大小像素字体的字体大小(以像素为单位)?
我在编写代码时在 emacs 中使用固定大小的像素字体。在 emacs 中指定字体大小时,它需要以磅为单位的字体大小。由于我在几台具有不同显示器尺寸的不同计算机上使用 .emacs 文件,这意味着当字体在一台计算机上看起来很棒时,它在另一台计算机上通常会模糊或太大。我已经在 .emacs 中通过检查实际显示器大小(以像素为单位)来解决这个问题,但正确的方法是指定以像素为单位的字体大小,或者使用一个小的 lisp 存根来根据给定的值计算正确的点大小像素大小,假设 dpi 值可从 emacs 中获得。
建议? 9 月 26 日更新
我使用的是 Linux(Ubuntu 10.04,x64)。
我当前的黑客解决方案是:
(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"))))))
只有高度属性与我之前在 .emacs 文件中设置的位置不同。在另一台机器上,我必须将其设置为 90 才能获得“像素完美”。我尝试输入:
(set-frame-font "proggycleanttsz")
,但这不起作用。当我回顾我之前的尝试时,我发现我现在使用的是 truetype 版本的字体,这意味着问题的主题并不完全正确,但无论如何,它看起来非常像像素字体,但仅限于尺寸准确。不确定 truetype 是如何工作的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用了
一段时间了。在 Linux 上与 Emacs 25 配合良好。这种字体名称样式的文档适用于 MS Windows,但我已经在 Linux 上使用它很多年了。
I've been using
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.
正如您问题的评论中提到的,如果您使用的是 Linux,XFT 就是您想要的,因此在 .emacs 中使用类似
(set-frame-font "Terminus-8")
的内容就可以了出色地。Borbus 提到 ~/.Xresources - 我认为你可以在 ~/.Xdefaults 中使用
Emacs*font: Font-name
。我快速浏览了您的个人资料,试图确定您使用的操作系统,但我无法猜测。更多信息可能会更好(操作系统、emacs 版本)
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)