SyntaxHighlighter

Thursday, February 23, 2012

Solved problem with fonts in Oracle Reports 10g on Windows 2008 Server

Oracle Reports 10g
I have seen countless posts of people battling with fonts in Oracle Reports. I battled my Reports Server on Windows Server 2008 for two days trying to get the font to display. In the end, it turned out to be relatively simple, but not obvious. 

The trick with Oracle Reports fonts is to make sure that you have got the font names right in the font aliasing configuration file (uifont.ali). If you don't get the font names right, then the alias will not be used and your report will not use the correct font. Get the font names correct and the report will show as expected.

Century Gothic font selected in the Fonts Control Panel applet.
First things first... I have an Oracle Reports Server 10g running on a Windows 2008 Server and was attempting to run a report as PDF. The font that I was trying to get to work on this server was Century Gothic. The report engine decided not to use the Century Gothic font as specified in the report definition even though the font was already registered with Windows. 

To check if your font is installed on the server, navigate Windows Start->Control Panel, and select fonts. Search the fonts panel by name.

If the font is installed on the server and the report is still not using it, the reports server must be using another font in its place. You will have to use font aliasing to get your font to display properly. 

List of fonts used in PDF noting the presence
of the MSSansSerif font
In order to implement font aliasing properly, you will need to know the exact name of the font that the reports engine is replacing your font with. This can be done quite easily by running the report to PDF, opening the PDF file and navigating File->Properties from the Acrobat Reader menu to produce the Document Properties dialog. Then click on the fonts tab to view the list of fonts used in the document. In my case there were three fonts present: Courier; Helvetica; and MSSansSerif
Hint: write yourself a simple report to test with to limit the number of fonts.

In my case, I had three fonts present of which only the MSSansSerif was out of place. This would be the target of my font aliasing. This font must be aliased to Century Gothic in the uifont.ali. In addition, I wanted the Century Gothic font to be subset'd into the PDF.

To accomplish this I copied the Century Gothic font file into the path (D:\Documents\NPAS\reports\GOTHIC.TTF) that was in my REPORT_PATH environment variable (REPORT_PATH=D:\Documents\NPAS\reports). This allows the report engine to read the font file for use in the report. I then had to edit the uifont.ali file (located at ${ORACLE_HOME}\tools\common) and add the alias declaration under the [ PDF:Subset ] section.

And this is where the major hint comes in... Acrobat reader removes spaces from the names of the fonts. I am not sure if this is Acrobat readers fault, Oracle Reports fault, or just how its supposed to be, but, you can't just use the names as you see them in the font window as entries in the alias file. In my case Acrobat reported the font as MSSansSerif without the spaces. But the actual name should be MS Sans Serif as separate words. Using an alias of MSSansSerif did not work. It only worked once I used "MS Sans Serif". My final alias entry looked exactly like this:

"MS Sans Serif" = "GOTHIC.TTF"

Don't forget to restart your Oracle Reports Server component after modifying the uifont.ali file. The changes will only be read from the file after restarting the component. 

List of fonts used in PDF noting that the font is now reported as CenturyGothic
After restarting the Reports Server component and re-running the report, the Century Gothic font appeared correctly on screen. Also, viewing the fonts in Acrobat reader showed that the Century Gothic font was finally being applied. Note however, that Acrobat reader reports the font as CenturyGothic with no space between the words.
Post a Comment