Feature: Labelprint für Kistenetiketten hinzugefügt

This commit is contained in:
2025-10-27 12:14:44 +01:00
parent 43bc416554
commit 14bae6c9ef
1068 changed files with 229014 additions and 1807 deletions

View File

@@ -0,0 +1,187 @@
# makefile
#
# @since 2015-05-14
# @category Library
# @package PdfFont
# @author Nicola Asuni <info@tecnick.com>
# @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
# @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
# @link https://github.com/tecnickcom/tc-lib-pdf-font
#
# This file is part of tc-lib-pdf-font software library.
#
# Download and convert fonts for tc-lib-pdf-font.
# ----------------------------------------------------------------------------------------------------------------------
# Folder containing the font to install (package)
PKGFONTDIR=.
# License name of the font to be packaged
PKGFONTLICENSE=.
# Project owner
OWNER=tecnickcom
# Project vendor
VENDOR=${OWNER}
# Project name
PROJECT=tc-lib-pdf-font-data-$(PKGFONTDIR)
# Project version
VERSION=$(shell cat ../VERSION)
# Project release number (packaging build number)
RELEASE=$(shell cat ../RELEASE)
# Name of RPM or DEB package
PKGNAME=php-${OWNER}-${PROJECT}
# Data dir
DATADIR=usr/share
# PHP home folder
PHPHOME=${DATADIR}/php/Com/Tecnick
# Default installation path for code
FONTPATH=${PHPHOME}/Pdf/Font/fonts/$(PKGFONTDIR)/
# Default installation path for documentation
DOCPATH=${DATADIR}/doc/$(PKGNAME)/
# Installation path for the code
PATHINSTFONT=$(DESTDIR)/$(FONTPATH)
# Installation path for documentation
PATHINSTDOC=$(DESTDIR)/$(DOCPATH)
# Current directory
CURRENTDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# RPM Packaging path (where RPMs will be stored)
PATHRPMPKG=$(CURRENTDIR)/../target/RPM_FONTS/$(PKGFONTDIR)
# DEB Packaging path (where DEBs will be stored)
PATHDEBPKG=$(CURRENTDIR)/../target/DEB_FONTS/$(PKGFONTDIR)
# BZ2 Packaging path (where BZ2s will be stored)
PATHBZ2PKG=$(CURRENTDIR)/../target/BZ2_FONTS/$(PKGFONTDIR)
# Composer executable (disable APC to as a work-around of a bug)
COMPOSER=$(shell which php) -d "apc.enable_cli=0" $(shell which composer)
# --- MAKE TARGETS ---
# Display general help about this command
.PHONY: help
help:
@echo ""
@echo "${PROJECT} Makefile."
@echo "The following commands are available:"
@echo ""
@echo " make clean : Delete the vendor and target directory"
@echo " make build : Clean and download the composer dependencies"
@echo " make update : Update composer dependencies"
@echo " make install : Install this library"
@echo " make uninstall : Remove all installed files"
@echo " make rpm : Build an RPM package"
@echo " make deb : Build a DEB package"
@echo " make bz2 : Build a tar bz2 (tbz2) compressed archive"
@echo ""
# alias for help target
.PHONY: all
all: help
# delete the vendor and target directory
.PHONY: clean
clean:
rm -rf ./vendor/
rm -rf ../target/fonts
.PHONY: deps
deps:
($(COMPOSER) install --no-dev --no-interaction)
# clean and download the composer dependencies (all TTF font files)
.PHONY: build
build: deps
./bulk_convert.php
# update composer dependencies
.PHONY: update
update:
($(COMPOSER) update --no-interaction)
# Install this application
.PHONY: install
install: uninstall
mkdir -p $(PATHINSTFONT)
cp -rf ../target/fonts/$(PKGFONTDIR)/*.json $(PATHINSTFONT)
cp -rf ../target/fonts/$(PKGFONTDIR)/*.z $(PATHINSTFONT) | true
find $(PATHINSTFONT) -type d -exec chmod 755 {} \;
find $(PATHINSTFONT) -type f -exec chmod 644 {} \;
mkdir -p $(PATHINSTDOC)
cp -f ../target/fonts/$(PKGFONTDIR)/LICENSE $(PATHINSTDOC)
cp -f ../target/fonts/$(PKGFONTDIR)/README $(PATHINSTDOC)
cp -f ../VERSION $(PATHINSTDOC)
cp -f ../RELEASE $(PATHINSTDOC)
chmod -R 644 $(PATHINSTDOC)*
# Remove all installed files
.PHONY: uninstall
uninstall:
rm -rf $(PATHINSTFONT)
# --- PACKAGING ---
# Build the RPM package for RedHat-like Linux distributions
.PHONY: rpm
rpm:
rm -rf $(PATHRPMPKG)
rpmbuild --define \
"_topdir $(PATHRPMPKG)" \
--define "_vendor $(VENDOR)" \
--define "_owner $(OWNER)" \
--define "_project $(PROJECT)" \
--define "_package $(PKGNAME)" \
--define "_version $(VERSION)" \
--define "_release $(RELEASE)" \
--define "_current_directory $(CURRENTDIR)" \
--define "_fontpath /$(FONTPATH)" \
--define "_docpath /$(DOCPATH)" \
--define "_fontdir $(PKGFONTDIR)" \
--define "_license $(PKGFONTLICENSE)" \
-bb ../resources/rpm/fonts.spec
# Build the DEB package for Debian-like Linux distributions
.PHONY: deb
deb:
echo resources/fonts/control/$(DEBCOPYRIGHT)
rm -rf $(PATHDEBPKG)
make install DESTDIR=$(PATHDEBPKG)/$(PKGNAME)-$(VERSION) PKGFONTDIR=$(PKGFONTDIR)
tar -zcvf $(PATHDEBPKG)/$(PKGNAME)_$(VERSION).orig.tar.gz -C $(PATHDEBPKG)/ $(PKGNAME)-$(VERSION)
cp -rf ../resources/fonts/debian $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#DATE#~/`date -R`/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#VENDOR#~/$(VENDOR)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#PROJECT#~/$(PROJECT)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#PKGNAME#~/$(PKGNAME)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#VERSION#~/$(VERSION)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#RELEASE#~/$(RELEASE)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#FONT#~/$(PKGFONTDIR)/" {} \;
find $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/ -type f -exec sed -i "s/~#LICENSE#~/$(PKGFONTLICENSE)/" {} \;
echo $(FONTPATH) > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
echo "$(FONTPATH)* $(FONTPATH)" > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
echo $(DOCPATH) >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).dirs
echo "$(DOCPATH)* $(DOCPATH)" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/install
echo "new-package-should-close-itp-bug" > $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).lintian-overrides
echo "extra-license-file $(DOCPATH)LICENSE.gz" >> $(PATHDEBPKG)/$(PKGNAME)-$(VERSION)/debian/$(PKGNAME).lintian-overrides
cd $(PATHDEBPKG)/$(PKGNAME)-$(VERSION) && debuild -us -uc
# build a compressed bz2 archive
.PHONY: bz2
bz2:
rm -rf $(PATHBZ2PKG)
make install DESTDIR=$(PATHBZ2PKG) PKGFONTDIR=$(PKGFONTDIR)
tar -jcvf $(PATHBZ2PKG)/$(PKGNAME)-$(VERSION)-$(RELEASE).tbz2 -C $(PATHBZ2PKG) $(DATADIR)

View File

@@ -0,0 +1,197 @@
#!/usr/bin/env php
<?php
/**
* bulk_convert.php
*
* @since 2015-11-30
* @category Library
* @package PdfFont
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* This file is part of tc-lib-pdf-font software library.
*
* Command-line tool to convert fonts data for the tc-lib-pdf-font library in bulk.
*/
if (php_sapi_name() != 'cli') {
fwrite(STDERR, 'You need to run this command from console.'."\n");
exit(1);
}
/**
* Display help guide for this command.
*/
function showHelp()
{
$help = <<<EOD
bulk_convert - Command-line tool to convert fonts data for the tc-lib-pdf-font library.
Usage:
bulk_convert.php [ options ]
Options:
-o, --outpath
Output path for generated font files (must be writeable by the
web server). Leave empty for default font folder.
-h, --help
Display this help and exit.
EOD;
fwrite(STDOUT, $help);
exit(0);
}
// initialize the array of options
$options = array('outpath' => dirname(__DIR__).'/target/fonts/');
// short input options
$sopt = 'o:';
// long input options
$lopt = array('outpath:');
// parse input options
$inopt = getopt($sopt, $lopt);
// import options (with some sanitization)
foreach ($inopt as $opt => $val) {
switch ($opt) {
case 'o':
case 'outpath':
$options['outpath'] = realpath($val);
if (substr($options['outpath'], -1) != '/') {
$options['outpath'] .= '/';
}
break;
case 'h':
case 'help':
default:
showHelp();
break;
}
}
// check input values
if (!is_dir($options['outpath'])) {
mkdir($options['outpath'], 0755, true);
}
if (!is_writable($options['outpath'])) {
fwrite(STDERR, 'ERROR: Can\'t write to '.$options['outpath']."\n\n");
exit(2);
}
$ttfdir = __DIR__.'/vendor/tecnickcom/tc-font-mirror/';
if (!is_dir($ttfdir)) {
fwrite(STDERR, 'ERROR: The '.$ttfdir.' directory is empty, please execute \'make build\' before this command.'."\n\n");
exit(3);
}
fwrite(STDOUT, "\n".'>>> Converting fonts:'."\n".'*** Output directory set to '.$options['outpath']."\n");
// count conversions
$convert_errors = 0;
$convert_success = 0;
require_once (dirname(__DIR__).'/vendor/autoload.php');
$fontdir = array_diff(scandir($ttfdir), array('.', '..', '.git'));
// URL of websites containing the font sources
$font_url = array(
'cid0' => 'http://unifoundry.com/unifont.html',
'core' => 'https://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip',
'dejavu' => 'http://sourceforge.net/projects/dejavu/files/dejavu/2.35/dejavu-fonts-ttf-2.35.zip',
'freefont' => 'https://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip',
'pdfa' => 'https://github.com/tecnickcom/tc-font-pdfa',
'unifont' => 'http://unifoundry.com/unifont.html',
);
foreach ($fontdir as $dir) {
$indir = $ttfdir.$dir;
if (!is_dir($indir)) {
continue;
}
// search font files in sub directories
$all_files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($indir));
$fonts = iterator_to_array(new RegexIterator($all_files, '/\.ttf$/'));
$fonts = array_merge($fonts, iterator_to_array(new RegexIterator($all_files, '/\.pfb$/')));
$fonts = array_merge($fonts, iterator_to_array(new RegexIterator($all_files, '/\.otf$/')));
if (empty($fonts)) {
$fonts = iterator_to_array(new RegexIterator($all_files, '/\.afm$/'));
}
if (empty($fonts)) {
continue;
}
// build output path directory
$outdir = $options['outpath'].$dir.'/';
if (!is_dir($outdir)) {
mkdir($outdir, 0755, true);
}
copy($indir.'/LICENSE', $outdir.'LICENSE');
// generate a README file
$readme = '# '.$dir.' font files for tc-lib-pdf-font'."\n\n"
.'This folder contains font files and/or font data extracted from:'."\n"
.$font_url[$dir]."\n"
.'using the "bulk_convert.php" utility in https://github.com/tecnickcom/tc-font-pdf-font'."\n\n"
.'The original files (if present) have been renamed and compressed using the ZLIB data format (.z files).'."\n"
.'The font files are subject to the conditions stated in the LICENSE file.'."\n"
.'For further information please consult the original documentation at the link above.'."\n";
file_put_contents($outdir.'README', $readme);
foreach ($fonts as $font) {
if (substr($font, -4) == '.otf') {
// OTF fonts are not yet supported but we can try to convert them to TTF using FontForge
system('fontforge -script otf2ttf.ff '.escapeshellcmd($font), $err);
if ($err != 0) {
fwrite(STDERR, "\033[31m".'Unable to convert: '.$font."\033[m");
continue;
}
$font = substr($font, 0, -4).'.ttf';
}
$type = '';
$encoding = '';
if ($dir == 'cid0') {
$type = strtoupper(basename($font, '.ttf'));
} elseif (($dir == 'core') || ($dir == 'pdfa')) {
if (strpos($font, 'Symbol') !== false) {
$encoding = 'symbol';
} elseif (strpos($font, 'ZapfDingbats') === false) {
$encoding = 'cp1252';
}
}
try {
$import = new \Com\Tecnick\Pdf\Font\Import(
realpath($font),
$outdir,
$type,
$encoding
);
$fontname = $import->getFontName();
fwrite(STDOUT, "\033[32m".'+++ OK : '.$font.' added as '.$fontname."\033[m\n");
++$convert_success;
} catch (\Exception $exc) {
++$convert_errors;
fwrite(STDERR, "\033[31m".'--- ERROR: can\'t add '.$font."\n ".$exc->getMessage()."\033[m\n");
}
}
}
$endmsg = '>>> PROCESS COMPLETED: '.$convert_success.' CONVERTED FONT(S), '.$convert_errors.' ERROR(S)!'."\n\n";
if ($convert_errors > 0) {
fwrite(STDERR, "\033[31m".$endmsg.'ERROR'."\033[m");
exit(4);
}
fwrite(STDOUT, "\033[32m".$endmsg."\033[m");
exit(0);

View File

@@ -0,0 +1,45 @@
{
"name": "tecnickcom/tc-lib-pdf-font",
"description": "Import TTF font files to be converted for tc-lib-pdf-font",
"type": "library",
"homepage": "http://www.tecnick.com",
"keywords": [
"tc-lib-pdf-font-data",
"PDF",
"font",
"TTF",
"AFM",
"PFB",
"import"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"role": "lead"
}
],
"require": {
"tecnickcom/tc-font-mirror": "^2.1"
},
"require-dev": {},
"repositories": [
{
"type": "package",
"package": {
"name": "tecnickcom/tc-font-mirror",
"version": "2.1.0",
"dist": {
"type": "zip",
"url": "https://github.com/tecnickcom/tc-font-mirror/archive/refs/tags/2.1.0.zip",
"reference": "main"
},
"autoload": {
"classmap": [
"."
]
}
}
}
]
}

View File

@@ -0,0 +1,258 @@
#!/usr/bin/env php
<?php
/**
* convert.php
*
* @since 2011-05-23
* @category Library
* @package PdfFont
* @author Nicola Asuni <info@tecnick.com>
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-font
*
* This file is part of tc-lib-pdf-font software library.
*
* Command-line tool to convert fonts data for the tc-lib-pdf-font library.
*/
if (php_sapi_name() != 'cli') {
fwrite(STDERR, 'You need to run this command from console.'."\n");
exit(1);
}
/**
* Display help guide for this command.
*/
function showHelp()
{
$help = <<<EOD
convert - Command-line tool to convert fonts data for the tc-lib-pdf-font library.
Usage:
convert.php [ options ] -i fontfile[,fontfile]...
Options:
-o, --outpath
Output path for generated font files (must be writeable by the
web server). Leave empty for default font folder.
-t, --type
Font type. Leave empty for autodetect mode.
Valid values are:
Core
TrueTypeUnicode
TrueType
Type1
CID0JP = CID-0 Japanese
CID0KR = CID-0 Korean
CID0CS = CID-0 Chinese Simplified
CID0CT = CID-0 Chinese Traditional
-e, --encoding
Name of the encoding table to use.
Leave empty for default mode.
Omit this parameter for TrueTypeUnicode and symbolic fonts
like Symbol or ZapfDingBats.
-f, --flags
Unsigned 32-bit integer containing flags specifying various
characteristics of the font (see PDF32000:2008 - 9.8.2 Font
Descriptor Flags):
+1 for fixed font;
+4 for symbol;
+32 for non-symbol;
+64 for italic.
Fixed and Italic mode are generally autodetected so you have
to set it to:
4 = symbolic font;
32 = non-symbolic font (default).
-p, --platform_id
Platform ID for CMAP table to extract (when building a Unicode
font for Windows this value should be 3, for Macintosh should
be 1).
-n, --encoding_id
Encoding ID for CMAP table to extract (when building a Unicode
font for Windows this value should be 1, for Macintosh should
be 0).
When Platform ID is 3, legal values for Encoding ID are:
0 = Symbol,
1 = Unicode,
2 = ShiftJIS,
3 = PRC,
4 = Big5,
5 = Wansung,
6 = Johab,
7 = Reserved,
8 = Reserved,
9 = Reserved,
10 = UCS-4.
-l, --linked
Link to system font instead of copying the font data (not
transportable).
Note: this feature is unsupported by Type1 fonts.
-i, --fonts
Comma-separated list of input font files.
-h, --help
Display this help and exit.
Examples:
./convert.php --outpath=/tmp/ --type=Type1 --encoding=cp1252 --flags=97 --encoding_id=1 \
--fonts=/tmp/pdfa/pdfacourieri.pfb,/tmp/pdfa/pdfacourierbi.pfb
./convert.php --outpath=/tmp/ --type=TrueTypeUnicode --flags=32 --encoding_id=1 \
--fonts=/tmp/freefont-20120503/FreeSans.ttf
./convert.php --outpath=/tmp/ --type=TrueTypeUnicode --flags=97 --encoding_id=1 \
--fonts=/tmp/dejavu-fonts-ttf-2.35/ttf/DejaVuSansMono-BoldOblique.ttf
EOD;
fwrite(STDOUT, $help);
exit(0);
}
// remove the name of the executing script
array_shift($argv);
// no options chosen, display help
if (empty($argv)) {
showHelp();
}
// initialize the array of options
$options = array(
'outpath' => './',
'type' => '',
'encoding' => '',
'flags' => 32,
'platform_id' => 3,
'encoding_id' => 1,
'linked' => false
);
// short input options
$sopt = 't:e:f:o:p:n:li:h';
// long input options
$lopt = array(
'outpath:',
'type:',
'encoding:',
'flags:',
'platform_id:',
'encoding_id:',
'linked',
'fonts:',
'help'
);
// parse input options
$inopt = getopt($sopt, $lopt);
// import options (with some sanitization)
foreach ($inopt as $opt => $val) {
switch ($opt) {
case 'o':
case 'outpath':
$options['outpath'] = realpath($val);
if (substr($options['outpath'], -1) != '/') {
$options['outpath'] .= '/';
}
break;
case 't':
case 'type':
if (in_array($val, array('TrueTypeUnicode', 'TrueType', 'Type1', 'CID0JP', 'CID0KR', 'CID0CS', 'CID0CT'))) {
$options['type'] = $val;
}
break;
case 'e':
case 'encoding':
$options['encoding'] = $val;
break;
case 'f':
case 'flags':
$options['flags'] = intval($val);
break;
case 'p':
case 'platform_id':
$options['platform_id'] = min(max(1, intval($val)), 3);
break;
case 'n':
case 'encoding_id':
$options['encoding_id'] = min(max(0, intval($val)), 10);
break;
case 'l':
case 'linked':
$options['linked'] = true;
break;
case 'i':
case 'fonts':
$options['fonts'] = explode(',', $val);
break;
case 'h':
case 'help':
default:
showHelp();
break;
}
}
// check input values
if (!is_dir($options['outpath']) || !is_writable($options['outpath'])) {
fwrite(STDERR, 'ERROR: Can\'t write to '.$options['outpath']."\n\n");
exit(2);
}
if (empty($options['fonts'])) {
fwrite(STDERR, 'ERROR: missing input fonts (try --help for usage)'."\n\n");
exit(3);
}
fwrite(STDOUT, "\n".'>>> Converting fonts:'."\n".'*** Output directory set to '.$options['outpath']."\n");
// count conversions
$convert_errors = 0;
$convert_success = 0;
require_once (dirname(dirname(__DIR__)).'/vendor/autoload.php');
foreach ($options['fonts'] as $font) {
try {
$import = new \Com\Tecnick\Pdf\Font\Import(
realpath($font),
$options['outpath'],
$options['type'],
$options['encoding'],
$options['flags'],
$options['platform_id'],
$options['encoding_id'],
$options['linked']
);
$fontname = $import->getFontName();
fwrite(STDOUT, "\033[32m".'+++ OK : '.$font.' added as '.$fontname."\033[m\n");
++$convert_success;
} catch (\Exception $exc) {
++$convert_errors;
fwrite(STDERR, "\033[31m".'--- ERROR: can\'t add '.$font."\n ".$exc->getMessage()."\033[m\n");
}
}
$endmsg = '>>> PROCESS COMPLETED: '.$convert_success.' CONVERTED FONT(S), '.$convert_errors.' ERROR(S)!'."\n\n";
if ($convert_errors > 0) {
fwrite(STDERR, "\033[31m".$endmsg.'ERROR'."\033[m");
exit(4);
}
fwrite(STDOUT, "\033[32m".$endmsg."\033[m");
exit(0);

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env fontforge
# FontForge script used to convert Noto CJK OTF fonts into TTF format
# FROM: https://gist.github.com/mojavelinux/c74162d44ca77d1a7c25
# PDF Flags
# * 0x90 - Neither OpenType or Apple
# * 0x800 - Generate old-style 'kern' table
# * 0x08 - Exclude TrueType instructions
genflags = 0x90 + 0x08 + 0x800
src_file = $1
dst_file = $1:r + ".ttf"
Open(src_file)
CIDFlatten()
SelectAll()
ClearInstrs()
SelectNone()
# Remove glyphs we'll later truncate to get under glyph limit
SelectMore(0u1f190,0u1f199)
Clear()
SelectNone()
Generate(dst_file, "", genflags)
Close()
Open(dst_file)
# Add missing space glyph
Select(0u00a0)
Copy()
Select(0u0020)
Paste()
SetWidth(0)
SelectNone()
# select lesser range of glyphs
#SelectMore(0u0020,0uffee)
#SelectInvert()
#Clear()
#SelectNone()
Generate(dst_file, "", genflags)
Close()