From 34f562d64a589b606e6e94742aad6a4c3cd28139 Mon Sep 17 00:00:00 2001 From: Manuel F Martinez Date: Tue, 20 May 2014 22:31:49 -0700 Subject: [PATCH] Added density support --- CHANGELOG | 1 + escpos/constants.py | 10 ++++++++++ escpos/escpos.py | 23 ++++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 6bc3eb3..4571229 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,5 +18,6 @@ CHANGELOG - Added exception for PIL import * 2014-05-20 - Version 1.0.4 +- Issue #20: Added Density support (Sent by thomas.erbacher@ragapack.de) - Added charcode tables - Fixed Horizontal Tab diff --git a/escpos/constants.py b/escpos/constants.py index ea83a6e..0d7d8c6 100644 --- a/escpos/constants.py +++ b/escpos/constants.py @@ -73,3 +73,13 @@ S_RASTER_N = '\x1d\x76\x30\x00' # Set raster image normal size S_RASTER_2W = '\x1d\x76\x30\x01' # Set raster image double width S_RASTER_2H = '\x1d\x76\x30\x02' # Set raster image double height S_RASTER_Q = '\x1d\x76\x30\x03' # Set raster image quadruple +# Printing Density +PD_N50 = '\x1d\x7c\x00' # Printing Density -50% +PD_N37 = '\x1d\x7c\x01' # Printing Density -37.5% +PD_N25 = '\x1d\x7c\x02' # Printing Density -25% +PD_N12 = '\x1d\x7c\x03' # Printing Density -12.5% +PD_0 = '\x1d\x7c\x04' # Printing Density 0% +PD_P50 = '\x1d\x7c\x08' # Printing Density +50% +PD_P37 = '\x1d\x7c\x07' # Printing Density +37.5% +PD_P25 = '\x1d\x7c\x06' # Printing Density +25% +PD_P12 = '\x1d\x7c\x05' # Printing Density +12.5% diff --git a/escpos/escpos.py b/escpos/escpos.py index e4f9784..72d1b3a 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -230,7 +230,7 @@ class Escpos: raise TextError() - def set(self, align='left', font='a', type='normal', width=1, height=1): + def set(self, align='left', font='a', type='normal', width=1, height=1, density=9): """ Set text properties """ # Width if height == 2 and width == 2: @@ -276,6 +276,27 @@ class Escpos: self._raw(TXT_ALIGN_RT) elif align.upper() == "LEFT": self._raw(TXT_ALIGN_LT) + # Density + if density == 0: + self._raw(PD_N50) + elif density == 1: + self._raw(PD_N37) + elif density == 2: + self._raw(PD_N25) + elif density == 3: + self._raw(PD_N12) + elif density == 4: + self._raw(PD_0) + elif density == 5: + self._raw(PD_P12) + elif density == 6: + self._raw(PD_P25) + elif density == 7: + self._raw(PD_P37) + elif density == 8: + self._raw(PD_P50) + else:# DEFAULT: DOES NOTHING + pass def cut(self, mode=''):