Extra ascent and descent

56 views
Skip to first unread message

Neil Hodgson

unread,
Mar 31, 2009, 10:11:08 PM3/31/09
to scintilla-interest
There have been some requests to be able to increase line spacing
in Scintilla. While this could be achieved in previous versions by
including a style with a larger font, this is indirect and less
controllable.

It is now possible to set an extra amount of ascent and descent for
text. The settings are extra amounts because this works with the user
zooming better than setting the total ascent and descent. While using
negative numbers for these parameters is currently possible, such use
may produce random results and is not supported. The feature is now
available from CVS. The API is:

SCI_SETEXTRAASCENT(int extraAscent)
SCI_GETEXTRAASCENT
SCI_SETEXTRADESCENT(int extraDescent)
SCI_GETEXTRADESCENT
Text is drawn with the base of each character on a 'baseline'. The
height of a line is found from the maximum that any style extends
above the baseline (its 'ascent'), added to the maximum that any style
extends below the baseline (its 'descent'). Space may be added to the
maximum ascent (SCI_SETEXTRAASCENT) and the maximum descent
(SCI_SETEXTRADESCENT) to allow for more space between lines. This may
done to make the text easier to read or to accomodate underlines or
highlights.

Neil

Philippe Lhoste

unread,
Apr 1, 2009, 5:26:07 AM4/1/09
to scintilla...@googlegroups.com
On 01/04/2009 04:11, Neil Hodgson wrote:
> It is now possible to set an extra amount of ascent and descent for
> text. The settings are extra amounts because this works with the user
> zooming better than setting the total ascent and descent. While using
> negative numbers for these parameters is currently possible, such use
> may produce random results and is not supported.

This is interesting. Although I would have been precisely interested by negative values,
some fonts, or font combinations, makes too much spacing as you point out, and if that's
font combinations, it is hard to find the culprit (set this font size to ridiculously
small value, check ... set this one, check ...).

> This may done to make the text easier to read or to accomodate underlines or
> highlights.

This reminds me, although I admit it is hardly related...

For the HTML lexer, I chose font:Georgia,size:9 for style 0 (plain text) and font:Andale
Mono,size:9 for style 32 (default).
As a result, content of HTML tag is fixed width while text is proportional, easier to read.
But the indentation is using, in general, the text style/font, with a rather small space
width. The problem is that indentation guides, aligned on fixed font tags, so on a wider
basis, are drawn after text, so they partially hide it.
I uploaded a screenshot to illustrate the problem:
http://usera.ImageCave.com/PhiLho/Screenshots/IndentationGuidesOverText.png
(volatile URL!)

That's all. The fix is probably simple, I hope. Alas I don't do much C/C++ coding
currently, so I fear I can't provide a fix shortly.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Neil Hodgson

unread,
Apr 1, 2009, 10:22:06 PM4/1/09
to scintilla...@googlegroups.com
Philippe Lhoste:

> This is interesting. Although I would have been precisely interested by negative values,
> some fonts, or font combinations, makes too much spacing as you point out, and if that's
> font combinations, it is hard to find the culprit (set this font size to ridiculously
> small value, check ... set this one, check ...).

Scintilla currently divides the window strictly up into a sequence
of lines. If you decrease ascent or descent then bits of characters
will be missing. To do this well, the window should be treated more as
a single area allowing descenders and underlines from one line to be
partly in the next line. This would mean changing the drawing code a
lot to draw the whole window as a set of layers so that drawing the
background colour for one line doesn't wipe out the text from another.
It is likely that this would then lead to more lines being drawn at a
time (so that the common portions would look right) and would be
slower. Probably a good feature but it will bulk up the code if the
current drawing method is also available for compatibility and
performance.

> As a result, content of HTML tag is fixed width while text is proportional, easier to read.
> But the indentation is using, in general, the text style/font, with a rather small space
> width. The problem is that indentation guides, aligned on fixed font tags, so on a wider
> basis, are drawn after text, so they partially hide it.

Yes, that is present even in the distributed properties. I'll
eventually have a look at it.

Neil

Reply all
Reply to author
Forward
0 new messages