summaryrefslogtreecommitdiff
path: root/devdocs/elisp/line-height.html
blob: 3c81112a97ea3f758b568199e251f6fcf64902fd (plain)
1
2
3
4
5
6
 <h3 class="section">Line Height</h3>   <p>The total height of each display line consists of the height of the contents of the line, plus optional additional vertical line spacing above or below the display line. </p> <p>The height of the line contents is the maximum height of any character or image on that display line, including the final newline if there is one. (A display line that is continued doesn’t include a final newline.) That is the default line height, if you do nothing to specify a greater height. (In the most common case, this equals the height of the corresponding frame’s default font, see <a href="frame-font">Frame Font</a>.) </p> <p>There are several ways to explicitly specify a larger line height, either by specifying an absolute height for the display line, or by specifying vertical space. However, no matter what you specify, the actual line height can never be less than the default. </p>  <p>A newline can have a <code>line-height</code> text or overlay property that controls the total height of the display line ending in that newline. The property value can be one of several forms: </p> <dl compact> <dt><code>t</code></dt> <dd><p>If the property value is <code>t</code>, the newline character has no effect on the displayed height of the line—the visible contents alone determine the height. The <code>line-spacing</code> property, described below, is also ignored in this case. This is useful for tiling small images (or image slices) without adding blank areas between the images. </p></dd> <dt><code>(<var>height</var> <var>total</var>)</code></dt> <dd><p>If the property value is a list of the form shown, that adds extra space <em>below</em> the display line. First Emacs uses <var>height</var> as a height spec to control extra space <em>above</em> the line; then it adds enough space <em>below</em> the line to bring the total line height up to <var>total</var>. In this case, any value of <code>line-spacing</code> property for the newline is ignored. </p></dd> </dl>  <p>Any other kind of property value is a height spec, which translates into a number—the specified line height. There are several ways to write a height spec; here’s how each of them translates into a number: </p> <dl compact> <dt><code><var>integer</var></code></dt> <dd><p>If the height spec is a positive integer, the height value is that integer. </p></dd> <dt><code><var>float</var></code></dt> <dd><p>If the height spec is a float, <var>float</var>, the numeric height value is <var>float</var> times the frame’s default line height. </p></dd> <dt><code>(<var>face</var> . <var>ratio</var>)</code></dt> <dd><p>If the height spec is a cons of the format shown, the numeric height is <var>ratio</var> times the height of face <var>face</var>. <var>ratio</var> can be any type of number, or <code>nil</code> which means a ratio of 1. If <var>face</var> is <code>t</code>, it refers to the current face. </p></dd> <dt><code>(nil . <var>ratio</var>)</code></dt> <dd><p>If the height spec is a cons of the format shown, the numeric height is <var>ratio</var> times the height of the contents of the line. </p></dd> </dl> <p>Thus, any valid height spec determines the height in pixels, one way or another. If the line contents’ height is less than that, Emacs adds extra vertical space above the line to achieve the specified total height. </p> <p>If you don’t specify the <code>line-height</code> property, the line’s height consists of the contents’ height plus the line spacing. There are several ways to specify the line spacing for different parts of Emacs text. </p> <p>On graphical terminals, you can specify the line spacing for all lines in a frame, using the <code>line-spacing</code> frame parameter (see <a href="layout-parameters">Layout Parameters</a>). However, if the default value of <code>line-spacing</code> is non-<code>nil</code>, it overrides the frame’s <code>line-spacing</code> parameter. An integer specifies the number of pixels put below lines. A floating-point number specifies the spacing relative to the frame’s default line height. </p>  <p>You can specify the line spacing for all lines in a buffer via the buffer-local <code>line-spacing</code> variable. An integer specifies the number of pixels put below lines. A floating-point number specifies the spacing relative to the default frame line height. This overrides line spacings specified for the frame. </p>  <p>Finally, a newline can have a <code>line-spacing</code> text or overlay property that can enlarge the default frame line spacing and the buffer local <code>line-spacing</code> variable: if its value is larger than the buffer or frame defaults, that larger value is used instead, for the display line ending in that newline. </p> <p>One way or another, these mechanisms specify a Lisp value for the spacing of each line. The value is a height spec, and it translates into a Lisp value as described above. However, in this case the numeric height value specifies the line spacing, rather than the line height. </p> <p>On text terminals, the line spacing cannot be altered. </p><div class="_attribution">
  <p class="_attribution-p">
    Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
    <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Line-Height.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Line-Height.html</a>
  </p>
</div>