Contenues dansTrouver plus de documentationRessources d'assistance comprises | Télécharger cet ouvrage au format PDF (3243 Ko)
Chapter 7 Print Filter Enhancement With mpThis chapter describes print enhancement to the mp utility. The chapter discusses the following topics: Printing for UTF-8An enhanced mp print filter that can print various input file formats including flat text files written in UTF-8 is available in the current Solaris environment. This print filter uses TrueType and Type 1 scalable fonts and X11 bitmap fonts available on the 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 PostScriptTM 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 OverviewThe mp print filter is enhanced in the current 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.confIf 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 FilesThe /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) ClientUsing 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 FileConfiguration 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 AliasingThe 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
FontNameAlias prnHelveticaR Type1 Helvetica Font Group DefinitionYou can combine same-type fonts to form a font group. The format of the font group is as follows:
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 SectionThe 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.
Association SectionThe 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:
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 Solaris environment obey these restrictions, you can map all TrueType fonts in 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
How to Add a Printer-Resident FontThe 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.
How to Create a Shared Object FileThe examples in the following procedure how you how to create shared object files.
You can find a sample mp.conf file in the /usr/lib/lp/locale/en_US.UTF-8/mp directory. Adding and Customizing prolog FilesThe prolog files can be divided into two main categories:
PostScript File CustomizationThe PostScript files fall into the following categories:
Locale-Dependent prolog FilesThe purpose of the prolog.ps 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 Solaris localization kit provides a sample prolog.ps 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 prolog.ps 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 prolog.ps file is to study the example version. In the example prolog.ps, 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 prolog.ps file support is reserved for backward compatibility only. Do not create a new prolog.ps file for generating printed output for a locale. Use mp.conf instead. The path for prolog.ps file is /usr/openwin/lib/locale/$LANG/print/prolog.ps Common PostScript prolog FilesThe common prolog file is mp.common.ps. Every other page layout prolog file needs to include this file. The mp.common.ps 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 FilesThe 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 following functions are implemented in print layout prolog files. All of these functions can use subfunctions.
To add new print layout prolog files, you need to define the following variables explicitly within the print layout prolog file:
.xpr FilesThese files are located by default at /usr/lib/lp/locale/C/mp/. An .xpr file corresponds to each PostScript prolog layout file except the mp.common.ps 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. STARTCOMMON/ENDCOMMON KeywordsAll 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.
STARTPAGE/ENDPAGE KeywordsThe 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.
STARTFORCEDPAGE/ENDFORCEDPAGE SectionWhen 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. STARTCOLUMN/ENDCOLUMN SectionAll 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. STARTFORCEDCOLUMN/ENDFORCEDCOLUMN SectionWhen 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 FileWhen 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
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. |
||||||||||||||||||||||||||||||||||