Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -80,9 +80,9 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
80 |
|
81 |
# 2. Load fonts at sizes appropriate for a 520×728 label
|
82 |
try:
|
83 |
-
title_font = ImageFont.truetype("Inter_24pt-Bold.ttf", size=
|
84 |
-
details_font = ImageFont.truetype("Inter_18pt-Regular.ttf", size=
|
85 |
-
energy_font = ImageFont.truetype("Inter_18pt-Medium.ttf", size=
|
86 |
except Exception as e:
|
87 |
st.error(f"Font loading failed: {e}")
|
88 |
return bg_resized
|
@@ -90,13 +90,13 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
90 |
# 3. Place your text.
|
91 |
# You may need to experiment with x/y coordinates or font sizes
|
92 |
# to make it look right in 520×728.
|
93 |
-
title_x, title_y =
|
94 |
-
details_x, details_y =
|
95 |
-
energy_x, energy_y =
|
96 |
|
97 |
# Text 1 (title)
|
98 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
99 |
-
draw.text((title_x, title_y +
|
100 |
|
101 |
# Text 2 (details)
|
102 |
details_lines = [
|
@@ -108,7 +108,7 @@ def create_label_single_pass(background_image, model_data, final_size=(520, 728)
|
|
108 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|
109 |
text_width = bbox[2] - bbox[0]
|
110 |
# Right-justify the details text at details_x
|
111 |
-
draw.text((details_x - text_width, details_y + i*
|
112 |
|
113 |
# Text 3 (energy)
|
114 |
energy_text = str(model_data['energy'])
|
|
|
80 |
|
81 |
# 2. Load fonts at sizes appropriate for a 520×728 label
|
82 |
try:
|
83 |
+
title_font = ImageFont.truetype("Inter_24pt-Bold.ttf", size=27)
|
84 |
+
details_font = ImageFont.truetype("Inter_18pt-Regular.ttf", size=23)
|
85 |
+
energy_font = ImageFont.truetype("Inter_18pt-Medium.ttf", size=24)
|
86 |
except Exception as e:
|
87 |
st.error(f"Font loading failed: {e}")
|
88 |
return bg_resized
|
|
|
90 |
# 3. Place your text.
|
91 |
# You may need to experiment with x/y coordinates or font sizes
|
92 |
# to make it look right in 520×728.
|
93 |
+
title_x, title_y = 32, 140
|
94 |
+
details_x, details_y = 480, 260
|
95 |
+
energy_x, energy_y = 460, 470
|
96 |
|
97 |
# Text 1 (title)
|
98 |
draw.text((title_x, title_y), str(model_data['model']), font=title_font, fill="black")
|
99 |
+
draw.text((title_x, title_y + 35), str(model_data['provider']), font=title_font, fill="black")
|
100 |
|
101 |
# Text 2 (details)
|
102 |
details_lines = [
|
|
|
108 |
bbox = draw.textbbox((0, 0), line, font=details_font)
|
109 |
text_width = bbox[2] - bbox[0]
|
110 |
# Right-justify the details text at details_x
|
111 |
+
draw.text((details_x - text_width, details_y + i*50), line, font=details_font, fill="black")
|
112 |
|
113 |
# Text 3 (energy)
|
114 |
energy_text = str(model_data['energy'])
|