Next: , Previous: , Up: Classes   [Index]


X11Font

X11Font Class

A X11Font object provides information about a X Window System font, like its resource ID, width, height, and X Logical Font Descriptor (XLFD) string. Normally, a pane or X window does not use font glyphs directly but uses Pane methods to display text using the font resource. See X11Pane.

For variable width fonts, the maxWidth instance variable provides the width of the widest character in the set.

For more information about X’s font naming scheme, the xfontsel(1) manual page is a good place to begin.

Instance Variables

ascent
descent

Integer objects that contain the number of pixels the character set extends above and below the baseline. These dimensions are typically used to determine interline spacing.

fontDesc

A String containing the X Logical Font Descriptor of the receiver’s font. After a call to getFontInfo (below), contains the XLFD of the actual font.

fontId

An Integer that contains the X Window System’s resource ID of the font.

height

An Integer that contains the sum of the maximum descent and ascent; that is, the height of the font’s tallest character.

maxLBearing

An Integer that contains the maximum distance in pixels from a character’s drawing origin to its glyph.

maxRBearing

An Integer that contains the maximum distance in pixels between the right side of a font’s character glyphs to the right-hand edge of the character space.

maxWidth

An Integer that contains the width of the font’s widest character glyph. Note that these metrics’ uses differ for different fonts, and can vary a lot, especially in foreign language character sets. Generally, though, for Western, monospaced fonts, the width in pixels of a character plus its horizontal spacing is:


myFont maxLBearing + myFont maxWidth;

Instance Methods

getFontInfo (String fontDesc)

Fills in the font metrics (height, maxWidth, ascent, descent, X font ID) for the font named by fontDesc. Also fills in the receiver’s fontDesc instance variable with the string given as the argument.

textWidth (String text)

Returns an Integer with the width of text in pixels when rendered in the reciever’s font. The program should call the getFontInfo method before calling this method.


Next: , Previous: , Up: Classes   [Index]