[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
Tue Dec 13 01:42:33 CET 2011
On Dec 12, 2011, at 9:50 AM, Michael Sharpe wrote:
>
> On Dec 11, 2011, at 5:45 PM, Quark67 wrote:
>
>>>> 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
>>>
>>>
>> 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.
>
I found that there is a way to get a version of OCRB.pfb from the site mentioned above. The steps are:
1. Open OCRB.ttf in FontForge and correct the errors that show up in validation.
2. In FontForge, File/Generate Fonts, choose to save the output in PostScript binary format. The resulting OCRB.pfb works when copied to the ghostscript font folder and an entry is made in fontmap.GS as described above. In case you are not familiar with FontForge, I placed a copy of the output you can download at
http://math.ucsd.edu/~msharpe/OCRBf.zip
(Note the small name change to distinguish this version.)
Michael
More information about the PSTricks
mailing list