Skip to content

Commit a77a8dc

Browse files
committed
Allow for OCR Font and uncolorized text characters.
Add `.gitignore`.
1 parent 37342cc commit a77a8dc

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
Small Webapp to generate LTO tape barcodes
33

44
https://lto-barcodes.dicp.net
5+
6+
7+
### Sources
8+
9+
* FPDF: https://www.fpdf.org
10+
* OCR Font: https://tsukurimashou.org/ocr.php.en

fpdf186/font/OCRA.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
$type = 'TrueType';
3+
$name = 'OCRA';
4+
$desc = array('Ascent'=>800,'Descent'=>-200,'CapHeight'=>800,'Flags'=>33,'FontBBox'=>'[87 -212 636 1106]','ItalicAngle'=>0,'StemV'=>70,'MissingWidth'=>723);
5+
$up = 0;
6+
$ut = 0;
7+
$cw = array(
8+
chr(0)=>723,chr(1)=>723,chr(2)=>723,chr(3)=>723,chr(4)=>723,chr(5)=>723,chr(6)=>723,chr(7)=>723,chr(8)=>723,chr(9)=>723,chr(10)=>723,chr(11)=>723,chr(12)=>723,chr(13)=>723,chr(14)=>723,chr(15)=>723,chr(16)=>723,chr(17)=>723,chr(18)=>723,chr(19)=>723,chr(20)=>723,chr(21)=>723,
9+
chr(22)=>723,chr(23)=>723,chr(24)=>723,chr(25)=>723,chr(26)=>723,chr(27)=>723,chr(28)=>723,chr(29)=>723,chr(30)=>723,chr(31)=>723,' '=>723,'!'=>723,'"'=>723,'#'=>723,'$'=>723,'%'=>723,'&'=>723,'\''=>723,'('=>723,')'=>723,'*'=>723,'+'=>723,
10+
','=>723,'-'=>723,'.'=>723,'/'=>723,'0'=>723,'1'=>723,'2'=>723,'3'=>723,'4'=>723,'5'=>723,'6'=>723,'7'=>723,'8'=>723,'9'=>723,':'=>723,';'=>723,'<'=>723,'='=>723,'>'=>723,'?'=>723,'@'=>723,'A'=>723,
11+
'B'=>723,'C'=>723,'D'=>723,'E'=>723,'F'=>723,'G'=>723,'H'=>723,'I'=>723,'J'=>723,'K'=>723,'L'=>723,'M'=>723,'N'=>723,'O'=>723,'P'=>723,'Q'=>723,'R'=>723,'S'=>723,'T'=>723,'U'=>723,'V'=>723,'W'=>723,
12+
'X'=>723,'Y'=>723,'Z'=>723,'['=>723,'\\'=>723,']'=>723,'^'=>723,'_'=>723,'`'=>723,'a'=>723,'b'=>723,'c'=>723,'d'=>723,'e'=>723,'f'=>723,'g'=>723,'h'=>723,'i'=>723,'j'=>723,'k'=>723,'l'=>723,'m'=>723,
13+
'n'=>723,'o'=>723,'p'=>723,'q'=>723,'r'=>723,'s'=>723,'t'=>723,'u'=>723,'v'=>723,'w'=>723,'x'=>723,'y'=>723,'z'=>723,'{'=>723,'|'=>723,'}'=>723,'~'=>723,chr(127)=>723,chr(128)=>723,chr(129)=>723,chr(130)=>723,chr(131)=>723,
14+
chr(132)=>723,chr(133)=>723,chr(134)=>723,chr(135)=>723,chr(136)=>723,chr(137)=>723,chr(138)=>723,chr(139)=>723,chr(140)=>723,chr(141)=>723,chr(142)=>723,chr(143)=>723,chr(144)=>723,chr(145)=>723,chr(146)=>723,chr(147)=>723,chr(148)=>723,chr(149)=>723,chr(150)=>723,chr(151)=>723,chr(152)=>723,chr(153)=>723,
15+
chr(154)=>723,chr(155)=>723,chr(156)=>723,chr(157)=>723,chr(158)=>723,chr(159)=>723,chr(160)=>723,chr(161)=>723,chr(162)=>723,chr(163)=>723,chr(164)=>723,chr(165)=>723,chr(166)=>723,chr(167)=>723,chr(168)=>723,chr(169)=>723,chr(170)=>723,chr(171)=>723,chr(172)=>723,chr(173)=>723,chr(174)=>723,chr(175)=>723,
16+
chr(176)=>723,chr(177)=>723,chr(178)=>723,chr(179)=>723,chr(180)=>723,chr(181)=>723,chr(182)=>723,chr(183)=>723,chr(184)=>723,chr(185)=>723,chr(186)=>723,chr(187)=>723,chr(188)=>723,chr(189)=>723,chr(190)=>723,chr(191)=>723,chr(192)=>723,chr(193)=>723,chr(194)=>723,chr(195)=>723,chr(196)=>723,chr(197)=>723,
17+
chr(198)=>723,chr(199)=>723,chr(200)=>723,chr(201)=>723,chr(202)=>723,chr(203)=>723,chr(204)=>723,chr(205)=>723,chr(206)=>723,chr(207)=>723,chr(208)=>723,chr(209)=>723,chr(210)=>723,chr(211)=>723,chr(212)=>723,chr(213)=>723,chr(214)=>723,chr(215)=>723,chr(216)=>723,chr(217)=>723,chr(218)=>723,chr(219)=>723,
18+
chr(220)=>723,chr(221)=>723,chr(222)=>723,chr(223)=>723,chr(224)=>723,chr(225)=>723,chr(226)=>723,chr(227)=>723,chr(228)=>723,chr(229)=>723,chr(230)=>723,chr(231)=>723,chr(232)=>723,chr(233)=>723,chr(234)=>723,chr(235)=>723,chr(236)=>723,chr(237)=>723,chr(238)=>723,chr(239)=>723,chr(240)=>723,chr(241)=>723,
19+
chr(242)=>723,chr(243)=>723,chr(244)=>723,chr(245)=>723,chr(246)=>723,chr(247)=>723,chr(248)=>723,chr(249)=>723,chr(250)=>723,chr(251)=>723,chr(252)=>723,chr(253)=>723,chr(254)=>723,chr(255)=>723);
20+
$enc = 'cp1252';
21+
$uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
22+
$file = 'OCRA.z';
23+
$originalsize = 14572;
24+
$subsetted = true;
25+
?>

fpdf186/font/OCRA.z

7.42 KB
Binary file not shown.

lto.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@
2020
$id = 'CU';
2121
}
2222

23+
$colorizeChars = (isset($_GET['colorizeChars']) && $_GET['colorizeChars'] == 1) ? true : false;
24+
2325
$tapeType = $_GET['tapeType'] ?? 'normal';
2426

27+
$fontType = $_GET['fontType'] ?? 'normal';
28+
if ($fontType == 'normal') {
29+
$font = 'Arial';
30+
$fontweight = 'B';
31+
} elseif ($fontType == 'ocr') {
32+
$font = 'OCRA';
33+
$fontweight = '';
34+
}
35+
2536
// Prefix
2637
//$pre = 'BWN';
2738
$pre = $_GET['prefix'] ?? '';
@@ -55,7 +66,10 @@ function lto_label($x, $y, $code, $id, $palette) {
5566
global $colors;
5667
global $pdf;
5768
global $text_h;
69+
global $font;
70+
global $fontweight;
5871
global $textColor;
72+
global $colorizeChars;
5973

6074
// Label outer border/marker
6175
$pdf->SetLineWidth(0.05);
@@ -66,16 +80,20 @@ function lto_label($x, $y, $code, $id, $palette) {
6680
$pdf->SetX($x+4);
6781

6882
// Label text size
69-
$pdf->SetFont('Arial', 'B', 14);
83+
$pdf->SetFont($font, $fontweight, 14);
7084
$pdf->SetTextColor($textColor[0], $textColor[1], $textColor[2]);
7185
// Label Code
7286
for ($i = 0; $i < strlen($code); $i++) {
7387
$char = substr($code, $i, 1);
74-
$pdf->SetFillColor($colors[$palette][$char][0], $colors[$palette][$char][1], $colors[$palette][$char][2]);
75-
$pdf->Cell(10, $text_h, $char, 1, 0, 'C', 1);
88+
if ($colorizeChars === true && !ctype_digit($char) || ctype_digit($char)) {
89+
$pdf->SetFillColor($colors[$palette][$char][0], $colors[$palette][$char][1], $colors[$palette][$char][2]);
90+
$pdf->Cell(10, $text_h, $char, 1, 0, 'C', 1);
91+
} else {
92+
$pdf->Cell(10, $text_h, $char, 1, 0, 'C', 0);
93+
}
7694
}
7795
// Tape Type marker
78-
$pdf->SetFont('Arial', 'B', 8);
96+
$pdf->SetFont($font, $fontweight, 8);
7997
$pdf->SetFillColor($colors[$palette][" "][0], $colors[$palette][" "][1], $colors[$palette][" "][2]);
8098
$pdf->Cell(10, $text_h, $id, 1, 0, 'C', 1);
8199

@@ -85,6 +103,9 @@ function lto_label($x, $y, $code, $id, $palette) {
85103
}
86104

87105
$pdf=new PDF_Code39('P', 'mm', 'A4');
106+
if ($fontType != 'normal') {
107+
$pdf->AddFont($font, $fontweight, $font.'.php');
108+
}
88109
$pdf->AddPage();
89110
$pdf->SetMargins(10, 10, 10, 10);
90111

0 commit comments

Comments
 (0)