Next: Special Fonts, Previous: Using Symbols, Up: Fonts and Symbols [Contents][Index]
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.
In groff
, a character class (or simply “class”) is a set
of characters, grouped by some user aspect. The class
request
defines such classes so that other requests can refer to all characters
belonging to this set with a single class name. Currently, only the
cflags
request can handle character classes.
A class
request takes a class name followed by a list of
entities. In its simplest form, the entities are characters or symbols:
.class [prepunct] , : ; > }
Since class and glyph names share the same namespace, it is recommended
to start and end the class name with [
and ]
,
respectively, to avoid collisions with normal groff
symbols (and
symbols defined by the user). In particular, the presence of ]
in the symbol name intentionally prevents the usage of \[...]
,
thus you must use the \C
escape to access a class with such a
name.
You can also use a special character range notation, consisting of a
start character or symbol, followed by ‘-’, and an end character or
symbol. Internally, gtroff
converts these two symbol names to
Unicode values (according to the groff glyph gist), which then give the
start and end value of the range. If that fails, the class definition
is skipped.
Finally, classes can be nested, too.
Here is a more complex example:
.class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
The class ‘prepunctx’ now 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 add ‘-’ to a class, it must be the first character value in the argument list, otherwise it gets misinterpreted as a range.
Note that it is not possible to use class names within range definitions.
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, you can write:
.cflags 2 \C'[prepunctx]'
See the cflags
request in Using Symbols, for more details.
Next: Special Fonts, Previous: Using Symbols, Up: Fonts and Symbols [Contents][Index]