【问题标题】:How to generate barcode using specific font in PHP如何在 PHP 中使用特定字体生成条形码
【发布时间】:2019-04-30 09:54:10
【问题描述】:

我需要生成 code39 格式的条形码图像。我需要使用特定的字体 'w39H.fft' , 'w39LC.fft'

我正在使用这个库来生成条形码图像。

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");  

但我找不到任何使用字体的选项。 您还可以建议任何其他库。

【问题讨论】:

标签: php cakephp barcode code39


【解决方案1】:

我不知道 *.fft 文件格式是什么,但库中处理文本的唯一代码使用imagestring() 打印条形码下方的人类可读文本。这些是相关的位:

/**
 * 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);

根据文档,您可以使用 imageloadfont() 为其提供自定义字体,但它们似乎是自定义平台相关位图定义。如果这不是您需要的,这不是您想要的库。

【讨论】:

    猜你喜欢
    • 2011-06-09
    • 1970-01-01
    • 2011-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 2018-12-01
    • 2018-06-29
    相关资源
    最近更新 更多