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、ドキュメントを読んで動作することが予想されていたため適用されます。

関連情報