Why is tab unaffected by font whereas space is affected?

Eli Zaretskii eliz at gnu.org
Mon Apr 20 09:36:51 CDT 2020


> From: Kent Karlsson <kent.b.karlsson at bahnhof.se>
> Date: Mon, 20 Apr 2020 02:01:36 +0200
> Cc: Richard Wordingham <richard.wordingham at ntlworld.com>,
>  Unicode <unicode at unicode.org>
> 
> > Emacs uses a fixed number of space_width pixels to display a TAB.
> > Since space_width varies with font, so does the width of a TAB.
> 
> 1) Several text editors, primarily aimed at editing program source code, actually REPLACE
> an input (i.e. from the keyboard, not when read in from a file) tab character with a number of spaces,
> or can be set to do so. That is preferred for programming, with the (max) number of spaces specified
> in a style guide, since people use different editors (with different (default) tab positions), or
> use different tab positions even if using the same text editor. This is especially true for programming
> project involving hundreds of people and/or spanning over many years.

What happens in the text and what is shown on display are different
and separate things in Emacs.  Emacs does have commands to replace
TABs with spaces, and vice versa, but that is unrelated to how a TAB
is displayed.  The replacement commands, btw, make sure the text on
display stays aligned the same, i.e. if you defined a TAB stop every 4
characters, a TAB at the beginning of a line will be replaced by 4
spaces, not 8.

> 2) (Stepping away from source code editing.) What if one can change font or size ”in the middle of lines”.
> With the emacs approach (but not talking about emacs here, but a context where one actually can
> change font or size in the middle of lines), one would then get a harder time getting text to line up
> over several lines by using tabs. That kind of defeats the purpose of tabs. Sure, tables are better, and
> are not bogged with other (similar) problems associated with tabs and setting tab stops. But I see no
> reason to make tabs less useful than they have been. So no, the emacs approach to tabs ”does not fly”.

Yes.  If someone wants the text to align, they will not mix variable
fonts in the same text (and will probably use a fixed-pitch font
anyway).

> 3) Tab stops really used to be settable (either by proprietary escape sequences, or standard ECMA-48
> control sequences) on some terminals. Granted, those terminals also had very fixed size of their
> characters’s glyphs, and at that time one could not set the tab stops ”between” character positions
> (which one can in some modern ”document editors” (trying to use a neutral term here)).

As I explained, the number of space_width units in a tab stop can be
controlled for each buffer of text.  This affects how text is
displayed, not its contents.

> In summary, tab stops are at particular positions in a displayed line of text, and do not depend on
> font changes, or font size changes. In some contexts one can set the tab stops (not just using
> default positions), and they ”stay” over font changes and font size changes, until tab stops are
> (re)set by a tab setting ”command” (or paragraph property, or similar mechanism, depending
> on system).

That would mean, for example, that if you make the font smaller, the
tab stops stay in the same positions, pixel-wise?  isn't that strange?

> I would say that emacs stands alone with its rather strange interpretation. (As far as I know.)

Emacs is unique in many aspects; I guess this is one of them.


More information about the Unicode mailing list