0

Is it possible in Emacs to change the font size of a single character or region, without affecting the whole Emacs window?

  • 1
    In Elisp programs (add-face-text-property (region-beginning) (region-end) '(:height 200)) does the trick. Replace 200 with the number of your choice. This only works for buffers without font-lock. If font-lock is active you need to add the :size face attribute via font-lock-add-keywords. – Tobias Apr 15 at 12:44
  • @tobias: Please consider posting your comment as an answer. Thx. – Drew Apr 15 at 14:08
  • @Drew Hi, I was not sure whether the OP wanted an Elisp solution or an interactive one. But, you are right. If that is not what the OP wants one can just add another answer or extent that one. – Tobias Apr 15 at 14:11
0

In Elisp programs the following form does the trick for the text in the current region.

 (add-face-text-property (region-beginning) (region-end) '(:height 200))

Replace 200 with the number of your choice.

This only works for buffers without font-lock. If font-lock is active you need to add the :size face attribute via font-lock-add-keywords.

  • Evaluating the function above doesn't change anything. How should it be used? – user12021 Apr 15 at 22:22
  • 1
    @amirteymuri Please try it in text-mode or fundamental-mode with an active region. Afterwards switch to your actual target buffer and look what the value of font-lock-mode is. You can do that through direct evaluation by M-: font-lock-mode or by the help C-h v font-lock-mode. As I already stated in the answer that method does not work for buffers with font-lock-mode enabled. If you have such a buffer you must more comprehensively describe what you want to achieve: Do you want to change the font size for some syntactical thing or is it a one-time change of a user-selected region? – Tobias Apr 16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy