Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / font

Barcode 39 without images

5.00/5 (5 votes)
21 Apr 2014Public Domain3 min read 19K   563  
A short description of the Code 39 Barcode font by Matthew Welch (and how to use it)

Introduction

Sometimes the forums give me great ideas for write-ups which may be interesting to a lot of people. One forum thread, started by our very own OriginalGriff brought something to my attention: Often people think that it is only possible to use generated images to create or display barcodes. Some members replied to OG's post, stating that there are in fact fonts to display the barcode equivalent of a string (which is pretty awesome, you don't need to store any images to display a barcode).
I did a quick googling on that topic and found the Code 39 Barcode Font, introduced back in 1997 by Matthew Welch. Matthew was kind enough to leave his font in the public domain, allowing an unrestricted use of it to all of us!

Background

The Code 39 font is a True Type font, meaning that it is available for all major browsers, programs and operating systems. "True Type" is a font standard to display fonts on screens and printers. The standard is integrated with Microsoft Windows and MacOS and available in Linux/Unix Environments under the name "FreeType". In difference to Bitmap-Based fonts, True Type fonts are based on vector graphics. The original True Type formate was introduced by the Apple Lead Engineer Sampo Kaasila, even though it was called "Bass" at first. True Type fonts were available within Windows since Windows 3.1, Apple introduced them a bit earlier in System 7.

Using the font within HTML

Modern browsers support True Type fonts embedded in the HTML, e.g. you can even use the Code 39 font within your HTML page (and with HTML I'm also referring to PHP, ASP.Net and all the other Web technologies). w3schools.com lists the browsers which support True Type fonts, currently all modern browsers support them (IE was a bit late to the party, versions before IE 9 do not support TTFs).
Whatsoever, to use a true type font within your HTML page you can simply use CSS3:

CSS
@font-face
{
   font-family:Code39;
   src:url(free3of9.ttf);
}

.barcode
{
   font-family:Code39;
}

If you now set a Textbox' CSS class to "barcode", the text you set to it will be displayed as 3 of 9 Barcode.

Using the font with Desktop applications

Most of the common Desktop developmente frameworks (Qt, Java and .Net) use the fonts installed on then system. To install a True Type font to your system, just double-click the the font file (the one with the *.ttf extension) and then click on "Install" in the newly opened Window. After you have installed the font you can set it as font for your control in the Desing mode of your IDE. Please remember that you have to deploy and install the font with your program if you are using it within.

Thanks

A big "Thank you!" goes out to Matthew Welch who developed the Code39 font and made it available to the public domain. If you decided to use his font, drop him an email at matt@squaregear.net to thank him.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication