fix(pmr): 라벨 박스 내 텍스트 레이아웃 일관성 개선

- 고정 라인 높이(32px) 기준 중앙 정렬 (글자 내용과 무관하게 동일 레이아웃)
- 1회복용량 ↔ 복용횟수 간격 조정 (6px)
- 박스 내 텍스트 전체 5px 위로 조정
This commit is contained in:
thug0bin 2026-03-12 22:45:29 +09:00
parent 80f7f0ac80
commit d901c67125

View File

@ -994,18 +994,19 @@ def create_label_image(patient_name, med_name, add_info='', dosage=0, frequency=
time_text = f"1일 {frequency}"
# 박스 내 텍스트 중앙 배치 (수직 중앙 정렬)
line_spacing = 5
line_spacing = 6 # 1회복용량 ↔ 복용횟수 간격
bbox1 = draw.textbbox((0, 0), dosage_text, font=info_font)
text1_height = bbox1[3] - bbox1[1]
bbox2 = draw.textbbox((0, 0), time_text, font=info_font)
text2_height = bbox2[3] - bbox2[1]
total_text_height = text1_height + line_spacing + text2_height
# 방법 2: 폰트 최대 높이 기준 고정 (글자 내용과 무관하게 일정한 레이아웃)
fixed_line_height = 32 # 폰트 크기 30 기반 고정 라인 높이
fixed_total_height = fixed_line_height * 2 + line_spacing
center_y = (box_top + box_bottom) // 2
start_y = center_y - (total_text_height // 2) - 5 # 약간 위로 조정
start_y = center_y - (fixed_total_height // 2) - 5 # 박스 내 텍스트 전체 위로 조정
draw_centered(dosage_text, start_y, info_font)
draw_centered(time_text, start_y + text1_height + line_spacing, info_font)
draw_centered(time_text, start_y + fixed_line_height + line_spacing, info_font)
y = box_bottom + 10