International Language Environments Guide

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 prolog.ps file is present in either of the/usr/openwin/lib/locale/$LANG/print or /usr/lib/lp/locale/$LANG/mp directories. The prolog.ps file forces mp to print using PostScript embedded fonts in the file. Even if a prolog.ps exists in a locale, using the -M option ignores the prolog.ps 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/prolog.ps exists, then the prolog.ps 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 prolog.ps 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 			
font-alias-name

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.

font-type

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.

font-path

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:

keyword

FontGroup.

fontgroupname

The group name for the fonts.

GroupType

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

Roman

The Roman font name in the font group.

Bold

The Bold font name in the font group.

Italic

The Italic font name in the font group.

BoldItalic

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.

keyword

MapCode2Font.

range_start

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

range_end

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.

group

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:

keyword

CnvCode2Font.

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:

-monotype-arial-bold-r-normal-bitmap-10-100-75-75-p-54-iso8859-8

The corresponding PCF font is:

/usr/openwin/lib/locale/iso_8859_8/X11/fonts/75dpi/ariabd10.pcf.Z

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:

-monotype-arial-medium-r-normal--0-0-0-0-p-0-iso8859-8

has the corresponding font:

/usr/openwin/lib/locale/iso_8859_8/X11/fonts/TrueType/arial__h.ttf

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 

Default 

Orientation

ORIENTATION_LTR/

ORIENTATION_RTL/

ORIENTATION_CONTEXTUAL

ORIENTATION_LTR

Numerals

NUMERALS_NOMINAL/

NUMERALS_NATIONAL/

NUMERALS_CONTEXTUAL

NUMERALS_NOMINAL

TextShaping

TEXT_SHAPED/

TEXT_NOMINAL/

TEXT_SHFORM1/

TEXT_SHFORM2/

TEXT_SHFORM3/

TEXT_SHFORM4

TEXT_SHAPED

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/xuiso88591.so
    CnvCode2Font iso88591B _xuiso88591 /usr/lib/lp/locale/$LANG/mp/xuiso88591.so

    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) {
                     return(ucs2);
             }
    1. Save the mapping to the ttfjis0201.c file.

    2. Create a shared object file.

      cc -G -Kpic -o ttfjis0201.so 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.

    -sun-gothic-medium-r-normal--22-200-75-75-c-100-jisx0201.1976-0
    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 ftp.unicode.org/pub/MAPPINGS/ directory.

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

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

      cc  -G -o xu2jis0201.so 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 xu2jis0201.so 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/prolog.ps file to create output in the current locale. When you use the prolog.ps 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.