Previous: , Up: Font and Characters   [Contents][Index]


9.5 Querying Text Size

CLX defines functions to return the size of text drawn in a specified font. See Drawing Text, for a description of the :translate function used by the functions in the following paragraphs.

Function: text-extents font sequence &key (:start 0) :end :translate
font

The font (or gcontext) used for measuring characters.

sequence

A sequence of characters or other objects to be translated into font indexes.

:start
:end

Start and end indexes defining the elements to draw.

:translate

A function to translate text to font indexes. Default is #’translate-default.

Returns the complete geometry of the given sequence when drawn in the given font. The font can be a gcontext, in which case the font attribute of the given graphics context is used. :start and :end define the elements of the sequence which are used.

The returned width is the total pixel width of the translated character sequence. The returned ascent and descent give the vertical ascent and descent for characters in the translated sequence. The returned left gives the left bearing of the leftmost character. The returned right gives the right bearing of the rightmost character. The returned font-ascent and font-descent give the maximum vertical ascent and descent for all characters in the font. If :translate causes font changes, then font-ascent and font-descent will be the maximums over all fonts used. The direction returns the preferred draw direction for the font. If :translate causes font changes, then the direction will be nil. The first-not-done value returned is nil if all elements of the sequence were successfully translated; otherwise the index of the first untranslated element is returned.

width

Type int32.

ascent

Type int16.

descent

Type int16.

left

Type int32.

right

Type int32.

font-ascent

Type int16.

direction

Type draw-direction.

first-not-done

Type array-index or null.

Function: text-width font sequence &key (:start 0) :end :translate
font

The font (or gcontext) used for measuring characters.

sequence

A sequence of characters or other objects to be translated into font indexes.

:start
:end

Start and end indexes defining the elements to draw.

:translate

A function to translate text to font indexes. Default is #’translate-default.

Returns the total pixel width of the given sequence when drawn in the given font. The font can be a gcontext, in which case the font attribute of the given graphics context is used. :start and :end define the elements of the sequence which are used. The second value returned is nil if all elements of the sequence were successfully translated; otherwise the index of the first untranslated element is returned.

width

Type int32.

first-not-done

Type array-index or null.


Previous: , Up: Font and Characters   [Contents][Index]