IDAutomation.com, Inc.
Your Source for Quality Symbology
[IDAutomation.com Home Page]

# Code 128 for the Macintosh Technical Notes

This download package contains fonts for the Macintosh version of the Code 128 bar code fonts. These fonts allow printing of Code 128, UCC-128 and EAN-128 barcodes. Be aware that using Code 128 fonts on a Macintosh is a complicated process that is only recommended for advanced users and programmers. It is recommended that you use a Windows PC instead if it is possible.

## Overview:

Macintosh font files consist of resources stored in the resource fork of a file. Windows files contain only the data fork. To further complicate things, Macintosh files must also be given a file type and creator to allow them to show up on the desktop with the proper icons, and to tell the Macintosh operating system what type of files they are.

## Usage Procedure:

## Step 1: Install the fonts

### Macintosh font installation overview

This TrueType version is formatted for the Macintosh computer in MacBinary format. This encodes both resource and data forks into one file so it can be encoded in a ZIP file. Using this file on a MAC is a two step process:

1. Expand the ZIP file: After the distribution file (which is in ZIP format) is copied to a folder on the MAC it must be expanded or decompressed so you can see all the font files in the distribution package.
2. Decode the MacBinary font file: Within the distribution file, the individual font file you wish to use must be decoded and then copied into the system fonts folder. There are several MAC programs that can open ZIP files and decode MacBinary files. In our example below, we use Stuffit Expander available from Aladdin Systems.

### To install the font on the Macintosh:

1. We suggest you use the TrueType fonts if possible. The TrueType fonts end in ".MTT".
2. Download and install Stuffit Expander on your Macintosh if you do not have an expander utility that can open ZIP files and decode MacBinary files.
3. Open the ZIP distribution file that contains the fonts by dragging the ZIP file on the Stuffit Expander icon. The font files will be extracted from the ZIP distribution file and will appear in a subfolder of the folder you placed the ZIP file in. Open this subfolder to view the MacBinary font files. At this point, you may want to view the documentation supplied with the font files. To do so just drag the Readme.htm file to the Netscape or Internet Explorer icon.
4. Now we must decode the files from MacBinary format. Drag the font files that you wish to use to the Stuffit Expander icon.
5. Drag the decoded font files to the System folder.
6. Restart the application you wish to use the font with - some applications require you to restart the computer.
7. The font should now be active in the font menu of your application.
8. To create the correct output for the font, you will need to choose the font in your application and type in the corresponding letter.

## Step 2: Format the barcode

After the fonts are installed, the appropriate start, stop and check characters must be added to create a scanable barcode. Refer to the Code 128 Font Data Sheet for information on performing these calculations or writing an application to perform them for you. Note that on the Macintosh, the characters in the "char" column are different for ASCII 0195 to 0206 because the Macintosh uses different character encoding. To print these from a Macintosh, you will need to create an application that prints the characters from their UNICODE or ASCII locations.

Customers have successfully implemented our fonts on the Macintosh platform by using ATSUI. Our fonts contain the UNICODE 2.0 support and proper Apple name mappings that ATSUI requires. If problems are encountered with ATSUI, we recommend obtaining the AAT Font Tool from Apple's website. When converting our fonts with the AAT Font Tool, please be aware that the only option you should have selected is "Add a Unicode 2.0 'cmap' table".

The following is sample source code for character set C written for Omnis 4GL:

    ##### Method 'Code128c' #####
    No. Parameter Type Subtype Init.Val/Calc
    1 pvInNumber Number 0 dp

    No. Local Variable Type Subtype Init.Val/Calc
    1 lvC128startVal Short integer (0 to 255) 105
    2 lvC128stop Short integer (0 to 255) 206
    3 lvCheckChar Character 10000000
    4 lvCheckSum Long integer
    5 lvInString Character 256
    6 lvOutString Character 100
    7 lvPairNo Short integer (0 to 255)
    8 lvPairVal Short integer (0 to 255)
    9 lvPosn Short integer (0 to 255)

    No. Method text
    1 Calculate lvInString as pvInNumber
    2 If not(isnumber(lvInString))
    3 OK message Code128c Translation (Sound bell) {Input parameter ([pvInNumber]) is not a number.}
    4 Quit method ''
    5 End If
    6 If mod(len(lvInString),2)=1
    7 Calculate lvInString as con('0',lvInString)
    8 End If
    9
    10 Calculate lvCheckSum as lvC128startVal
    11 Calculate lvPairNo as 0
    12
    13 For lvPosn from 1 to len(pvInNumber) step 2
    14 Calculate lvPairNo as lvPairNo+1
    15 Calculate lvPairVal as eval(mid(lvInString,lvPosn,2))
    16 Calculate lvCheckSum as lvCheckSum+(lvPairNo*lvPairVal)
    17 If lvPairVal>0&lvPairVal<95
    18 Calculate lvOutString as con(lvOutString,chr(lvPairVal+32))
    19 Else If lvPairVal>=95
    20 Calculate lvOutString as con(lvOutString,chr(lvPairVal+100))
    21 Else If lvPairVal=0
    22 Calculate lvOutString as con(lvOutString,chr(194))
    23 End If
    24 End For
    25
    26 Calculate lvCheckSum as mod(lvCheckSum,103)
    27 If lvCheckSum>0&lvCheckSum<95
    28 Calculate lvCheckChar as chr(lvCheckSum+32)
    29 Else If lvCheckSum>=95
    30 Calculate lvCheckChar as chr(lvCheckSum+100)
    31 Else If lvCheckSum=0
    32 Calculate lvCheckChar as chr(194)
    33 End If
    34
    35 Calculate lvOutString as con(chr(lvC128startVal+100),lvOutString,lvCheckChar,chr(lvC128stop))
    36 Quit method lvOutString

NOTE: The code example above is only sample code. We cannot provide consulting services to help you with your source code; we can only support the font itself.

Copyright © 1999-2001 IDAutomation.com, Inc. All trademarks are the property of their respective owners.