Function: char-width

char-width is a function defined in character.c.

Signature

(char-width CHAR)

Documentation

Return width of CHAR in columns when displayed in the current buffer.

The width of CHAR is measured by how many columns it will occupy on the screen. This is based on data in char-width-table, and ignores the actual metrics of the character's glyph as determined by its font. If the display table in effect replaces CHAR on display with something else, the function returns the width of the replacement. Tab is taken to occupy tab-width columns.

View in manual

Probably introduced at or before Emacs version 20.1.

Source Code

// Defined in /usr/src/emacs/src/character.c
{
  int c;
  ptrdiff_t width;

  CHECK_CHARACTER (ch);
  c = XFIXNUM (ch);
  width = char_width (c, buffer_display_table ());
  return make_fixnum (width);
}