Tags:
create new tag
view all tags

Defining Custom Fonts

How to use custom fonts in PDF outputs

Disclaimer: While these steps work in most cases this implementation of custom fonts is not supported in APPX (not in 4.x or 5.x). Appx can use vector-based TrueType fonts, but not those based on bitmaps.


Overview

When designing graphical images in APPX there are 9 fonts pre-configured with the Desktop Client that are part of the Java installation within the client. In order to use custom fonts not included with the installation, such as bar codes, there are a few steps that must be taken. Follow these steps and you should be able to make use of custom fonts on your PDF outputs. Again, Appx can use vector-based TrueType fonts, but not those based on bitmaps.

Custom Fonts on a Windows Server

There are two ways to install and use a font on a Windows Server

Install as Windows Font

The easiest way to include a custom font is to install the font on your Windows server. The steps to install the font will be different depending on the desktop OS release. The steps below are for Windows XP Professional.

  • Save the font to somewhere on your APPX server
  • Open the Windows Control Panel
  • Open the Fonts folder
  • From the File menu, choose "Install New Font..."
  • Use the Add Fonts selector to find the font
  • Click on OK. This will install the font.
  • Reboot the server!! The font might not be recognized by the PDF printing software until after a reboot.
On more recent versions of Windows, you may be able to simply double click the font file. This will display the font, and there will be an 'Install' button to install the font.

After you have installed a font you must tell Appx the name of the font, not the name of the font file. For example, the "Free 3 of 9" font is distributed in a file named "free3of9.ttf", but the name of the font is actually "Free 3 of 9 Regular". (you can also use "Free 3 of 9"). To find the font name, open the font file (free3of9.ttf) with Font Viewer (the easiest way to do that is to simply double-click on the font file in the Windows file manager).

  • Log into APPX and select Application Design for the app you where you will be using the custom font.
  • Select Named Resources and define a resource with:
    • Select the FONT state. If you are using Appx 5.1 or older, choose ROLLOVER SELECTED instead.
    • Set the Location Type to SERVER FILE
    • Enter the font name (not the .ttf file name) as the Location Data (Free 3 of 9 Regular, for example). Important: The font name is cached in your session. If you need to correct the name, log off & on again so Appx will pick up the new name.

Install Font in a Folder

Alternatively, you can install the font in a folder of your choosing, then tell the PDF printing software where to find the font. You will need to add an entry to the Windows registry which will provide a search path that APPX will use to find your font files. You can download one of the attached files at the bottom of the page (either 32 bit or 64 bit depending on your Windows version), edit the path and then simply double click the file to install the change in your registry.

You can also use the following steps to manually change the registry:

On your APPX server, open a command prompt or Run dialog box and run regedit (be very, very careful when editing the Windows registry as mistakes can possibly disable your computer)

  • Navigate to HKEY_LOCAL_MACHINE\SOFTWARE for 32 bit Windows, or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ for 64 bit Windows
  • Add new keys for PDFlib\PDFlib\7.0.3
  • Add a new string named searchpath
  • Double-click searchpath and enter the path to the directory where you placed the font file. Multiple directories can be entered by separating them with a semicolon.
  • Exit regedit
You will also need to define a Named Resource for each font file with the following attributes:
  • Select the FONT state. If you are using Appx 5.1 or earlier, choose ROLLOVER SELECTED instead.
  • Set the Location Type to SERVER FILE
  • Enter the name of the font file without an extension in the Location Data field. Important: The font name is cached in your session. If you need to correct the name, log off & on again so Appx will pick up the new name.

Custom Fonts on a Unix or Linux Server

Follow these instructions to install a custom font. This should also work in APPX 4.2.x. This example will refer to the Free3of9.ttf bar code font.

  • Place the font file (Free3of9.ttf) in the Resource directory for one of your applications.
  • Log into APPX and select Application Design for the app you where you will be using the custom font.
  • Select Named Resources and define a resource with:
    • Select the FONT state. If you are using Appx 5.1 or earlier, choose ROLLOVER SELECTED instead.
    • Set the Location Type to DESIGN FILE
    • Enter the font file name without the extension as the Location Data (free3of9, for example). Remember that file names are case sensitive. The font name is cached in your session. If you need to correct the name, log off & on again so Appx will pick up the new name.

Install Font in a Folder (Platform Independent)

An alternative mechanism is to create a PDFlib resource file that defines the searchpath. You can use this approach on either Windows or Linux. Here is a sample file:

PS-Resources-1.0

.

SearchPath

C:\MyCustomFonts

.

The file must begin with a line that says: PS-Resources-1.0, followed by line containing a single period.

Then, each section begins with a resource name (in this case, SearchPath), followed by the values assigned to that resource (For example, C:\MyCustomFonts for Windows platforms, or /tmp/myfonts for Linux), and the section is terminated with a line containing only a period.

The format of the resource file (along with a list of the resources you can define) is described in section 3.1.3 here: http://www.pdflib.com/fileadmin/pdflib/pdf/manuals/PDFlib-7-tutorial.pdf

This file can be placed anywhere you like, and you must define the environment variable PDFLIBRESOURCEFILE to point at that file. We recommend setting the environment variable in the appx.env file.

You will also need to define a Named Resource for each font file with the following attributes:

  • Select the FONT state. If you are using Appx 5.1 or earlier, choose ROLLOVER SELECTED instead.
  • Set the Location Type to SERVER FILE
  • Enter the name of the font file without an extension in the Location Data field. Important: The font name is case sensitive on Linux platforms, and it is cached in your session. If you need to correct the name, log off & on again so Appx will pick up the new name.

Using the Font in Appx

  • On your image define a field and set these GUI Attributes:
    • Select the Control Type of Label
    • In Resource enter the application and name you set in the above step
    • Leave the Font blank
    • Enter a name in the Name field ( VENDOR BAR CODE in this example)
  • In the Pre-Display event point enter the following code:
      SET      --- WIDGET NAME                =      VENDOR BAR CODE
      READ     --- WIDGET                 HOLD 1 FT 0 BY WIDGET NAME
T     SET      --- II                         =      10
T     SET      --- WIDGET FONT                =  --- II
T     REWRITE  --- WIDGET                 FAIL 0

The font will be embedded in the PDF document so the custom font should be viewable and printable on all systems whether the font is installed on the system or not.

PDF Debug Logging

If you are having trouble getting a custom font to print you can gather debugging information by setting the following environment variable prior to starting an APPX session:

Windows example; copy this to appx.env before invoking Appx;

PDFLIBLOGGING=filename=c:\pdf.log enable remove classes={filesearch=9 api=2 resource=9}

"enable" means that you want to enable logging
"remove" means that you want PDFlib to remove any log file (of the same name) before starting
The "classes" clause specifies the information you want to log (and the level of detail for each category)

It would be helpful to include the log generated by this process when reporting PDF output issues.

If the log shows that PDFlib is unable to find your installed font, try rebooting the server.

Comments:

Read what other users have said about this page or add your own comments.


Here is a sample. APPX 5.4.5 on Linux.

[appx@rhel7server data]$ 
[appx@rhel7server data]$ grep pdflib /usr/local/appx/data/appx.env
PDFLIBRESOURCEFILE=/usr/local/appx/data/pdflib.upr
PDFLIBLOGGING=filename=/tmp/pdflibdebug.txt enable remove classes={filesearch=9 api=2 resource=9}
[appx@rhel7server data]$ 
[appx@rhel7server data]$ cat /usr/local/appx/data/pdflib.upr
PS-Resources-1.0
.
SearchPath
/usr/local/appx/data/fonts
.
FontOutline
3 of 9 Barcode=3of9_new.ttf
Free 3 of 9 Extended=fre3of9x.ttf
Free 3 of 9=free3of9.ttf
IDAutomationHC39M=hc39m.ttf
.
[appx@rhel7server data]$ 
[appx@rhel7server data]$ ls -1 /usr/local/appx/data/fonts
3of9_new.ttf
fre3of9x.ttf
free3of9.ttf
hc39m.ttf
[appx@rhel7server data]$ 

-- Joe Ortagus - 2017-07-13

-- GaryRogers - 2010-06-01

Topic attachments
I Attachment History Action Size Date Who Comment
Registry filereg pdflib32.reg r1 manage 0.3 K 2014-06-11 - 16:25 JeanNeron Registry file for 32 bit Windows
Registry filereg pdflib64.reg r1 manage 0.3 K 2014-06-11 - 16:26 JeanNeron Registry file for 64 bit Windows
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r20 - 2017-07-13 - JoeOrtagus
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback