emacs 中的face-font-rescale-alist 出現意外結果

emacs 中的face-font-rescale-alist 出現意外結果

我正在嘗試使用修改字體的預設大小

(add-to-list 'face-font-rescale-alist (cons "^.*STIXGeneral.*$" 0.95) t)

這應該會將所有名為 STIXGeneral 的字體重新縮放 0.95,因為對我來說該字體比標準字體稍高。的結果值為face-font-rescale-alist

(("-cdac$" . 1.3) ("^.*STIXGeneral.*$" . 0.95))

然而,對於 emacs 24.3(也是 git 版本,也是預發行版 24.3.92.1),添加上述內容的結果.emacs是,除了初始幀之外,每個幀上的字體都是錯誤的。運行 24.3-Q --eval="<expression above>"給出:

(message "%s" (face-all-attributes 'default (selected-frame)))
New frame: ((:family . Geneva) (:foundry . apple) (:width . normal) (:height . 120) (:weight . normal) (:slant . normal) (:underline) (:overline) (:strike-through) (:box) (:inverse-video) (:foreground . Black) (:background . White) (:stipple) (:inherit))
Initial frame: ((:family . Menlo) (:foundry . apple) (:width . normal) (:height . 120) (:weight . normal) (:slant . normal) (:underline) (:overline) (:strike-through) (:box) (:inverse-video) (:foreground . Black) (:background . White) (:stipple) (:inherit))

使用我的常規.emacsgit 版本:

New frame: "((:family . Helvetica) (:foundry . nil) (:width . normal) (:height . 110) (:weight . normal) (:slant . normal) (:underline) (:overline) (:strike-through) (:box) (:inverse-video) (:foreground . #000000) (:background . AliceBlue) (:stipple) (:inherit))"
Initial frame: ((:family . Source Code Pro) (:foundry . nil) (:width . normal) (:height . 110) (:weight . normal) (:slant . normal) (:underline) (:overline) (:strike-through) (:box) (:inverse-video) (:foreground . #000000) (:background . AliceBlue) (:stipple) (:inherit))

第一幀中的臉正是我所期望的。face-font-rescale-alist影響字體的地方font_scorefont.c(關聯)。如果我替換(add-to-list ...)為.git 版本,也會有同樣的問題(setq face-font-rescale-alist nil)

我在這裡做錯了什麼?

答案1

嗯。在startup.el以下程式碼中,檢測 中的更改face-font-rescale-alist,並重置預設字體,同時忽略來自的更改custom-set-face(這就是我使用自訂介面設定字體的方式):

;; startup.el:670
(unless (eq face-font-rescale-alist old-face-font-rescale-alist)
 (set-face-attribute 'default nil :font (font-spec)))

因此,有必要face-font-rescale-alist在嘗試刪除自訂的程式碼之後進行設定。這可以透過將建議附加到 來完成frame-notice-user-settings,該建議在臉部重置程式碼之後運行:

;; in .emacs
(defadvice frame-notice-user-settings (before my:rescale-alist)
  (message "Set face-font-rescale-alist")
  (add-to-list 'face-font-rescale-alist
               (cons (font-spec :family "STIXGeneral") 0.95) t))
(ad-activate 'frame-notice-user-settings)

這適用face-font-rescale-alist於我期望它可以透過閱讀文件來工作。

相關內容