diff --git a/slip39/layout/components.py b/slip39/layout/components.py index 61f770a..a3126a8 100644 --- a/slip39/layout/components.py +++ b/slip39/layout/components.py @@ -299,7 +299,7 @@ def layout_card( ).square( justify='BR' ) card_top.add_region_proportional( - Text( 'card-title', x1=0, y1=0, x2=1, y2=40/100, bold=True ) + Text( 'card-title', x1=0, y1=0, x2=1, y2=40/100, bold=True, align='C' ) ) card_top.add_region_proportional( Text( 'card-requires', x1=0, y1=40/100, x2=1, y2=66/100, align='C', italic=True ) diff --git a/slip39/output_test.py b/slip39/output_test.py index 903c0b4..9eacc08 100644 --- a/slip39/output_test.py +++ b/slip39/output_test.py @@ -4,6 +4,7 @@ from fpdf import FPDF, FlexTemplate from .layout import Region, Text, Image, Box, Coordinate +from .layout.components import layout_card from .defaults import MM_IN @@ -73,3 +74,10 @@ def test_Region(): tpl.render( offsetx = card_size.x * MM_IN, offsety = card_size.y * MM_IN ) #pdf.output( "test.pdf" ) # To view results in test.pdf, uncomment + + +def test_card_title_centered(): + """The card title is horizontally centered (it is also used, unchanged, on the back of the card).""" + card = layout_card( Coordinate( y=2+1/4, x=3+3/8 ), 1/8, 20 ) + title = next( e for e in card.elements() if e['name'] == 'card-title' ) + assert title['align'] == 'C'