3333# Paste your API token below
3434TOKEN = "YOUR_API_TOKEN"
3535
36+
3637def font_width_to_dict (font ):
3738 # Reads the font file to determine how wide each character is
3839 # Used to avoid bad wrapping breaking the QR code
@@ -87,7 +88,6 @@ def wrap(text, max_width, max_lines, font):
8788 return "\n " .join (lines [:max_lines ])
8889
8990
90-
9191# Get first 300 items, saving only the OSHWA UIDs. The first 300 are also used to find the
9292# number of requests that will need to be made.
9393# This was done this way since if the items themselves were all asked for and stored, the MagTag
@@ -155,16 +155,16 @@ def wrap(text, max_width, max_lines, font):
155155
156156# Add the two text fields
157157magtag .add_text (
158- text_font = "fonts/Arial-12.bdf" ,
159- text_position = (5 , - 2 ),
158+ text_font = "fonts/Arial-Bold- 12.bdf" ,
159+ text_position = (5 , 0 ),
160160 text_scale = 1 ,
161- line_spacing = 0.6 ,
161+ line_spacing = 0.7 ,
162162 text_anchor_point = (0 , 0 ),
163163)
164164
165165magtag .add_text (
166166 text_font = "fonts/ArialMT-9.bdf" ,
167- text_position = (5 , 30 ),
167+ text_position = (5 , 38 ),
168168 text_scale = 1 ,
169169 line_spacing = 0.6 ,
170170 text_anchor_point = (0 , 0 ),
@@ -175,15 +175,15 @@ def wrap(text, max_width, max_lines, font):
175175magtag .graphics .qrcode (url , qr_size = 4 , x = 173 , y = 3 )
176176
177177# Prepare to wrap the text correctly by getting the width of each character for every font
178- arial_12 = font_width_to_dict ("fonts/Arial-12.bdf" )
178+ arial_12 = font_width_to_dict ("fonts/Arial-Bold- 12.bdf" )
179179arial_9 = font_width_to_dict ("fonts/ArialMT-9.bdf" )
180180
181181# Set the text. On some characters, this fails. If so, run the whole file again in 5 seconds
182182try :
183- magtag .set_text (wrap (selected ["projectName" ], 530 , 2 , arial_12 ), 0 , False )
184- magtag .set_text (wrap (selected ["projectDescription" ], 530 , 10 , arial_9 ), 1 )
183+ magtag .set_text (wrap (selected ["projectName" ], 545 , 2 , arial_12 ), 0 , False )
184+ magtag .set_text (wrap (selected ["projectDescription" ], 530 , 19 , arial_9 ), 1 )
185185 magtag .exit_and_deep_sleep (3600 )
186- except Exception : # pylint: disable=broad-except
186+ except Exception : # pylint: disable=broad-except
187187 print ("Could not set title or description: unsupported glyphs." )
188188 print ("Trying again in 10 seconds." )
189189 magtag .exit_and_deep_sleep (10 )
0 commit comments