
ucs2any Command in Linux
Understanding ucs2any not only gives you the tools to produce specialized fonts but also offers insight into the evolution of font encoding and management on Unixâlike systems. Even though much of the modern graphical world has moved toward outline fonts, many systems (from embedded devices to legacy applications) still benefit greatly from bitmap fonts in specific encodings.
With ucs2any, you have a powerful commandâline tool that efficiently bridges the gap between universal Unicode representations and the more specialized 8-bit encodings required by certain applications.
Table of Contents
Here is a comprehensive guide to the options available with the ucs2any command −
- Understanding ucs2any Command
- How to Use ucs2any Command in Linux?
- Syntax and Command-Line Options
- Multiple Mapping Files and Registry-Encoding Pairs
- Examples of ucs2any Command in Linux
Understanding ucs2any Command
The ucs2any command was specifically designed to leverage an ISO 10646â1 encoded master BDF file to create various target BDF fonts with different encodings. By generating fonts in multiple 8âbit encodings from a single master font, ucs2any eliminates the need to store many complete font files that only differ in the arrangement of character codepoints.
For example, using ucs2any, one can derive fonts for the ISO 8859â1 (Latinâ1), ISO 8859â2 (Latinâ2), and many other 8âbit encodings from one master font file. This approach is not only storage efficient but also ensures consistency across different encoded versions of the same typeface.
How to Use ucs2any Command in Linux?
Simply put, ucs2any takes as input an ISO 10646â1 encoded BDF font (the master font) and mapping files that describe how to translate Unicode codepoints into the desired target encoding. It then produces one or more new BDF font files reâencoded in the specified encoding(s).
This conversion process involves reading the glyph representations, filtering out only the glyphs that belong to the target encoding, and rearranging the mapping so that the target font conforms to its designated encoding's layout.
Syntax and Command-Line Options
The basic syntax of the ucs2any command is as follows −
ucs2any [ +d | -d ] source-name { mapping-file registry-encoding } ...
Let's break this down component by component.
Usage Example:
To include the DEC VT100 symbols −
ucs2any +d mymasterfont.bdf mapping1.txt target1

To omit them −
ucs2any -d mymasterfont.bdf mapping1.txt target1

The source-name Operand
The source-name operand is the name (and path, if needed) of the master BDF file. This file must be encoded in ISO 10646â1.
For example −
ucs2any -d 6x13.bdf mapping_file.txt target_encoding

In this example, 6x13.bdf is the source file that contains the master font data.
The mapping-file Operand
Next, you provide one or more mapping files. These files define the character set translations between ISO 10646â1 and the target encoding. Mapping files are simple text files (often distributed by the Unicode Consortium and available on FTP sites such as ftp://ftp.unicode.org/Public/MAPPINGS/) that list the correspondence between Unicode codepoints and the corresponding codepoints in an 8âbit encoding.
In many systems, these mapping files are installed in directories like /usr/X11R6/lib/X11/fonts/util/, making them easily accessible when generating new fonts.
The registry-encoding Operand
Following each mapping file, you specify a registry-encoding pair. This operand represents the two fields from the font's naming convention (known as the XLFD) that describe the target encoding −
- CHARSET_REGISTRY − Often denotes the organization or standard (for example, "ISO10646").
- CHARSET_ENCODING − Specifies the actual encoding (for example, "iso8859-1" or "iso8859-2").
These fields are typically separated by a hyphen when viewed together. This operand tells ucs2any what to name the target BDF file accordingly. Each mapping file's corresponding registry-encoding tells the command which encoded subset to produce.
Multiple Mapping Files and Registry-Encoding Pairs
An important feature of ucs2any is that you can provide not just a single mapping file and encoding pair but any number of these pairs. This allows you to generate multiple fonts from the master font in one single invocation of the command.
Example −
ucs2any 6x13.bdf 8859-1.TXT iso8859-1 8859-2.TXT iso8859-2

In this example −
- 6x13.bdf is the master font.
- 8859-1.TXT is the mapping file for the ISO 8859â1 encoding, and iso8859-1 is the registry-encoding.
- 8859-2.TXT is the mapping file for the ISO 8859â2 encoding, and iso8859-2 is its registry-encoding.
Each file will contain only the glyphs that belong to the respective 8âbit encoding.
Examples of ucs2any Command in Linux
Let's walk through some real-world scenarios and examples that demonstrate the usage of ucs2any.
Converting a Font with DEC VT100 Graphics
Suppose you have an ISO 10646â1 encoded BDF file named 6x13.bdf that is tailored for use in a terminal with characterâcell fonts. You want to generate a version of this font for the ISO 8859â1 encoding and include DEC VT100 graphics characters in the C0 range.
ucs2any +d 6x13.bdf 8859-1.TXT iso8859-1

- The +d flag tells ucs2any to include the DEC VT100 graphics characters in the C0 range.
- bdf is your master font.
- 8859-1.TXT is the mapping file for ISO 8859â
- iso8859-1 indicates the registry-encoding.
- The output would be a file likely named 6x13-iso8859-1.bdf, which includes both the standard glyphs and the additional DEC VT100 graphics characters required for characterâcell display.
Generating Multiple Encoded Fonts Simultaneously
Imagine you need to produce fonts for two different ISO 8859 variants-say ISO 8859â1 and ISO 8859â2- from a single master file. You can supply multiple mapping file and registryâencoding pairs in one command.
ucs2any -d 6x13.bdf 8859-1.TXT iso8859-1 8859-2.TXT iso8859-2

- The -d flag is used because you want to omit the DEC VT100 graphics characters (which is common for many fonts aside from the specialized characterâcell fonts).
- The master font is 6x13.bdf.
- Each output file contains only the glyphs that correspond to its respective 8âbit encoding.
Using Alternative Mapping Files
Mapping files can vary depending on your requirements. For instance, if you're targeting a less common 8âbit encoding (or a custom encoding), you might have a mapping file specifically designed for that purpose. Provided you have the correct mapping file and specify the desired registryâencoding correctly, ucs2any handles the conversion seamlessly.
ucs2any -d masterfont.bdf mycustom_map.TXT myregistry-custom

Here, masterfont.bdf is the master ISO 10646â1 BDF file.
- TXT is your custom mapping file.
- myregistry-custom indicates the target registryâ
- The output, likely named masterfont-myregistry-custom.bdf, will then be a font file formatted for your custom encoding.
Conclusion
In summary, the Linux ucs2any command is indispensable for generating multiple encoded BDF fonts from a single master ISO 10646-1 font. With clear options for including control characters, specifying mapping files and the desired target encoding, and handling multiple outputs simultaneously, ucs2any remains a vital tool for font management in legacy and specialized environments. Embrace its flexibility, and you can maintain a consistent, efficient, and tailored set of fonts for virtually any 8-bit environment.