Troubleshooting Guide for Font Aliasing / Font Subsetting / Font Embedding Issues

Troubleshooting Guide for Font Aliasing / Font Subsetting / Font Embedding Issues

Troubleshooting Guide for Font Aliasing / Font Subsetting / Font Embedding Issues

Titleimage

Posted by Patrick Hamou on 2016:04:19 18:21:24

Introduction

APPLIES TO:

Oracle Reports Developer - Version 9.0.2.0 and later
Information in this document applies to any platform.
***Checked for relevance on 02-Jul-2013***

Purpose

The purpose of this document is to give some tips / hints to solve Font aliasing / Font Subsetting / Font embedding issues. 

Remark: This note is related to a "Postscript Printer" environment (Font Metric information found in AFM files).

Oracle Reports 11g Release 1 (11.1.1) uses a new font model that supports the TTF and TTC font types on UNIX platforms.
This document does not cover the "new font model"

http://docs.oracle.com/cd/E12839_01/bi.1111/b32121/pbr_xplat002.htm

The location of some files has changed in the version 11g. For more details, refer to the document :
Doc ID 1083666.1 Location Of Different Reports Configuration Files in Fusion Middleware Forms and Reports 11.1.1.1 and 11.1.1.2 Installations 

Why Font aliasing ?

In order to be able to format the output, Reports MUST have access to Font Metric information (AFM files for a "Postscript Printer" environment).  

If "Font Metric" information is not available for a Font used in a report, Reports will "alias" this font with another Font for which Font Metric Information is available.

The file uifont.ali may be used to give "directives" for the font aliasing.

If there are no directives for a Font or if the directives cannot be used, Oracle Reports will look for the nearest matching font under the same character set which can be used instead.

This problem may occur when you develop your reports on a given platform type (Windows) and deploy it on another platform type (UNIX).

For more details about Font management in Reports :

Oracle Application Server Reports Services Publishing Reports to the Web 10g Release 2 (10.1.2) 
B14048-02
4 Managing Fonts in Oracle Reports

Validate the files used by the Font aliasing

The first step in debugging a Font aliasing issue is to verify the files used by Reports: 
uifont.ali / uiprint.txt / PPD files / AFM files

Errors in these files may lead to problems during Font Aliasing without giving any error messages.

Validate the file uifont.ali

A utility is provided in the directory /bin to check the file uifont.ali:

UNIX: mfontchk90 (Reports 9.0.x), mfontchk (Reports 10.1.2.x / 11.1.1.x)
Windows: fnchk90 (Reports 9.0.x), fnchk (Reports 10.1.2.x / 11.1.1.x)

If you call this utility without any parameters, the "standard" uifont.ali will be validated.

Example on UNIX :

mfontchk 
 Parsing font alias file "/oracle/oas1012/midtier/guicommon/tk/admin/uifont.ali"
 Successfully parsed font alias file

Error Example :

>mfontchk
Parsing font alias file "/oracle/oas1012/midtier/guicommon/tk/admin/uifont.ali"
Courier New          = cour.ttf
       ^
Error at line 279: Invalid font specification
Parse of font alias file failed

 In this example, the font name Courier New must be enclosed between quotes:

"Courier New" = cour.ttf

Check the files AFM / PPD / uiprint.txt / uifont.ali

These files may have been modified on Windows and transferred to UNIX.  If they have been transferred in binary mode, some may be left in these files and will prevent the Font aliasing.
To check if have been left, use the UNIX utility 'od' with the option -a:
(According to the platform, the command can be od -a or od -t a )

cd $ORACLE_HOME/guicommon/tk/admin/AFM
   od -a * | grep -i cr    

   cd $ORACLE_HOME/guicommon/tk/admin/PPD
   od -a * | grep -i cr
   
   cd $ORACLE_HOME/guicommon/tk/admin
   od -a uiprint.txt | grep -i cr

 cd $ORACLE_HOME/guicommon/tk/admin 
   od -a uifont.ali | grep -i cr   

The command "od -a * | grep -i cr" should return no line. If lines are returned by the command "od -a * | grep -i cr ", you can use a script, like the example below, to find the file(s) containing the .

#!/bin/sh 
for fic in `ls *` 
do 
(od -a $fic | grep -i cr) && echo "File containing a Carriage Return: " $fic 
done

Note: The commands above are for Reports 10.1.2. For Reports 9.0.2 / 9.0.4, replace /guicommon/tk by /guicommon9/tk90.   

List of Fonts available in the "Postscript Printer" environment

In the PPD file, the AFM files associated to the PPD are listed under:

*% Font Information =====================

For example:

*% Font Information =====================
*DefaultFont: Courier
*Font Courier: Standard "(001.004)" Standard ROM
*Font Courier-Bold: Standard "(001.001)" Standard ROM
*Font Courier-BoldOblique: Standard "(001.001)" Standard ROM
*Font Courier-Oblique: Standard "(001.001)" Standard ROM
*Font Helvetica: Standard "(001.001)" Standard ROM
*Font Helvetica-Bold: Standard "(001.001)" Standard ROM
*Font Helvetica-BoldOblique: Standard "(001.001)" Standard ROM
*Font Helvetica-Oblique: Standard "(001.001)" Standard ROM
*Font Symbol: Special "(001.001)" Special ROM
*Font Times-Bold: Standard "(001.001)" Standard ROM
*Font Times-BoldItalic: Standard "(001.001)" Standard ROM
*Font Times-Italic: Standard "(001.001)" Standard ROM
*Font Times-Roman: Standard "(001.001)" Standard ROM

The AFM files must exist in the AFM directory (/guicommon/tk/admin/AFM by default), else a warning message is returned by rwrun.sh.

For example : 
Given the following line has been added in the PPD file:

*Font NotExist: Standard "(V.2)" Standard ROM

As the file NotExist does not exist in the directory /guicommon/tk/admin/AFM, the following message is displayed when launching rwrun.sh:

Can't open AFM file(s):
    NotExist

The font name used by Reports for an AFM file is the Font name specified in the attribute "FamilyName".

For example:

FamilyName Helvetica

Build a very simple report to debug the Font aliasing issue

t is always easier to work with a report using only one Font. To more easily debug any Font aliasing problems, create a simple new report for the debugging which has: 

     - No SQL Query.
     - Just a boilerplate text in the Paper Layout.
     - Set the boilerplate text Font to the Font you want to test.

Use your "private" environment for the tests

It is possible to test with "private" AFM / PPD / uifont.ali and uiprint.txt files, instead of using the files in the default location of $ORACLE_HOME/guicommon/tk/admin.

You can modify any "private" file without any impact on the Reports Server.
 
Directory and environment variables to use to build a "private environment":

Reports 9.0.x
$ORACLE_HOME /guicommon9/tk90
Location of PPD files: TK90_PPD
Location of AFM files: TK90_AFM
Location of HPD files: TK90_HPD
Location of TFM files: TK90_TFM
Location of uifont.ali: TK90_FONTALIAS
Location of uiprint.txt: TK90_UNKNOWN

Reports 10.1.2.x / 11.1.1.x
$ORACLE_HOME/guicommon/tk
Location of PPD files: TK_PPD
Location of AFM files: TK_AFM
Location of HPD files: TK_HPD
Location of TFM files: TK_TFM
Location of uifont.ali: TK_FONTALIAS
Location of uiprint.txt: TK_UNKNOWN

Remark : These variables can be used only on UNIX platforms. On Windows the PPD/AFM/HPD/TFM directories do not exist and the file uiprint.txt does not exist.. To use another file uifont.ali than the default one on Windows, use the variable UI instead of TK_FONTALIAS

Steps to create your "private environment": 

# Create the directory testaliasing in $ORACLE_HOME/guicommon/tk  
#
cd $ORACLE_HOME/guicommon/tk
mkdir testaliasing
#
# Create the directories AFM and PPD in $ORACLE_HOME/guicommon/tk/testaliasing
#
cd $ORACLE_HOME/guicommon/tk/testaliasing
mkdir AFM
mkdir PPD   
#
# Copy the AFM files to your private directory:
#  
cp $ORACLE_HOME/guicommon/tk/admin/AFM/* $ORACLE_HOME/guicommon/tk/testaliasing/AFM
#      
# Copy the PPD files to your private directory: 
#    
cp $ORACLE_HOME/guicommon/tk/admin/PPD/* $ORACLE_HOME/guicommon/tk/testaliasing/PPD
#      
# Copy the files uiprint.txt and uifont.ali to your private directory: 
#
cp $ORACLE_HOME/guicommon/tk/admin/uiprint.txt $ORACLE_HOME/guicommon/tk/testaliasing
cp $ORACLE_HOME/guicommon/tk/admin/uifont.ali  $ORACLE_HOME/guicommon/tk/testaliasing
#            
# Copy the file reports.sh
#    
cp $ORACLE_HOME/bin/reports.sh $ORACLE_HOME/bin/ta_reports.sh 
#      
# Copy the file rwrun.sh
#    
cp $ORACLE_HOME/bin/rwrun.sh $ORACLE_HOME/bin/ta_rwrun.sh

Edit the file $ORACLE_HOME/bin/ta_rwrun.sh, and change the line:     

$ORACLE_HOME/bin/reports.sh

to:

$ORACLE_HOME/bin/ta_reports.sh

Edit the file $ORACLE_HOME/bin/ta_reports.sh, and add the following lines:

################### Reports Private Environment Variables #########################################
REPORTS_DEFAULT_DISPLAY=YES ; export REPORTS_DEFAULT_DISPLAY
TK_PPD=$ORACLE_HOME/guicommon/tk/testaliasing/PPD ; export TK_PPD
TK_AFM=$ORACLE_HOME/guicommon/tk/testaliasing/AFM ; export TK_AFM
TK_HPD=$ORACLE_HOME/guicommon/tk/testaliasing/HPD ; export TK_HPD
TK_TFM=$ORACLE_HOME/guicommon/tk/testaliasing/TFM ; export TK_TFM
TK_FONTALIAS=$ORACLE_HOME/guicommon/tk/testaliasing ; export TK_FONTALIAS
TK_UNKNOWN=$ORACLE_HOME/guicommon/tk/testaliasing ; export TK_UNKNOWN
REPORTS_PATH=$ORACLE_HOME/guicommon/tk/testaliasing:$REPORTS_PATH ; export REPORTS_PATH
TK_PRINTER=printer_ps ; export TK_PRINTER
TK_PRINT_STATUS=echo ; export TK_PRINT_STATUS

Remark: The printer printer_ps must be defined in the file $ORACLE_HOME/guicommon/tk/testaliasing/uiprint.txt:

printer_ps:postscript:2:Test PostScript Printer:default.ppd:

To use the "private" aliasing environment, execute the report with the script ta_rwrun.sh:

ta_rwrun.sh report=test destype=file desname=/tmp/test.html desformat=html

Check the Font name used in the RDF

To check what exact Font name is used in the report, you can search the XML version of your report. 

To generate the XML file, you can: 

- Save the RDF as XML using Reports Builder, 
or 
- Convert the RDF into XML.  Sample syntax: 
  rwconverter.sh stype=rdffile source=test.rdf dtype=xmlfile dest=test.xml      (UNIX) 
  rwconverter.exe stype=rdffile source=test.rdf dtype=xmlfile dest=test.xml     (Windows) 

Once you have the XML file, you search for the string "face=" in the XML file: 
   grep -i face= /tmp/myreport.xml          (UNIX) 

Example (UNIX): 

>rwconverter.sh  stype=rdffile source=test.rdf dtype=xmlfile dest=test.xml  batch=yes
  
   Report Builder: Release 10.1.2.0.2 - Production on Mon Dec 12 12:07:47 2005
   Copyright (c) 1982, 2005, Oracle.  All rights reserved.
   REP-25200: Converting 'test.rdf' to 'test.xml'...
  >grep -i face= test.xml
          <font face="Helvetica" size="14" bold="yes" italic="yes"/>
          <font face="Helvetica" size="12" bold="yes"/>
          <font face="Helvetica" size="12" bold="yes"/>
          <font face="Helvetica" size="12" bold="yes"/>
          <font face="Arial" size="12" bold="yes"/>
          <font face="Helvetica" size="36" bold="yes" italic="yes"/>
          <font face="Helvetica" size="20" bold="yes" textColor="gray64"/>
   >

Check the font used in the output after the "Font Aliasing"

The easiest way to check the Font name used in an output generated by Reports is to use DESFORMAT=HTML.
Since the HTML output is a text file, the Font name used can be easily found.
For example, execute the report with:

DESFORMAT=HTML
DESTYPE=FILE 
DESNAME=/tmp/test_aliasing.html

Check the font name used in the output by searching for the string "face=":

grep -i face= /tmp/font_aliasing.html

PDF Font aliasing

The Font name in PDF is case sensitive. In some cases, the Font name generated by Reports may be wrong.

Step 1) Check the Font name used in the PDF file by searching for the string "basefont":

grep -i basefont test.pdf

Example :

>grep -i basefont /tmp/test.pdf
/BaseFont /Helvetica-Bold
>

Step 2) Check the Font name used by Acrobat Reader to display the PDF document:
From Acrobat Reader 7.0

File -> Document Properties ...
Tab "Fonts"

Check the value of "Actual Font".

Step 3) If the Font name generated by Reports is not correct (Uppercase problem / Space in the font name is missing / ...), then you can use the [ PDF ] section in the uifont.ali file.

Example : [ PDF ]

fontname1 = FontName1
fontname2 = "Font Name 2"

Remarks : 
a) This [PDF] section is read after the "Font Aliasing". The font name, specified at the left of the equal sign, must be the font name after the "Font Aliasing" has occurred.
b) This section should be used ONLY to fix UpperCase / LowerCase / Space problems in the Font Name. It is possible to replace a font name with a totally different font; however, in this case, there may be truncation / overlapping problems in the output.
Example that may lead to truncation / overlapping problems:

[ PDF ] 
Arial = "Courier New"

With this setting, the report output will be formatted with the Arial Font metric information, but the Adobe Reader will use the font Courier New, which has totally different font metrics.

PDF Font Subsetting / Font Embedding issues

Font Subsetting or Font Embedding always occurs AFTER Font Aliasing . That's why it is important to first check the result of Font Aliasing. To do Font Subsetting or Font Embedding, you have to add a line in uifont.ali like:

Font Subsetting :

<font name>="<ttf filename>" in the section [ PDF:Subset ].

Windows Font Embedding :

<font name>="<pfm filename> <pfb filename>" in the section [ PDF:Embed ].

UNIX Font Embedding :

<font name>="<afm filename> <pfa filename>"  in the section [ PDF:Embed ].

The font name specified at the left of the equal sign is the font name AFTER "Font Aliasing" has occurred.  So, if the font chosen by Reports during the Font Aliasing is not the one specified at the left of the equal sign, then the Subsetting or Embedding will not take place. If you have problems with Font Subsetting or Font Embedding, generate a HTML output and check the font name used in the HTML file.

During Font Subsetting / Font Embedding , ttf / pfm /pfb / afm / pfa files are used. These files must be accessible to Reports (in REPORTS_PATH) and readable (Access rights on UNIX).  UNIX trace utilities, such as strace or truss, may be used to debug problems that you suspect to be access related.

Doc ID 110888.1 How to Trace Unix System Calls
Doc ID 882227.1 How to Know if Font Subsetting / Font Embedding Has Been Used by Oracle Reports when Generating a PDF output ?

Problems related to the Character Set

In order to check if the problem is related to the Character Set, always test generating an output with 
NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

If the problem does not occur when NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1, modify the AFM files as described in the following  note:
Doc ID 300416.1 Symbol Characters ("Greek") Instead Of Expected Characters Are Displayed in Reports or Reports Parameter Form

This Character Set  problem is also described in the document:
Oracle Application Server Reports Services Publishing Reports to the Web 10g Release 2 (10.1.2) B14048-02 
Repairing Garbled Fonts When Using the WE8ISO8859P15 Character Set

This problem may occur for character sets other than WEISO8859P15 (UTF8 , EE8ISO8859P2, ...).

Here is an example of script to modify the EncodingScheme value in the AFM files:

1) Create a new directory AFM2 under $ORACLE_HOME/guicommon/tk/admin    
2) Create the following script in the directory $ORACLE_HOME/guicommon/tk/admin/AFM

#!/bin/sh
    for filename in *
    do
        sed "s/EncodingScheme AdobeStandardEncoding/EncodingScheme FontSpecific/" $filename >  ../AFM2/$filename
    done

 3) Save the script and give execute permissions (In the example below, the script is called  change_encoding.sh):

chmod a+x change_encoding.sh

4) Execute the script  change_encoding.sh
    
5) Change the name of the directory AFM into AFM_backup :

cd $ORACLE_HOME/guicommon/tk/admin
mv AFM AFM_backup

6) Change the name of the directory AFM2 into AFM :

cd $ORACLE_HOME/guicommon/tk/admin
mv AFM2 AFM   

If you are using a "private environment", you can modify the AFM files in the directory specified in TK_AFM (TK90_AFM).
AFM files created by the utility ttf2pt1 have by default "EncodingScheme FontSpecific".

Posted by Patrick Hamou on 2016:04:19 18:21:24

Return to Blog