Projects STRLCPY dummy Commits 5df433c7
🤬
  • ■ ■ ■ ■ ■
    dummy/cli.py
    skipped 4 lines
    5 5  import binascii
    6 6  import colorama
    7 7  import io
     8 +import platform
    8 9   
    9 10  from colorama import Fore
    10 11  from PIL import Image, ImageDraw, ImageFont
    11 12  from reportlab.pdfgen import canvas
    12 13  from reportlab.lib.pagesizes import B5
    13 14   
     15 +system = platform.system()
    14 16   
    15 17  def make_jpeg(file_path, text):
    16 18   image = Image.new('RGB', (729, 516), (255, 255, 255)) # B5, White
    17 19   draw = ImageDraw.Draw(image)
    18 20   # Pillow's builtin font has a static size, so I used Arial
    19 21   # https://github.com/python-pillow/Pillow/issues/2695
    20  - arial = ImageFont.truetype('Arial.ttf', 30)
     22 + 
     23 + if system == 'Windows':
     24 + font_path = 'C:\\Windows\\Fonts\\arial.ttf'
     25 + else:
     26 + font_path = 'Aria.ttf'
     27 + arial = ImageFont.truetype(font_path, 30)
    21 28   draw.text((10, 10), text, fill=(0, 0, 0), font=arial) # Black
    22 29   image.save(file_path, format='jpeg')
    23 30   return True
    skipped 3 lines
    27 34   draw = ImageDraw.Draw(image)
    28 35   # Pillow's builtin font has a static size, so I used Arial
    29 36   # https://github.com/python-pillow/Pillow/issues/2695
    30  - arial = ImageFont.truetype('Arial.ttf', 30)
     37 + 
     38 + system = platform.system()
     39 + if system == 'Windows':
     40 + font_path = 'C:\\Windows\\Fonts\\arial.ttf'
     41 + else:
     42 + font_path = 'Aria.ttf'
     43 + arial = ImageFont.truetype(font_path, 30)
    31 44   draw.text((10, 10), text, fill=(0, 0, 0), font=arial) # Black
    32 45   output = io.BytesIO()
    33 46   image.save(output, format='png')
    skipped 88 lines
Please wait...
Page is in error, reload to recover