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

Thai codepage error #38

Open
GoogleCodeExporter opened this issue Mar 17, 2015 · 1 comment
Open

Thai codepage error #38

GoogleCodeExporter opened this issue Mar 17, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

os:Raspberry Pi

I want to print thai font this is my code

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from escpos import *
import qrcode

Epson = printer.Usb(0x0519,0x0001)
s = u'ตัวอักษรไทย'
Epson.text("Hello World\n")
ss=s.encode('cp874')
Epson.text(ss)
Epson.cut()


but thai letter 'ตัวอักษรไทย' it came out like a added 
picture  
how can I solve it??

Original issue reported on code.google.com by [email protected] on 3 Nov 2014 at 10:55

Attachments:

@GoogleCodeExporter
Copy link
Author

As no other answer has been provided to your question, I will show you the more 
time consuming way to accomplish this. You are at least guaranteed an honest 
shot.

I will assume your printer is not sold with Thai fonts. You will have to 
extract the Thai font yourself, and convert each character to a 12x24 cell. 
These cells will be useable in the printers default "Type A" font.

This demo proves Epson will allow you to temporarily substitute the low-order 
ASCII characters:



#!/usr/bin/env python
# -*- coding: utf-8 -*-

from escpos import *
#import qrcode

Epson = printer.Usb(0x0519,0x0001)



# define a 12x24 printer custom symbol font
def linedrawncodez ( P, i_offset=0x78, i_length=0x02, j_offset=0x0 ):

  # Graphic mandate: disable real-time commands of the DLE, DC4 prefix
  P._raw('\x1D\x28\x44\x05\x00\x14\x01\x00\x02\x00')

  # Define substitution range
  P._raw(
  char(0x1B)+char(0x26)+
  char(0x03)+
  char( i_offset)+
  char( i_offset + ( i_length - 1 ) )
  )

  # Define substitute type face (only for easy-to-encode 12x24)
  P._raw(
  char(0x0C)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x18)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x0C)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x33)+char(0x33)+char(0x33)+
  char(0x33)+char(0x33)+char(0x33)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)+
  char(0x00)+char(0x00)+char(0x00)
  )

  # Re-enable real-time commands of the DLE, DC4 prefix
  P._raw('\x1D\x28\x44\x05\x00\x14\x01\x01\x02\x01')



# reset printer
Epson.text(char(0x1b)+char(0x40))

# Declare a Box-Art table, presently 2 characters only:
linedrawncodez(Epson)



# Beginning of line:
Epson.text('yxx 90 xxy = ');

# font custom on
Epson.text('\x1B\x25\x01')

# Will look like: |-- 90 --|
Epson.text('yxx 90 xxy');

# font custom off
Epson.text('\x1B\x25\x00')

# End of line
Epson.text(" <\n");



Epson.cut();

Original comment by [email protected] on 16 Feb 2015 at 11:04

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

1 participant