yinuozhang commited on
Commit
4f0aaef
1 Parent(s): a0cad87

add more functions

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -260,8 +260,20 @@ def annotate_cyclic_structure(mol, sequence):
260
  # Convert to PIL Image
261
  img = Image.open(BytesIO(drawer.GetDrawingText()))
262
  draw = ImageDraw.Draw(img)
263
- font = ImageFont.load_default(60)
264
- small_font = ImageFont.load_default(60)
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
  # Get molecule bounds
267
  conf = mol.GetConformer()
 
260
  # Convert to PIL Image
261
  img = Image.open(BytesIO(drawer.GetDrawingText()))
262
  draw = ImageDraw.Draw(img)
263
+ try:
264
+ # Try to use DejaVuSans as it's commonly available on Linux systems
265
+ font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 60)
266
+ small_font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 60)
267
+ except OSError:
268
+ try:
269
+ # Fallback to Arial if available (common on Windows)
270
+ font = ImageFont.truetype("arial.ttf", 60)
271
+ small_font = ImageFont.truetype("arial.ttf", 60)
272
+ except OSError:
273
+ # If no TrueType fonts are available, fall back to default
274
+ print("Warning: TrueType fonts not available, using default font")
275
+ font = ImageFont.load_default()
276
+ small_font = ImageFont.load_default()
277
 
278
  # Get molecule bounds
279
  conf = mol.GetConformer()