kpal002 commited on
Commit
24584f6
1 Parent(s): cbc4951

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -99,24 +99,25 @@ def generate_score_bar(score, num_criteria):
99
  class PDF(FPDF):
100
  def __init__(self, *args, **kwargs):
101
  super().__init__(*args, **kwargs)
102
- # Assuming the Roboto font files have been converted and added to your project directory
103
- self.add_font('Roboto', '', 'Roboto/Roboto-Regular.ttf', uni=True)
104
- self.add_font('Roboto', 'B', 'Roboto/Roboto-Bold.ttf', uni=True)
105
- self.add_font('Roboto', 'I', 'Roboto/Roboto-Italic.ttf', uni=True)
106
 
107
  def header(self):
108
- self.set_font('Roboto', 'B', 12)
109
  self.cell(0, 10, 'Paper Analysis Report', 0, 1, 'C')
110
 
111
  def footer(self):
112
  self.set_y(-15)
113
- self.set_font('Roboto', 'I', 8)
114
  self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
115
 
116
  def create_pdf_report(title, author_info, score, reasoning_text, output_path):
117
  pdf = PDF()
118
  pdf.add_page()
119
- pdf.set_font("Arial", size=12)
 
120
  pdf.cell(0, 10, f"Title: {title}", 0, 1)
121
  pdf.cell(0, 10, f"Author Information: {author_info}", 0, 1)
122
  pdf.cell(0, 10, f"Score: {score}", 0, 1)
 
99
  class PDF(FPDF):
100
  def __init__(self, *args, **kwargs):
101
  super().__init__(*args, **kwargs)
102
+ # Load the DejaVu font files
103
+ self.add_font('DejaVu', '', 'DejaVu_Sans/DejaVuSansCondensed.ttf', uni=True)
104
+ self.add_font('DejaVu', 'B', 'DejaVu_Sans/DejaVuSansCondensed-Bold.ttf', uni=True)
105
+ self.add_font('DejaVu', 'I', 'DejaVu_Sans/DejaVuSansCondensed-Oblique.ttf', uni=True)
106
 
107
  def header(self):
108
+ self.set_font('DejaVu', 'B', 12)
109
  self.cell(0, 10, 'Paper Analysis Report', 0, 1, 'C')
110
 
111
  def footer(self):
112
  self.set_y(-15)
113
+ self.set_font('DejaVu', 'I', 8)
114
  self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
115
 
116
  def create_pdf_report(title, author_info, score, reasoning_text, output_path):
117
  pdf = PDF()
118
  pdf.add_page()
119
+ # Set the font to DejaVu for Unicode support
120
+ pdf.set_font("DejaVu", size=12)
121
  pdf.cell(0, 10, f"Title: {title}", 0, 1)
122
  pdf.cell(0, 10, f"Author Information: {author_info}", 0, 1)
123
  pdf.cell(0, 10, f"Score: {score}", 0, 1)