International Language Environments Guide

Chapter 7 Print Filter Enhancement With mp

This chapter describes print enhancement to the mp utility. The chapter discusses the following topics:

Printing for UTF-8

An enhanced mp print filter that can print various input file formats including flat text files written in UTF-8 is available in the current Oracle Solaris environment. This print filter uses TrueType and Type 1 scalable fonts and X11 bitmap fonts available on the Oracle Solaris system. The filter can also make use of printer resident fonts and can act as an X print server client.

The output from the utility is standard PostScript and can be sent to any PostScript printer. The mp utility can also output any page description language when configured as an X Print server client, mp is supported by the print server.

To use the utility, type the following command:

system% mp filename | lp

You can also use the utility as a filter, since mp accepts stdin stream:

system% cat filename | mp | lp

You can set the utility as a printing filter for a line printer. For example, the following command sequence tells the printer service LP that the printer lp1 accepts only mp format files. This command also installs the printer lp1 on port /dev/ttya. See the lpadmin(1M) man page for more details.

system# lpadmin -p lp1 -v /dev/ttya -I MP
system# accept lp1
system# enable lp1

Using lpfilter(1M), you can add the utility for a filter as follows:

system# lpfilter -f lp1 -F pathname 

The command tells LP that a converter (in this case, mp) is available through the filter description file named pathname. pathname contains the following information:

Input types: simple 
Output types: MP
Command: /usr/bin/mp

The filter converts the default type file input to PostScript output using /usr/bin/mp.

To print a UTF-8 text file, use the following command:

system% lp -T MP UTF-8-file

Refer to the mp(1) man page for more detail.

mp Print Filter Enhancement Overview

The mp print filter is enhanced in the current Oracle Solaris release. The latest mp can work internally in three different modes to produce the output file in a locale to print international text. The available modes are:

The following sections describe when to use a specific printing method and which configuration and supporting files are used by mp for these printing methods.

Using mp With the Locale-Specific Font Configuration File mp.conf

If the -D or -P option is not given in the command line, this printing method is the default method, unless the file is present in either of the/usr/openwin/lib/locale/$LANG/print or /usr/lib/lp/locale/$LANG/mp directories. The file forces mp to print using PostScript embedded fonts in the file. Even if a exists in a locale, using the -M option ignores the file and uses an mp.conf file instead, if one exists.

This method uses the /usr/lib/lp/locale/$LANG/mp/mp.conf font configuration file. You probably do not need to change this file unless you need to print using alternate fonts. This file can be configured with TrueType, Type 1, or .pcf fonts.

Using mp With the Locale-Specific PostScript Prolog Files

The /usr/lib/lp/locale/C/ directory contains .ps print page layout files common for this mode of printing. A description of how to customize these files is provided in Adding and Customizing prolog Files

If the -D or -P option is not given in the command line, and /usr/openwin/lib/locale/$LANG/print/ exists, then the file is prepended to the output. Depending upon the print style of the .ps prolog page, the layout file is also prepended to the output.

This method of printing makes use of PostScript font files only. Customization of files is described in Adding and Customizing prolog Files.

Using mp as an Xprt (X Print Server) Client

Using mp as an Xprt client enables mp to print the output of any printer connected to a network supported by an Xprt print service. As an Xprt client, mp supports PostScript and many versions of PCL.

The Xprt client attempts a connection to an Xprt server based on the following rules:

Localization With the mp.confConfiguration File

Configuration files provide the flexibility for adding or changing font entries, or font group entries.

The system default configuration file is /usr/lib/lp/locale/$LANG/mp/mp.conf where $LANG is a locale environment variable in the locale in which printing occurs. You can specify a personal configuration file with the -u config.file path option.

A ligature or variant glyph that has been encoded as a character for compatibility is called a presentation form. The mp.conf file is used mainly for mapping the intermediate code points in a locale to the presentation forms in the encoding of the font that is used to print that code point.

Intermediate code points can either be wide characters, or output of the Portable Layout Services (PLS) layer. Complex Text Layout printing requires the intermediate code points to be PLS output. The default intermediate code generated by mp is PLS output.

Font formats currently supported are Portable Compiled Format (PCF), TrueType, and Type1 format. Both system-resident and printer-resident Type1 fonts are supported. Keep in mind the following information about the format and contents of the mp.conf configuration file:

The different sections in the mp.conf file include:

Font Aliasing

The font aliasing section of the mp.conf file is used to define alias names for each font used for printing. Each line in this section is of the following form:

FontNameAlias font-alias-name font-type font-path 			

The usual convention for aliasing a font name is to specify the encoding/script name of the font followed by a letter that indicates whether the font is Roman, Bold, Italic, or BoldItalic (R, B, I or BI).

For example,/usr/openwin/lib/X11/fonts/75dpi/courR18.pcf.Z, because it is an iso88591 Roman font, can be assigned the alias name iso88591R.


Possible values are PCF for .pcf fonts, Type1 for Adobe Type1 fonts, and TrueType for TrueType fonts. Only these three kinds of fonts can be configured in this mp.config file.


The absolute path name for the font files. For Type1 printer-resident fonts, just specify the font name, such as Helvetica.

For example,

FontNameAlias   prnHelveticaR   Type1   Helvetica

Font Group Definition

You can combine same-type fonts to form a font group. The format of the font group is as follows:




The group name for the fonts.


The font type. Create font groups for the same type of fonts only (PCF, Type1, TrueType).


The Roman font name in the font group.


The Bold font name in the font group.


The Italic font name in the font group.


The BoldItalic font name in the font group.

For creating a group, only a Roman font entry is required. The Bold, Italic, and BoldItalic fonts are optional. The different types of fonts are used to display the header lines for mail or news articles, for example. If only the Roman font is defined, that font is used in place of other fonts.

Mapping Section

The mapping section of the mp.conf files maps from the intermediate code ranges to the font group in a locale. The format for each line in this section is as follows.




A 4–byte hexadecimal value, starting with 0x, that indicates the start of the code range to map to one or more font groups.


Indicates the end of the code range to map. If the values is '-', only a single intermediate code point is mapped to the target font.


A Type1, PCF, or TrueType font group with which the presentation forms are to be printed.

Association Section

The association section of the mp.conf file associates each font with the shared object that maps the intermediate code points to the presentation forms in the font encoding. The format for each line in this section is as follows:



font alias name

The alias name defined for the font.

mapping function

Takes in the intermediate code and returns presentation forms in font encoding, which is in turn used to get the glyph index and draw the glyph.

file path having mapping function

The .so file name that contains the mapping function. You can use the utility in dumpcs to ascertain the intermediate code set for EUC locales.

Note –

The current TrueType engine used by mp (1) can work only with format 4 and PlatformID 3 cmap. You can only configure Microsoft .ttf files. Additionally, the character map encoding has to be Unicode or Symbol for the TrueType font engine to work correctly. Because most of the .ttf fonts in the Oracle Solaris environment obey these restrictions, you can map all TrueType fonts in Oracle Solaris software within the mp.conf file.

You can create a shared object that maps a font to correspond with a PCF type1 X Logical Fonts Description (XLFD). You can then create a shared object that maps from the intermediate code range to the encoding specified by XLFD. For example:


The corresponding PCF font is:


This font is encoded in ISO 8859-8, so shared objects have to map between intermediate code and corresponding ISO 8859-8 code points.

If a TrueType font with XLFD:


has the corresponding font:


you should map between the intermediate code and Unicode, because the cmap encoding for the previous TrueType font is in Unicode. In the example of this TrueType font, suppose a sample intermediate code in the en_US.UTF-8 locale that corresponds to a Hebrew character (produced by the PLS layer) is 0xe50000e9. Because the font is Unicode encoded, design the function within the corresponding .so module in such a way that when you are passing 0xe50000e9, the output corresponds to presentation form in Unicode. The example here is 0x000005d9.

The function prototype for the mapping function should be:

unsigned int function(unsigned int inter_code_pt)

The following are optional keyword/value pairs that you can use in mp.conf:

PresentationForm        WC/PLSOutput

The default value is PLSOutput. If the user specifies WC, then the intermediate code points that are generated are wide characters. For CTL printing, this default value should be used.

If the locale is a non-CTL locale and the keyboard value is PLSOutput, that value is ignored and the mp generates wide-character codes instead.

You can use the optional keyword/value pairs listed in the following table if the locale supports CTL. These variables can assume any of the possible values given in the middle column of the table.

Table 7–1 Optional Keyword/Value Pairs

Optional Keyword 

Optional Value 




















ProcedureHow to Add a Printer-Resident Font

The example in the following procedure illustrates how to add a new PCF, TrueType, or Type1 printer-resident font to the configuration file.

Complete this procedure to replace the currently configured font. In the first two steps, a PCF font used to display the characters in the range 0x00000021 - 0x0000007f is replaced with a TrueType font.

  1. Before you add a new font, look at various components in the configuration file that correspond to the currently configured font.

    FontNameAlias iso88591R  PCF  /usr/openwin/lib/X11/fonts/75dpi/courR18PCF.Z
    FontNameAlias iso88591B  PCF  /usr/openwin/lib/X11/fonts/75dpi/courB18PCF.Z
    FontGroup       iso88591         PCF       iso88591R iso88591B
    MapCode2Font    0x00000020      0x0000007f      iso88591
    CnvCode2Font iso88591R _xuiso88591 /usr/lib/lp/locale/$LANG/mp/
    CnvCode2Font iso88591B _xuiso88591 /usr/lib/lp/locale/$LANG/mp/

    For example, you could map the /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf fonts to the en_US.UTF-8 locale. Because HG-MinchoL.ttf is a Unicode TrueType font file, you use the .so module mapping function to directly return the incoming ucs-2 code points.

    unsigned short _ttfjis0201(unsigned short ucs2) {
    1. Save the mapping to the ttfjis0201.c file.

    2. Create a shared object file.

      cc -G -Kpic -o ttfjis0201.c
  2. To map a PCF file, such as /usr/openwin/lib/locale/ja/X11/fonts/75dpi/gotmrk20.pcf.Z, check the following encoding that corresponds to XLFD in the /usr/openwin/lib/locale/ja/X11/fonts/75dpi/fonts.dir file.

    1. For jisx0201 encoding, prepare a shared object that maps from ucs-2 to jisx0201. Obtain the mapping table for creating the .so module. For a Unicode locale, find the character set mappings to Unicode in the directory.

    2. Use these mappings to write a xu2jis0201.c file:

      unsigned short _xu2jis0201(unsigned short ucs2) {
                               if(ucs2 >= 0x20 && ucs2 <= 0x7d )
                                       return (ucs2);
                                       return (0x7e);
                               if(ucs2 >= 0xff61 && ucs2 <= 0xff9f)
                                       return (ucs2 - 0xff60 + 0xa0);
    3. When you create a mapping file, include all the usc—2 to jisx0201 cases.

      cc  -G -o xu2jis0201.c

ProcedureHow to Create a Shared Object File

The examples in the following procedure how you how to create shared object files.

  1. To add a font, edit the lines of the following example that correspond to sections of the mp.conf file.

    This example shows how to add the TrueType font. The .so path points to the file.

    FontNameAlias   jis0201R TrueType /home/fn/HG-Minchol.ttf
    FontGroup     jis0201 TrueType jis0201R
    MapCode2Font  0x0020 	0x007f  jis0201
    CnvCode2Font   jis0201R 	 _ttfjis0201 <.so path>

    Note –

    To add a PCF font, change the keyword from TrueType to PCF.

  2. Invoke the mp command with the changed mp.conf file to print the range 0x0020-0x007f in the new font.

    You can map other Japanese character ranges with the same .so file, For example, you could map the range 0x0000FF61 0x0000FF9F.

    Note –

    To maintain backward compatibility, you can use the /usr/openwin/lib/locale/$LANG/print/ file to create output in the current locale. When you use the file, no configuration file is required.

    You can find a sample mp.conf file in the /usr/lib/lp/locale/en_US.UTF-8/mp directory.

Adding and Customizing prolog Files

The prolog files can be divided into two main categories:

PostScript File Customization

The PostScript files fall into the following categories:

Locale-Dependent prolog Files

The purpose of the file is to set up non-generic fonts. Applications use these predefined PostScript font names for printing. The prolog file must define at least the following font names for Desk Set Calendar manager and mp:

The following example uses these fonts to print the particular local character set specified:

100 100 moveto
/LC_Times-Roman findfont 24 scale font setfont
(Any text string in your locale) show 

The Oracle Solaris localization kit provides a sample file for the Japanese environment. Alternatively, this file is found in the /usr/openwin/lib/locale/ja/print/ directory.

The following example shows how to add or change composite fonts in an existing file.

(Foo-Fine) makecodeset12 
(Base-Font) makeEUCfont

You could define a composite font called LC_Base-Font, for example. LC_Base-Font might be a composite of a Foo-Fine font that contains a locale character set and a Base-Font. You do not need in-depth knowledge of PostScript programming to add or change a font.

The best way to create a file is to study the example version. In the example, two routines need to be written: makecodeset12 and makeEUCfont. The routine makecodeset12 sets the local font-encoding information. This routine might differ from locale to locale. The routine makeEUCfont combines the base font and the locale font to form a composite font. The creator of the prolog file should have good knowledge of PostScript in order to write makecodeset12 and makeEUCfont.

The file support is reserved for backward compatibility only. Do not create a new file for generating printed output for a locale. Use mp.conf instead.

The path for file is


Common PostScript prolog Files

The common prolog file is

Every other page layout prolog file needs to include this file.

The file resides in the /usr/lib/lp/locale/C/mp/ directory. This file contains a PostScript routine to re-encode a font from the standard encoding to the ISO 8859–1 encoding. The .reencodeISO routine is called from the print layout prolog files to change encoding of the fonts. Usually this prolog file does not need any customization. If you create your own prolog file, set the environment variable MP_PROLOGUE to point to the directory that contains the modified prolog files.

Print Layout prolog Files

The print layout prolog files, mp.*.ps files, contain routines for controlling the page layout for printing. In addition to issuing a header and a footer for a print page with user name, print date, and page number, these prolog files can provide other information. For example, the prolog files can give effective print area dimensions and landscape and portrait mode of printing to be used.

The Print Layout prolog files are:

A set of standard functions needs to be defined in every prolog file. These functions are called when a new print page starts, a print page ends, or a new column ends. The implementations of these functions define the print attributes of the printout.

The following PostScript variables are defined at runtime by the mp binary. All the print layout files can use these variables for printing dynamic information such as user name, subject, print time. This information taken from the variables normally appears in the header or footer of the print page.


The name of the user who is running mp, obtained from the system passwd file.


Variable used to hold the name of the type of article to print. The possible values for this variable are:

  • Listing for – When the input is a text file

  • Mail for – When the input is a mail file

  • Article from – When the input is an article from a news group


The subject taken from the mail and news headers. You can use the -s option to force a subject to the mail and news files as well as to normal text files.


The time of print that appears in the header and footer. This information is taken from the localtime() function.

The following functions are implemented in print layout prolog files. All of these functions can use subfunctions.


Usage: page_number endpage

Called when the bottom of a printed page is reached. This function restores the graphic context of the page and issues a showpage. In some prolog files the header and footer information is displayed in a page-by-page mode rather than in a column-by-column mode. You can implement this function to call subfunctions that display the header and footer gray-scale lozenges.


Usage: page_number newpage

Routines or commands to be executed when a new page begins. Setting landscape print mode, saving the print graphic context, and translating the page coordinates are some of the functions for these routines.


Usage: page_number col_number endcol

Used to display header and footer information, move to the new print position, and so forth.

To add new print layout prolog files, you need to define the following variables explicitly within the print layout prolog file:


Number of columns in a print page. Default is 2.


Width of print area in inches. Default is 6.


Height of print area in inches. Default is 9.

.xpr Files

These files are located by default at /usr/lib/lp/locale/C/mp/. An .xpr file corresponds to each PostScript prolog layout file except the file. You can define an alternate prolog directory by defining the MP_PROLOGUE environment variable.

These files work as keyword/values pairs. Lines that start with # are considered comments. Spaces separate different tokens unless explicitly stated. Three main sections for each .xpr file are bound by the following keyword pairs:

Certain keyword/value pairs can be used in these three areas. Each area is described in the following section.


All the keyword/value pairs that appear after the STARTCOMMON keyword and before the ENDCOMMON keyword define general properties of the print page. Different valid values for a keyword are separated by using a slash (/) character.


0 means the printing occurs in portrait and 1 means in landscape.

PAGELENGTH unsigned-integer

A value that indicates the number of lines per logical page.

LINELENGTH unsigned-integer

A value that indicates the number of single-column characters per line.

NUMCOLS unsigned-integer

The number of logical pages per physical page.

HDNGFONTSIZE unsigned-integer

The heading-font point size in decipoints.

BODYFONTSIZE unsigned-integer

The body-font point size in decipoints.

PROLOGDPI unsigned-integer

The dots-per-inch scale in which the current .xpr file is created.

YTEXTBOUNDARY unsigned-integer

This y-coordinate establishes the boundary for text printing in a page or logical page (column). This boundary is used as an additional check to see whether text printing is occurring within the expected area. This boundary is needed for Complex Text Layout and EUC printing, as character height information obtained from corresponding fonts can be wrong.

STARTTEXT unsigned-integerunsigned-integer

The decipoint x/y points where the actual text printing starts in the first logical page in a physical page.


The 1 indicates that a page string needs to be appended before the page number in the heading.

0 indicates that only the page number is displayed.

EXTRAHDNGFONT font string 1, font string 2, ... font string n

The font strings are X Logical Font Descriptions. The token that separates the keyword EXTRAHDNGFONT from the comma-separated font name list is a quote " character, not a space or tab. These fonts are given preference over the built-in fonts when the heading is printed. Usually, EXTRABODYFONT is used to assign printer-resident fonts that are configured in the /usr/openwin/server/etc/XpConfig/C/print/models/<model name>/fonts directory.

The fonts.dir file contains the XLFD of the printer-resident fonts.

In the .xpr file, a font usually is specified as shown in the following example:

 "-monotype-Gill Sans-Regular-r-normal- -*-%d-*-*-p-0-iso8859-2" 

The %d, if present, is replaced by mp to the point size of the current heading fonts in the .xpr file. The x resolution and y resolution are specified by *. The average width field is set as 0 to indicate selection of a scalable font, if possible. You can also provide more specific font names.

EXTRABODYFONT font string 1, font string 2, ... font string n

The same as EXTRAHDNGFONT, except that these fonts are used to print the page body.

XDISPLACEMENT signed/unsigned int

Provides the x coordinate displacement to be applied to the page for shifting the contents of the page in the x direction. This displacement can be a +ve or -ve value.

YDISPLACEMENT signed/unsigned int

The same as x displacement, except that the shifting happens in the y direction.

These two keywords are useful when you deal with some printers that have nonstandard margin widths that require you to shift the printed contents in a page.


The keyword value pairs in this section are bound by STARTPAGE and ENDPAGE keywords. This section contains drawing and heading information that is to be applied for a physical page. A physical page can contain many logical pages, but all the drawing routines that are contained between these keywords are applied only once to a physical page.

The valid drawing entities are LINE and ARC. The XDrawLine() and XDrawArc() functions are executed on values of these keywords.

The dimensions within this section are mapped in PROLOGDPI units. Angles are in degrees.

LINE x1 y1 x2 y2

The x/y unsigned coordinates define a pair of points for connecting a line.

ARC x y width height angle1 angle2

x and y are both unsigned integers that represent the arc origin. Width and height are unsigned integers that represent the width and height of the arc.


Unsigned coordinates represent the position in which the user information is printed on the heading.


Unsigned coordinates represent the position in which the time for printing is printed on the heading.


Unsigned coordinates represent the position to print the page string for each printed page.


Unsigned coordinates represent the position to print the subject in the page.


When the -n option is given to mp, all the decorations given within a STARTPAGE/ENDPAGE section do not print. However, everything included within a STARTFORCEDPAGE/ENDFORCEDPAGE section prints even if the -n option is given.


All keywords are the same as described in STARTPAGE/ENDPAGE Keywords except that the entries in this section are applied NUMCOLS times to a physical page. If NUMCOLS is 3, then the printable area of the physical page is divided into three, and lines, arcs, or heading decorations appear three times per page.


When the -n option is given to mp, all the decorations given within a STARTCOLUMN/ENDCOLUMN section do not print. However, everything included within a STARTFORCEDCOLUMN/ENDFORCEDCOLUMN section prints even if the -n option is given.

Creating a New .xpr File

When you create a new .xpr prolog file, you specify only the values that differ from the default.

The following table lists the mp program defaults for different keywords if these values are not specified in the .xpr file for the STARTCOMMON/ENDCOMMON section:

Table 7–2 STARTCOMMON/ENDCOMMON Keyword Values


















135 280



No default values are needed for the other two sections bound by STARTPAGE/ENDPAGE and STARTCOLUMN/ENDCOLUMN.

To create a page with no decoration, use four logical pages per physical page in portrait format. Specify the following sections and values:

When you create a page with no decoration, you do not need to specify the following two sections:

These parameters are not needed if you are not putting decorations on the printed page. All the coordinates are in 300 dpi by default unless you are not specifying the PROLOGDPI keyword. If the target printer resolution is different, the .xpr file is scaled to fit into that resolution by the program.

Before you create an .xpr file, you must know the paper dimensions. For U.S. paper, 8.5x11 inches, for a printer of resolution 300 dpi, 2550X3300 are the total dimensions. Most printers cannot print from the top left corner of the paper. Instead, some margin space is assigned around the physical paper. Even if you try to print from 0,0 the printing will not be in the top left corner of the page. Consider this limitation when you create a new .xpr file.