[pstricks] [pst-barcode] How changing font ? And how using with it a certain PostScript font downloaded from the web ?

Michael Sharpe msharpe at ucsd.edu
Mon Dec 12 18:50:10 CET 2011


On Dec 11, 2011, at 5:45 PM, Quark67 wrote:

> Le 11 déc. 2011 à 18:43, Herbert Voss a écrit :
>> Am 11.12.2011 16:39, schrieb Quark67:
>> > Hello, the default font in the pst-barcode package is Helvetica. How can
>> > I change the font ?
>> > Yes, I see the pst-barcode-doc.pdf documentation, at section 2.2, I see
>> > the option :
>> >
>> > font /Helvetica must be a PostScript font
>> 
>> that is a default PostScript font and _always_ present.
>> You can use all PostScript fonts, like Times-Roman and so on.
>> This font is only for the optional text which can be
>> printed, but not for the barcode
>> 
> Yes, this is for optional text, for printing the digits of the barcode. But there is an error in the documentation, at section 2.2 :
> the correct option is not :
>> > font       /Helvetica                       must be a PostScript font
> but :
> 
> textfont      Helvetica (not a slash before it)
> 
>> > But most of EAN13 barcodes in real objects use the font "OCR-B". You can
>> > see 
>> http://en.wikipedia.org/wiki/OCR-B
>>  but the sample of the font is not
>> > very correct. For better sample of the font, you can use the LaTeX
>> > package ocr (but this use bitmap fonts) or download a free PostScript
>> > (.pfb and .afm files), TrueType (.ttf file) and OpenType (.otf file)
>> > version of the OCR-B font, made by Matthew Skala from the ocr package,
>> > at the web page : 
>> http://ansuz.sooke.bc.ca/page/fonts#ocrb
>> 
>> > Is there an way to use the PostScript OCR-B font with the pst-barcode
>> > package ? At
>> 
>> no, why should it? The package draws the lines by itself.
>> 
> The lines are correct. But in real world, the most EAN13 barcodes digits (at least at France) are not printed with the font Helvetica or Times Roman, but with the font OCR-B. So there would be great if with the pst-barcode we can use the font OCR-B for printing the digits.
> If you don't believe me, I will take picture of EAN13 barcode of various products and publish these on my web site.
> 

There are several problems you will have to address.

1. MacTeX 2011 provides only an incomplete version of gs 9.02. It does not provide a Resource folder within which you would expect to find a fontmap.GS which could be customized to your needs. I was not successful in compiling gs 9.02 from source (missing libraries in 64 bit mode) and instead installed macports and used it to construct gs 9.04 in the macports tree with root at /opt. (You need the Apple development tools to do this---a free download from the App Store, at least with Lion.) You need to change only two things for TeXShop to use the new gs: (i) in TeXShop preferences (Engine), set the distiller folder to /opt/local/bin; (ii) find the simpdftex shell script and change the hard-coded location of gs from /usr/local/bin to /opt/local/bin.

2. In theory, it should suffice to add an entry for OCRB in fontmap.GS, like the line

/OCRB		(OCRB.pfb)	;

and copy OCRB.pfb and OCRB.afm to the fonts folder at the same level as the 9.04 folder in /opt/local/share/ghostscript. In practice, this failed, and I believe the fonts from http://ansuz.sooke.bc.ca/page/fonts#ocrb may be defective because they always produce gs errors, even with simple files not involving pst-barcode, where other versions of the fonts do not. (The files ocrb10,pfb, etc, (part of TeXLive) work correctly, for example, though I had to clean them up so they would validate in FontForge. The line in fontmap.GS should in this case be

/ocrb10		(ocrb10.pfb)	;

)

After doing this, I got correct font output from

%&latex
%!TEX TS-program = latex
\documentclass[dvips]{amsart}
\usepackage{graphicx}
\usepackage[dvipsnames]{pstricks}
\usepackage{pst-barcode}
\pagestyle{empty}
\begin{document}
\thispagestyle{empty}

\begin{pspicture}(3,1.2in) \psbarcode[scalex=0.8,scaley=0.8]{9781860742712}{includetext textfont=ocrb10 guardwhitespace}{ean13} \end{pspicture}
\end{document}

but not when I substituted textfont=OCRB.

Michael


More information about the PSTricks mailing list