emacs-devel
[Top][All Lists]
Advanced

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

Re: Variable pitch text filling


From: Lars Ingebrigtsen
Subject: Re: Variable pitch text filling
Date: Sat, 27 Nov 2021 15:28:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> It is trivial to add some pixels to the width of a glyph we produce
> for a character: it just involves enlarging the it->pixel_width and/or
> the glyph->pixel_width when we produce the glyph for that character.

Right.  This reminds me -- perhaps we'd want to distribute the extra
space both before and after the glyph, to centre it within its allotted
width?  I haven't looked at the code yet, but I assume that's not going
to make this significantly more difficult.

> The problem is how to determine which characters to "widen", and how
> to calculate the number of the "widening" pixels.  The answer could be
> different for each kind of situations you mention.

Yup.

> What would be the exact meaning of "char-spacing 1.0" here?  IOW, how
> would we compute the number of pixels to add to each glyph's width in
> this case? what is a "normal character" for this purpose?

It's the same as for all these width specs -- it's FRAME_COLUMN_WIDTH.
The lengthy commentary before calc_pixel_width_or_height has all the
grisly details, and I see that I misremembered the specs when doing the
documentation.  Floating point numbers aren't special:

   SPEC ::=
     NUM      - a (fractional) multiple of the default font width/height
     (NUM)    - specifies exactly NUM pixels

So both 1 and 1.0 is one "normal character width", and it's (10)
that's the pixel spec.  (But I did it correctly in the code. 😀)

>> while inter-character justification would use 'char-spacing 1 to add an
>> extra pixel after all the chars on the line, for instance. 
>
> With the value 1 computed by Lisp?  Because it cannot be a fixed
> value: it should at least depend on the size of the font, and I think
> it should be possible to add more pixels without making the display
> unpleasant.

Yes, for the justification case, the algo would have to do all the
computation, and I'm guessing getting at a pleasing result will depend
on a lot of things.  For instance, if the display is low res, we
wouldn't want to do inter-character spacing at all -- unless there
aren't any spaces, and then we'd have to do it after all.  Etc.  I think
we'll just have to implement it, see what it looks like and tweak it
until it's OK.

> Also, in the case of CJK fonts, we should be able to do that without
> any text property put on the text, so we need some (optional)
> variable as well.

Yup.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

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