简体   繁体   English

emacs 23和字体大小

[英]emacs 23 and font size

I am using emacs 23 on my Ubuntu netbook edition. 我在Ubuntu上网本版本上使用emacs 23。 Every app, automatically goes to fullscreen (so does my emacs). 每个应用程序都会自动进入全屏模式(我的emacs也是如此)。 But depending on the font size (:height), I get a smaller working window. 但是根据字体大小(:height),我会得到一个较小的工作窗口。 If I go to :height normal I get the full area but the fonts are HUGE! 如果我去:height normal我可以得到整个区域,但是字体很大!

any ideas? 有任何想法吗?

Your window manager is broken. 您的窗口管理器已损坏。 emacs resizes itself when you change the font size (this happens during startup). 更改字体大小时,emacs会自动调整大小(这种情况在启动时发生)。 Your window manager should tell emacs that emacs was resized by the window manager, at which point everything will work normally. 您的窗口管理器应告诉emacs,窗口管理器已调整了emacs的大小,此时一切正常。

Anyway, start emacs as "emacs --daemon" and connect with "emacsclient -c" and you should not notice this problem. 无论如何,以“ emacs --daemon”启动emacs并与“ emacsclient -c”连接,您应该不会注意到此问题。

OK, so actually I added this to my initfile: 好的,所以实际上我将此添加到了我的initfile中:

(add-hook 'after-make-frame-functions
      (lambda (frame)
        (progn
          (add-to-list 'default-frame-alist
               (cons 'height
                 (/ (x-display-pixel-height)
                    (frame-char-height)))
               (add-to-list 'default-frame-alist
                    (cons 'width
                          (/ (x-display-pixel-width)
                         (frame-char-width))))))))

and now the window is the same size as the full screen. 现在该窗口的大小与全屏相同。 If you are setting your fonts inside of the after-make-frame-functions hook then it is important that this comes first in your initfile, (I think because hooks are run in reverse order) but if you're just setting the fonts then this should work OK anywhere. 如果要在after-make-frame-functions挂钩中设置字体,那么重要的是,它首先出现在您的initfile中(我认为是因为挂钩以相反的顺序运行),但是如果您只是设置字体,则这应该在任何地方都可以。

Of course for maximum safety you could put this and your 'set fonts' stuff into the same defun, with this coming after the fonts have been set. 当然,为了获得最大的安全性,您可以将此字体和“设置字体”的内容放到相同的定义中,并在设置字体之后进行。

EDIT: This is a slightly more forceful way to do it, in case that doesn't work. 编辑:这是一种稍微更有力的方法,以防万一。

This gives me some issues though, really you would probably want to subtract the height of the top panel from the height you're setting it to. 不过,这给我带来了一些问题,实际上,您可能要从将其设置为的高度中减去顶部面板的高度。

(add-hook 'after-make-frame-functions
  (lambda (frame)
    (progn
      (set-frame-height frame
            (/ (x-display-pixel-height)
               (frame-char-height)))
      (set-frame-width frame
            (/ (x-display-pixel-width)
               (frame-char-width))))))

The font size issue can be fixed simply by selecting a different size font as the default font (Options->Set Default Font), then saving the options (Options->Save Options). 可以通过选择其他大小的字体作为默认字体(选项->设置默认字体),然后保存选项(选项->保存选项)来解决字体大小问题。 Emacs seems to have issues with font point sizes matching system sizes (there's discussion about X standard DPIs versus GTK standard DPIs), but if you select one that works it will stay the same. Emacs似乎存在与系统大小匹配的字体点大小问题(有关X标准DPI与GTK标准DPI的讨论),但是如果选择一个有效的字体,它将保持不变。

To get the window to come up maximized correctly, I've found there's an issue with the frame alist not accounting for the minibuffer correctly as well as the different font sizes not triggering the frame to resize correctly. 为了使窗口正确最大化,我发现框架列表存在一个问题,即不能正确考虑minibuffer以及不同的字体大小无法触发框架正确调整大小。 If you set the initial-frame-alist to include (fullscreen . fullwidth) and (minibuffer-lines . 1) it accounts for the minibuffer size correctly and comes up with the correct width, forcing an effect as if you resized the window by hand to the maximum visible area (not quite the same as maximizing). 如果将初始帧警报设置为包括(fullscreen。fullwidth)和(minibuffer-lines。1),它将正确考虑minibuffer的大小并提供正确的宽度,从而产生一种效果,就像您手动调整窗口大小一样到最大可见区域(与最大化不完全相同)。 You can set these via Options->Customize Emacs->Settings Matching Regexp... Then typing initial-frame-alist. 您可以通过“选项”->“自定义Emacs”->“设置匹配正则表达式”进行设置,然后键入initial-frame-alist。 Set two new parameters and values, "minibuffer-lines" to "1" and "fullscreen" to "fullwidth". 设置两个新的参数和值,“ minibuffer-lines”设置为“ 1”,“ fullscreen”设置为“ fullwidth”。

Removing the "minibuffer-lines" parameter will give you a full screen width window that's the wrong height, and removing the "fullscreen" parameter means nothing resizes correctly. 删除“ minibuffer-lines”参数将为您提供一个错误高度的全屏宽度窗口,而删除“ fullscreen”参数则意味着没有正确调整大小。 Attempting to set "fullscreen" to "fullscreen" gives the same issue as setting nothing, and "fullscreen" to "fullheight" gives blank space only across the height and not the width when a smaller font size is used. 尝试将“全屏”设置为“全屏”会产生与不设置任何内容相同的问题,而将“全屏”设置为“ fullheight”会在使用较小字体时仅在整个高度(而不是宽度)上提供空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM