escpos-php icon indicating copy to clipboard operation
escpos-php copied to clipboard

Support Armenian language

Open levon1991 opened this issue 6 years ago • 6 comments

Hi Mike When will you add support Armenian language?

I read about that in your forum https://github.com/receipt-print-hq/escpos-printer-db/issues/31 but it is 2 year ago.

levon1991 avatar Aug 20 '19 11:08 levon1991

Hi @levon1991 - any solution involving printer profiles will be highly printer-specific, can you share some information about which hardware and OS you are using?

I can basically confirm that this example will only get you a string of "??????" on the default profile, which is what you would use for Epson printers.

<?php
/* Call this file 'hello-world.php' */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Կրնամ ապակի ուտել և ինծի անհանգիստ չըներ\n");
$printer -> cut();
$printer -> close();

However, if you need this to work and are prepared to work with something that is prototype-quality, then I would suggest reading this blog post. I have never finished working on custom font support, but you can absolutely print Armenian on a good ESC/POS printer.

You can clone the code here, and get unifont here. You need to locate unifont-12.1.03.tar.gz, and extract font/precompiled/unifont-12.1.03.hex.

You then set a path and some text -

diff --git a/unifont-bitmap-font/unifont-example.php b/unifont-bitmap-font/unifont-example.php
index 374431c..e1ef080 100644
--- a/unifont-bitmap-font/unifont-example.php
+++ b/unifont-bitmap-font/unifont-example.php
@@ -515,7 +515,7 @@ class UnifontCodeSource implements ColumnFormatGlyphFactory {
     }
 
     public function __construct() {
-        $unifont = "/usr/share/unifont/unifont.hex";
+        $unifont = "unifont-12.1.03.hex";
         $this -> unifontFile = explode("\n", file_get_contents($unifont));
     }
 
@@ -722,11 +722,11 @@ class UnicodePrintBuffer implements PrintBuffer {
     }
 }
 
-$text = file_get_contents("php://stdin");
+$text = "Հայերեն     ֏55,000\n";
 $connector = new FilePrintConnector("php://stdout");
 $printer = new Printer($connector);
 $printer -> text($text);
 $printer -> cut();
 $printer -> close();
 
-?>
\ No newline at end of file
+?>

And you can go printing receipts with basically any character set on them, just without image, correct spacing, or other luxuries :)

$ php unifont-example.php > /dev/usb/lp0

receipt-example

This is all on an Epson TM-T20II on Debian, but maybe it will also be useful in your setup.

mike42 avatar Sep 19 '19 11:09 mike42

I try to run this script and want to print in terminal but it printed this


levon@debian:/var/www/html/models/print_test/escpos-snippets/unifont-bitmap-font$ php unifont-example.php P� ����x((��*** VAlevon@debian:/var/www/html/models/print_test/escpos-snippets/unifont-bitmap-font$


if it can't print in termianl I assume it wouldn't print in pos printer to.

I change this

  •    $unifont = "/usr/share/unifont/unifont.hex";
    
  •    $unifont = "unifont-12.1.03.hex";
    

and this -$text = file_get_contents("php://stdin"); +$text = "Հայերեն ֏55,000\n"; by your example. can you halp us sort it out?

levon1991 avatar Sep 21 '19 10:09 levon1991

@levon1991 - The command I ran redirected that binary to /dev/usb/lp0, which is where my TM-T20II printer appears (it is connected via USB).

Can you share some information about the type of printer you have, and how it is connected? I should be able to point you in the right direction if it's something common.

mike42 avatar Sep 22 '19 00:09 mike42

type of my printer SP-POS888U, now I can print check in armenian language but I have problem with hade of text 2019-10-06 12-46-48 what I can do to fix this problem

levon1991 avatar Oct 07 '19 06:10 levon1991

Cuting head of text it's depend on type of printer or it's libery problem?

levon1991 avatar Oct 21 '19 14:10 levon1991

@levon1991 Hello, did you solve the cut head problem?

yayidg22 avatar May 04 '24 18:05 yayidg22