Questions tagged [faces]

A 'face' in Emacs is the visual presentation of text using fonts and highlighting. A default face, for example, specifies both the font and the foreground and background colors.

Adapted from the Emacs manual:

Emacs can display text in several different styles, called "faces". Each face can specify various "face attributes", such as the font, height, weight, slant, foreground and background color, and underlining or overlining. Most major modes assign faces to the text automatically, via Font Lock mode. […]

To see what faces are currently defined, and what they look like, type M-x list-faces-display. With a prefix argument, this prompts for a regular expression, and displays only faces with names matching that regular expression […].

It's possible for a given face to look different in different frames. For instance, some text terminals do not support all face attributes, particularly font, height, and width, and some support a limited range of colors. In addition, most Emacs faces are defined so that their attributes are different on light and dark frame backgrounds, for reasons of legibility. By default, Emacs automatically chooses which set of face attributes to display on each frame, based on the frame's current background color. However, you can override this by giving the variable frame-background-mode a non-nil value. A value of dark makes Emacs treat all frames as if they have a dark background, whereas a value of light makes it treat all frames as if they have a light background.

You can customize a face to alter its attributes, and save those customizations for future Emacs sessions. […]

The default face is the default for displaying text, and all of its attributes are specified. Its background color is also used as the frame's background color. […]

Another special face is the cursor face. On graphical displays, the background color of this face is used to draw the text cursor. None of the other attributes of this face have any effect; the foreground color for text under the cursor is taken from the background color of the underlying text. On text terminals, the appearance of the text cursor is determined by the terminal, not by the cursor face.

You can also use X resources to specify attributes of any particular face. […]

Emacs can display variable-width fonts, but some Emacs commands, particularly indentation commands, do not account for variable character display widths. Therefore, we recommend not using variable-width fonts for most faces, particularly those assigned by Font Lock mode.

414 questions
19
votes
3 answers

Quickly Adjusting Text to DPI Changes

My laptop has a 4K screen therefore a very high DPI, much higher than my external monitors. So when I switch from using external monitors to the builtin laptop screen I would like to quickly scale the text and, if possible, all the GUI widgets in…
Nordlöw
  • 497
  • 3
  • 12
12
votes
1 answer

How can I override a pre-defined face for light and dark backgrounds?

I would like to use set-face-attribute to pick one of two colors for the foreground depending on whether the background of the current theme is light or dark. The expected behavior is that the foreground changes automatically if I switch from a…
Kaushal Modi
  • 25,651
  • 4
  • 80
  • 183
10
votes
2 answers

Changing faces one at a time, outside customize

Is there a way to change faces one at a time, outside of customize? In my custom-file I see a big blob of face customizations that starts with: (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it…
izkon
  • 1,878
  • 11
  • 24
10
votes
1 answer

Why does the font height change when bold?

It's so annoying... When any text on a line has its face changed so that the text is bold, the height of the line increases by (I assume) a single pixel. It's best shown with an image: Why is this? How do I prevent it? As requested, info on the…
edam
  • 311
  • 1
  • 6
9
votes
1 answer

How to get/read face attributes?

The following Emacs Lisp you can set the background color of face whitespace-trailing: (set-face-attribute 'whitespace-trailing nil :background "#ff0000" :foreground nil)) How can a face attribute be read back? Asking since I'd like to temporarily…
ideasman42
  • 8,786
  • 1
  • 32
  • 114
8
votes
2 answers

Unset inherited face attribute

Suppose I want the face helm-match to have an unset foreground. Unfortunately, helm-match inherits from match so, if I try to unset the foreground normally: (set-face-foreground 'helm-match nil) The inherited foreground becomes active. I'd rather…
PythonNut
  • 10,363
  • 2
  • 30
  • 76
7
votes
3 answers

Change size of wavy underlines for HiDPI displays

I'm running emacs on Linux with HiDPI display and all X environment I successfully tuned to support it, but in emacs wavy underlines are still looking extremely thin (relatively to font size). I've checked face settings, but it allows only to…
Oleksandr
  • 171
  • 1
7
votes
2 answers

How to make the region face take priority over the `show-paren-mode` face?

I'm using show-paren-mode with expression highlighting, changing the background face to just a shade lighter than the default background. I like it a lot. The problem is that when I have a mark, the background face from the paren expression is…
levand
  • 275
  • 1
  • 6
5
votes
3 answers

Getting `:distant-foreground` face attribute to work

Emacs's faces let you set :distant-foreground, which according to the docs, "is like :foreground but the color is only used as a foreground when the background color is near to the foreground that would have been used." I'm not really sure how…
asmeurer
  • 1,572
  • 12
  • 32
5
votes
1 answer

Use one face's attributes in another

What is the idiomatic way to make one face the same as another? Basically, I would like vertical-border to be exactly the same as default. Preferably, if default changes, so does vertical-border. I'm not sure that creating a face alias is the right…
Tianxiang Xiong
  • 3,878
  • 18
  • 28
3
votes
2 answers

How to delete a face

I was experimenting with face definitions and created a number of "test" faces that were meant to be temporary. At the end of the experiments, I wanted to clean up after myself, so I attempted (unintern FACE), but the faces remained on the return…
user1404316
  • 789
  • 5
  • 12
3
votes
1 answer

Override syntax highlighting with color of hex code.

From EmacsWiki: Hex Colour, it is explained how to get in-line syntax highlighting of hex code, and other formats of color. For instance with (defvar hexcolour-keywords '(("#[abcdef[:digit:]]\\{6\\}" (0 (put-text-property (match-beginning…
3
votes
2 answers

Why does the background of the text not correspond to the background color of the frame?

If you look closely there is a background on the text that is different than the frame background. Does anybody know why this happens? According to the manual (if I read it correctly) it says that they should be the same. I've tried changing the…
Xack
  • 31
  • 4
3
votes
2 answers

Get foreground color of face at point

I am writing a function to get the foreground color of the face at point and am thinking that Emacs may already provide a better method than the one I'm composing? I am going to be using this function about 50 times every redisplay (i.e., once for…
lawlist
  • 19,106
  • 5
  • 38
  • 120
2
votes
1 answer

Is there a way to watch/debug changes of face properties?

In my config file, I set properties for some faces used by my setup of Doom Emacs. These properties are promptly ignored when Emacs is loaded, and what I see is how things were before. I'm guessing that Doom overwrites my changes—however, seeing as…
aaa
  • 436
  • 3
  • 9
1
2 3