Rakesh
Rakesh

Reputation: 505

How to generate barcode using specific font in PHP

I need to generate barcode image in format of code39. I need to use specific font 'w39H.fft' , 'w39LC.fft'

I am using this library to generate the bar-code image.

https://github.com/fobiaweb/Barcode39

include('Barcode39.php');
$bc = new Barcode39("This is test barcode srting *&*%$# :"); 
// set text size 
$bc->barcode_text_size = 5; 
// set barcode bar thickness (thick bars) 
$bc->barcode_bar_thick = 4; 
// set barcode bar thickness (thin bars) 
$bc->barcode_bar_thin = 2; 
// save barcode GIF file 
$bc->draw("barcode.gif");  

But i could not find any option to use font. You can also suggest any other library.

Upvotes: -5

Views: 1773

Answers (1)

Álvaro González
Álvaro González

Reputation: 146660

I have no idea of what the *.fft file format is but the only code in the library that handles text makes use of imagestring() to print the human-readable text below the barcode. These are the relevant bits:

/**
 * Barcode text size
 *
 * @var int $barcode_text_size
 */
public $barcode_text_size = 3;
$font_size = $this->barcode_text_size;
imagestring($img, $font_size, $pos_center, $this->barcode_height - $barcode_text_h - 2,
            $barcode_string, $_000);

As per the docs, you can use imageloadfont() to feed it with custom fonts, but they seem to be custom platformt-dependent bitmap definitions. If that's not what you need, this it not the library you want.

Upvotes: 0

Related Questions