Bug 41255

Summary: Text fields center / right align on patron card is wonky
Product: Koha Reporter: Indranil Das Gupta <indradg>
Component: Label/patron card printingAssignee: Chris Nighswonger <cnighswonger>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: indradg
Version: 24.11   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: UX screenshot

Description Indranil Das Gupta 2025-11-16 21:14:14 UTC
Created attachment 189625 [details]
UX screenshot

Version: 24.11.10 (LTS)

layout_xml (left aligned text field)

<opt guide_box="1" guide_grid="0" page_side="F" units="POINT">
  <barcode height_scale="0.008" llx="35" lly="10" print="1" type="CODE39" width_scale="0.8" />
  <text>☐ Year 1   ☐ Year 2   ☐ Year 3   ☐ Year 4</text>
  <text font="H" font_size="10" llx="0" lly="75" text_alignment="L" />
</opt>

When text_alignment="L" - output is OK (Screenshot #1)

When text_alignment="C" - output is wonky (Screenshot #2)

When text_alignment="R" - output is wonky (Screenshot #3)

NOTE: all other settings being same for L, C and R

This seems to fix the issue (I may have missed outlier / edge cases)

diff /usr/share/koha/lib/C4/Patroncards/Patroncard.pm /usr/share/koha/lib/C4/Patroncards/Patroncard.pm.new
325c325
<             ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $lly_text_attr * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'});
---
>             ($Tx, $Tw) = text_alignment($origin_llx, $self->{'width'}, $llx_text_attr * $self->{'unitvalue'}, $string_width, $line, $text_attribs->{'text_alignment'});

diff /usr/share/koha/lib/C4/Patroncards/Lib.pm /usr/share/koha/lib/C4/Patroncards/Lib.pm.new
62c62
<         $Tx = ($text_box_width - $string_width) + (($origin_llx - $text_llx) / 2);
---
>         $Tx = ($text_box_width - $string_width) + ($origin_llx - $text_llx);

Can someone pls verify this?