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. Some of our Font Automation Tools such as FileMaker Plugins, 4D Source Code and VBA for Microsoft Excel and Access allow cross-platform use of the code 128 fonts on the MAC and PC. If you cannot use one of these tools and you do not intend to write an application to format the font data, 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 correct barcode. Refer to the Code 128 Font Data Sheet for information on performing these calculations or writing an application to perform them for you. To print code 128 from a Macintosh, you will need to create an application that prints the characters from their MAC ASCII locations. See source code below.

Code A Code B Code C ASCII * Unicode * MAC
ASCII
Value     Code A Code B Code C ASCII * Unicode * MAC
ASCII
Value
Space Space 00  0194 00C2  133 00   V V 54 0086 0056 086 54
! ! 01 0033 0021 033 01   W W 55 0087 0057 087 55
" " 02 0034 0022 034 02   X X 56 0088 0058 088 56
# # 03 0035 0023 035 03   Y Y 57 0089 0059 089 57
$ $ 04 0036 0024 036 04   Z Z 58 0090 005A 090 58
% % 05 0037 0025 037 05   [ [ 59 0091 005B 091 59
& & 06 0038 0026 038 06   \ \ 60 0092 005C 092 60
' ' 07 0039 0027 039 07   ] ] 61 0093 005D 093 61
( ( 08 0040 0028 040 08   ^ ^ 62 0094 005E 094 62
) ) 09 0041 0029 041 09   _ _ 63 0095 005F 095 63
* * 10 0042 002A 042 10   nul ` 64 0096 0060 096 64
+ + 11 0043 002B 043 11   soh a 65 0097 0061 097 65
, , 12 0044 002C 044 12   stx b 66 0098 0062 098 66
- - 13 0045 002D 045 13   etx c 67 0099 0063 099 67
. . 14 0046 002E 046 14   eot d 68 0100 0064 100 68
/ / 15 0047 002F 047 15   eno e 69 0101 0065 101 69
0 0 16 0048 0030 048 16   ack f 70 0102 0066 102 70
1 1 17 0049 0031 049 17   bel g 71 0103 0067 103 71
2 2 18 0050 0032 050 18   bs h 72 0104 0068 104 72
3 3 19 0051 0033 051 19   ht i 73 0105 0069 105 73
4 4 20 0052 0034 052 20   lf j 74 0106 006A 106 74
5 5 21 0053 0035 053 21   vt k 75 0107 006B 107 75
6 6 22 0054 0036 054 22   ff l 76 0108 006C 108 76
7 7 23 0055 0037 055 23   cr m 77 0109 006D 109 77
8 8 24 0056 0038 056 24   s0 n 78 0110 006E 110 78
9 9 25 0057 0039 057 25   s1 o 79 0111 006F 111 79
: : 26 0058 003A 058 26   dle p 80 0112 0070 112 80
; ; 27 0059 003B 059 27   dc1 q 81 0113 0071 113 81
< < 28 0060 003C 060 28   dc2 r 82 0114 0072 114 82
= = 29 0061 003D 061 29   dc3 s 83 0115 0073 115 83
> > 30 0062 003E 062 30   dc4 t 84 0116 0074 116 84
? ? 31 0063 003F 063 31   nak u 85 0117 0075 117 85
@ @ 32 0064 0040 064 32   syn v 86 0118 0076 118 86
A A 33 0065 0041 065 33   etb w 87 0119 0077 119 87
B B 34 0066 0042 066 34   can x 88 0120 0078 120 88
C C 35 0067 0043 067 35   em y 89 0121 0079 121 89
D D 36 0068 0044 068 36   sub z 90 0122 007A 122 90
E E 37 0069 0045 069 37   esc { 91 0123 007B 123 91
F F 38 0070 0046 070 38   fs | 92 0124 007C 124 92
G G 39 0071 0047 071 39   gs } 93 0125 007D 125 93
H H 40 0072 0048 072 40   rs ~ 94 0126 007E 126 94
I I 41 0073 0049 073 41   us del 95 0195 00C3 134 95
J J 42 0074 004A 074 42   fnc 3 fnc 3 96 0196 00C4 135 96
K K 43 0075 004B 075 43   fnc 2 fnc2 97 0197 00C5 136 97
L L 44 0076 004C 076 44   Shift Shift 98 0198 00C6 137 98
M M 45 0077 004D 077 45   code C code C 99 0199 00C7 138 99
N N 46 0078 004E 078 46   code B fnc 4 code B 0200 00C8 139 100
O O 47 0079 004F 079 47   fnc 4 code A code A 0201 00C9 140 101
P P 48 0080 0050 080 48   fnc 1 fnc 1 fnc 1 0202 00CA 141 102
Q Q 49 0081 0051 081 49   Start A Start A Start A 0203 00CB 142 103
R R 50 0082 0052 082 50   Start B Start B Start B 0204 00CC 143 104
S S 51 0083 0053 083 51   Start C Start C Start C 0205 00CD 144 105
T T 52 0084 0054 084 52   Stop Stop Stop 0206 00CE 145 na
U U 53 0085 0055 085 53                

NOTE:

* It is necessary to print the Code 128 space character from ASCII 194 instead of ASCII 32 because Windows cannot print a symbol instead of a space character from Visual Basic and most other development environments.

* Alternate ASCII locations are present for the Macintosh fonts for the stop character, character value 00, and 95 to 105 because the Macintosh does not encode extended characters in the same way that Windows and UNIX systems do.

* Some of the ASCII and Unicode values in this chart are unique to our Code 128 Fonts, ActiveX Controls and Java Barcode Packages. The ISO specification for Code 128 does not specify the location of ASCII and Unicode values for the symbols.


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.