Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Print Filter Enhancement With mp mp Print Filter Enhancement Overview Localization of the Configuration File  Previous   Contents   Next 
   
 

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 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 given the alias name iso88591R.

font-type

Specify 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

Give the absolute path name for the font files here. 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/news articles, for example. If only the Roman font is defined, it 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. Each line in this section is as follows.

keyword

MapCode2Font.

range_start

A 4-byte hexadecimal value that starts with 0x, that indicates the start of the code range to map to one or more font group.

range_end

Indicates the end of the code range to map. It can be '-' in which case 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 fonts encoding. 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 fonts 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 find out the intermediate codeset for EUC locales.


Note - The current TrueType engine used by mp (1) can deal only with format 4 and PlatformID 3 cmap. That is, 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.


When you create a shared object for mapping a font that corresponds to a PCF type1 X Logical Fonts Description (XLFD), then create the 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 isoISO 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 has the keyboard value is PLSOutput, that value is ignored and the mp(1) 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

Adding a Printer-resident Font

The following example illustrates the steps that you need to follow when you add a new PCF, TrueType, or Type1 printer-resident font to the configuration file.

Replace the font for displaying characters in the range 0x00000021 - 0x0000007f with a TrueType font instead of the currently configured PCF font.

Before adding a new font, look at various components in the configuration file that correspond to the currently configured font, as shown next.

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

Suppose you selected /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-MinchoL.ttf as your candidate for doing the mapping in the en_US.UTF-8 locale. Because this is a Unicode character-mapped TrueType font file, in the mapping function within the .so module you only need to have a function that directly returns the incoming ucs-2 code points.

unsigned short _ttfjis0201(unsigned short ucs2) {
                 return(ucs2);
         }

Save this in a ttfjis0201.c file. Create a shared object as follows.

cc -G -Kpic -o ttfjis0201.so ttfjis0201.c

But if you are mapping a PCF file, such as /usr/openwin/lib/locale/ja/X11/fonts/75dpi/gotmrk20.pcf.Z, then look in the fonts.dir file in the /usr/openwin/lib/locale/ja/X11/fonts/75dpi/ directory. Become familiar with the encoding, corresponding to XLFD, which is:

-sun-gothic-medium-r-normal--22-200-75-75-c-100-jisx0201.1976-0

If jisx0201 is the encoding, prepare a shared object that maps from ucs-2 to jisx0201. You need to obtain the mapping table for creating the .so module (if one is not already provided). For a Unicode locale, find the mappings from the many charsets to Unicode under ftp.unicode.org/pub/MAPPINGS/. Follow these mappings(1)(1) in order 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);
                 }
 
 
 
  Previous   Contents   Next