Next: , Previous: , Up: Using Fonts   [Contents][Index]


5.19.5 Character Classes

Classes are particularly useful for East Asian languages such as Chinese, Japanese, and Korean, where the number of needed characters is much larger than in European languages, and where large sets of characters share the same properties.

Request: .class name c1 c2 …

Define a character class (or simply “class”) name comprising the characters c1, c2, and so on.

A class thus defined can then be referred to in lieu of listing all the characters within it. Currently, only the cflags request can handle references to character classes.

In the request’s simplest form, each cn is a character (or special character).

.class [quotes] ' \[aq] \[dq] \[oq] \[cq] \[lq] \[rq]

Since class and glyph names share the same name space, it is recommended to start and end the class name with [ and ], respectively, to avoid collisions with existing character names defined by GNU troff or the user (with char and related requests). This practice applies the presence of ] in the class name to prevent the use of the special character escape form \[], thus you must use the \C escape to access a class with such a name.

You can also use a character range notation consisting of a start character followed by ‘-’ and then an end character. Internally, GNU troff converts these two symbol names to Unicode code points (according to the groff glyph list [GGL]), which then give the start and end value of the range. If that fails, the class definition is skipped.

Furthermore, classes can be nested.

.class [prepunct] , : ; > }
.class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]

The class ‘[prepunctx]’ thus contains the contents of the class [prepunct] as defined above (the set ‘, : ; > }’), and characters in the range between U+2013 and U+2016.

If you want to include ‘-’ in a class, it must be the first character value in the argument list, otherwise it gets misinterpreted as part of the range syntax.

It is not possible to use class names as end points of range definitions.

A typical use of the class request is to control line-breaking and hyphenation rules as defined by the cflags request. For example, to inhibit line breaks before the characters belonging to the prepunctx class defined in the previous example, you can write the following.

.cflags 2 \C'[prepunctx]'

See the cflags request in Using Symbols, for more details.


Next: , Previous: , Up: Using Fonts   [Contents][Index]