Revert "Add Chinese support"

This reverts commit 110200dde678a165062707e8ccb985c837ed6f68.
This commit is contained in:
WeijiangChen 2019-08-07 19:38:24 +08:00
parent b1f677f64d
commit 3dc88794c2

View File

@ -501,7 +501,7 @@ class Escpos(object):
image = my_code.writer._image image = my_code.writer._image
self.image(image, impl=impl) self.image(image, impl=impl)
def text(self, txt, chinese=False): def text(self, txt):
""" Print alpha-numeric text """ Print alpha-numeric text
The text has to be encoded in the currently selected codepage. The text has to be encoded in the currently selected codepage.
@ -510,14 +510,10 @@ class Escpos(object):
:param txt: text to be printed :param txt: text to be printed
:raises: :py:exc:`~escpos.exceptions.TextError` :raises: :py:exc:`~escpos.exceptions.TextError`
""" """
if chinese: txt = six.text_type(txt)
txt = txt.encode('GB18030') self.magic.write(txt)
self._raw(txt)
else:
txt = six.text_type(txt)
self.magic.write(txt)
def textln(self, txt='', chinese=False): def textln(self, txt=''):
"""Print alpha-numeric text with a newline """Print alpha-numeric text with a newline
The text has to be encoded in the currently selected codepage. The text has to be encoded in the currently selected codepage.
@ -526,7 +522,7 @@ class Escpos(object):
:param txt: text to be printed with a newline :param txt: text to be printed with a newline
:raises: :py:exc:`~escpos.exceptions.TextError` :raises: :py:exc:`~escpos.exceptions.TextError`
""" """
self.text('{}\n'.format(txt), chinese=chinese) self.text('{}\n'.format(txt))
def ln(self, count=1): def ln(self, count=1):
"""Print a newline or more """Print a newline or more
@ -539,7 +535,7 @@ class Escpos(object):
if count > 0: if count > 0:
self.text('\n' * count) self.text('\n' * count)
def block_text(self, txt, font=None, columns=None, chinese=False): def block_text(self, txt, font=None, columns=None):
""" Text is printed wrapped to specified columns """ Text is printed wrapped to specified columns
Text has to be encoded in unicode. Text has to be encoded in unicode.
@ -550,7 +546,7 @@ class Escpos(object):
:return: None :return: None
""" """
col_count = self.profile.get_columns(font) if columns is None else columns col_count = self.profile.get_columns(font) if columns is None else columns
self.text(textwrap.fill(txt, col_count), chinese=chinese) self.text(textwrap.fill(txt, col_count))
def set(self, align='left', font='a', bold=False, underline=0, width=1, def set(self, align='left', font='a', bold=False, underline=0, width=1,
height=1, density=9, invert=False, smooth=False, flip=False, height=1, density=9, invert=False, smooth=False, flip=False,