Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Armenian language #780

Open
levon1991 opened this issue Aug 20, 2019 · 6 comments
Open

Support Armenian language #780

levon1991 opened this issue Aug 20, 2019 · 6 comments

Comments

@levon1991
Copy link

levon1991 commented Aug 20, 2019

Hi Mike
When will you add support Armenian language?

I read about that in your forum
receipt-print-hq/escpos-printer-db#31
but it is 2 year ago.

@mike42
Copy link
Owner

mike42 commented Sep 19, 2019

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.

@levon1991
Copy link
Author

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?

@mike42
Copy link
Owner

mike42 commented Sep 22, 2019

@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 mike42 added the encoding label Oct 5, 2019
@levon1991
Copy link
Author

levon1991 commented Oct 7, 2019

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
Copy link
Author

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

@yayidg22
Copy link

yayidg22 commented May 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants