emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unfortunate pixel width of one TAB


From: Kenichi Handa
Subject: Re: Unfortunate pixel width of one TAB
Date: Mon, 27 Dec 2004 22:26:36 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3.50 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, Richard Stallman <address@hidden> writes:

>     When using a proportional font the pixel width of one TAB is "tab-width 
>     times average_char_pixel_width".  When editing files which contain tabs 
>     and spaces for indenting, this leads to some bad alignment.

>     If would be nice if the pixel width of one TAB could be set to something 
>     like "tab-width times space_pixel_width".

> Do you mean, the width of a space in the current font?
> That seems like the right behavior for it.

I don't think that solves the problem.  See this example
lines (the first line has three spaces after "wwwww", and
the next line has one TAB after "wwwww", the last line is
just TAB and "a"):
wwwww   a
wwwww   a
        a

Provided that space width is 5 pixels and "w" width is 10
pixels, the "a" of the first line is at 65 pixels from the
left, but the "a" of the second line is at 80 pixels from
the left, and the "a" of third lines is at 40 pixels from
the left.

> This ought to be an easy change, but I would have to spend half an
> hour learning the background knowledge to make it.
> Does anyone know enough about accessing fonts
> to be able to do this change quickly?  Handa, can you do
> it quickly?

> Please respond if you take care of this.

Even if that method doesn't solve the alignment problem, I
agree that current way of tab-width calculation is not
good.

Tab width is calculated as this (x_produce_glyphs):
  int tab_width = it->tab_width * FRAME_COLUMN_WIDTH (it->f);
and, x_new_font sets the column width (i.e. the
canonical character width) of a frame as this:
  FRAME_COLUMN_WIDTH (f) = FONT_WIDTH (FRAME_FONT (f));
and FONT_WIDTH is defined as this:
  #define FONT_WIDTH(f) ((f)->max_bounds.width)

That's why when we change the default font to a proportional
font, the frame gets too wide.

When we change FONT_WIDTH to return the width of space
glyph, the current tab width problem will be solved.  But,
as FRAME_COLUMN_WIDTH is also a base of calculating the
frame width, such a change leads to too narrow frame width.

Perhaps, the following modification will do:

(1) Make FONT_WIDTH return the average width of a font.
This will result in the more adequate frame width.

(2) Make a new macro FONT_SPACE_WIDTH that returns the width
of space glyph of the font of the frame.  We can make a new
member `space_width' in the struct frame and make x_new_font
sets it value.

(3) Calculate tab width based on FONT_SPACE_WIDTH.

This change will result in not perfect but more adequate tab
width for proportional fonts.

But, shouldn't we postpone such a change until the next
release?

---
Ken'ichi HANDA
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]