diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bce9d6e..0e67136 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,12 @@ ChangeLog ========= +Unreleased +---------- + +- Add Arial font name in addition to Helvetica for better font fallback on some + systems. + 1.0.0 (2022-09-21) ------------------ - BREAKING: Removed the ``due-date`` command line argument and the ``due_date`` diff --git a/qrbill/bill.py b/qrbill/bill.py index dc9ab89..25ccdea 100644 --- a/qrbill/bill.py +++ b/qrbill/bill.py @@ -213,6 +213,7 @@ class QRBill: allowed_currencies = ('CHF', 'EUR') # QR reference, Creditor Reference (ISO 11649), without reference reference_types = ('QRR', 'SCOR', 'NON') + font_family = 'Arial,Helvetica' def __init__( self, account=None, creditor=None, final_creditor=None, amount=None, @@ -365,20 +366,20 @@ def __init__( @property def title_font_info(self): - return {'font_size': 12 * self.font_factor, 'font_family': 'Helvetica', 'font_weight': 'bold'} + return {'font_size': 12 * self.font_factor, 'font_family': self.font_family, 'font_weight': 'bold'} @property def font_info(self): - return {'font_size': 10 * self.font_factor, 'font_family': 'Helvetica'} + return {'font_size': 10 * self.font_factor, 'font_family': self.font_family} def head_font_info(self, part=None): return { 'font_size': (8 if part == 'receipt' else 9) * self.font_factor, - 'font_family': 'Helvetica', 'font_weight': 'bold'} + 'font_family': self.font_family, 'font_weight': 'bold'} @property def proc_font_info(self): - return {'font_size': 7 * self.font_factor, 'font_family': 'Helvetica'} + return {'font_size': 7 * self.font_factor, 'font_family': self.font_family} def qr_data(self): """ diff --git a/tests/test_qrbill.py b/tests/test_qrbill.py index b19a1f2..0191db4 100644 --- a/tests/test_qrbill.py +++ b/tests/test_qrbill.py @@ -338,8 +338,8 @@ def test_spec_example1(self): bill.as_svg(fh.name) content = strip_svg_path(fh.read().decode()) self.assertTrue(content.startswith('')) - font9 = 'font-family="Helvetica" font-size="9" font-weight="bold"' - font10 = 'font-family="Helvetica" font-size="10"' + font9 = 'font-family="Arial,Helvetica" font-size="9" font-weight="bold"' + font10 = 'font-family="Arial,Helvetica" font-size="10"' # Test the Payable by section: expected = ( 'Payable by' @@ -476,13 +476,13 @@ def test_font_factor(self): ) content = strip_svg_path(self._produce_svg(bill)) self.assertIn( - 'Receipt' - 'Account / Payable to' - 'CH53 8000 5000 0102 8366 4'.format( - y1=mm(11), y2=mm(16), y3=mm(19.5) + ffamily='Arial,Helvetica', y1=mm(11), y2=mm(16), y3=mm(19.5) ), content )