File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -170,13 +170,16 @@ def _place_stamp(
170170 start_y = (- 210 + self .stamp_width + 2 ) * mm
171171 max_width = (self .statement_height - 10 ) * mm
172172 max_height = (self .stamp_width - 2 - 5 ) * mm
173+ school_length = max_width
173174
174175 if max_width > 75 * mm :
175176 start_x += (max_width - 75 * mm ) / 2
176177 max_width = 75 * mm
178+ school_length = max_width
177179
178180 if not include_qr :
179181 start_x += max_height / 2
182+ school_length -= max_height
180183
181184 canvas .setFillGray (0 )
182185 code = code128 .Code128 (
@@ -243,7 +246,10 @@ def _place_stamp(
243246 text = canvas .beginText ()
244247 text .setTextOrigin (start_x , start_y - max_height - 8 )
245248 text .setFont ("IBMPlexMono-Regular" , 6 )
246- text .textOut (tearoff .team .display_name_short )
249+ school_chars = (
250+ int (school_length / mm * 0.77 ) - 1
251+ ) # 0.77 is how many characters fit in a mm of space
252+ text .textOut (tearoff .team .get_shortened_display_name (school_chars ))
247253 canvas .drawText (text )
248254
249255 canvas .restoreState ()
Original file line number Diff line number Diff line change @@ -118,11 +118,14 @@ def display_name(self):
118118
119119 @property
120120 def display_name_short (self ):
121+ return self .get_shortened_display_name ()
122+
123+ def get_shortened_display_name (self , chars = 55 ):
121124 if self .name :
122- return shorten (self .name , 55 )
125+ return shorten (self .name , chars )
123126 if self .in_school_symbol :
124- return f"{ shorten (str (self .school ), 55 )} { self .in_school_symbol } "
125- return shorten (str (self .school ), 55 )
127+ return f"{ shorten (str (self .school ), chars )} { self .in_school_symbol } "
128+ return shorten (str (self .school ), chars )
126129
127130 @property
128131 def contact_phone_pretty (self ):
You can’t perform that action at this time.
0 commit comments