6.2 Fonts and Text

A font in X is a set of bitmaps and may represent text, a set of cursor shapes, or perhaps some other set of shapes for some other purpose.

The following sections describe the character format, how to load fonts, character metrics, the XFontStruct and XCharStruct structures, placing text, font properties, and more.

6.2.1 Character Format

Every X function that draws text has two versions: one that handles single-byte (8-bit) fonts and one for two-byte (16-bit) fonts. The difference between these two is that a single-byte font is limited to 256 characters, while a two-byte font may have up to 256 rows each with 256 characters, a total of 65,536 characters. Large numbers of characters are necessary for Oriental languages.

On many servers, only single-byte fonts can be used with the routines whose names do not end in 16 and only two-byte fonts may be used with the routines that do end in 16. However, some servers may handle either type in either routine. At the moment, there is only one two-byte font on the standard X distribution, the Kanji font used by the kterm program, a terminal emulator for Japanese.

6.2.2 Loading Fonts

A font must be loaded before being used. If one or more clients are using the same font, they share the same copy in the server, but each must request that the font be loaded, if only to get the font ID. The available fonts are stored in a database that is accessible with the XListFonts() and XListFontsWithInfo() commands.

XListFonts() lists the fonts ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.