diff --git a/stockTicker.py b/stockTicker.py index c685a74..f496bc2 100755 --- a/stockTicker.py +++ b/stockTicker.py @@ -7734,12 +7734,38 @@ class StockTicker(): f = open('csv/quotes_settings.json', 'r') quotes_settings = json.load(f) f.close() - + if quotes_settings['title']: title_img = self.openImage('feature_titles/quotes.png') image_list = [title_img] else: image_list = [] + font = ImageFont.load("./fonts/8x13B.pil") + font2 = ImageFont.load("./fonts/6x10.pil") + sun_img = self.openImage('logos/sun_quote.png') + try: + for index, each in enumerate(quotes_settings['quotes']): + if index == 0: + quote_img = self.textImage(each['quote'], font, 248, 152, 128) + author_img = self.textImage(each['author'], font2, 64, 181, 173) + img = Image.new('RGB', (max(quote_img.size[0], author_img.size[0]) + 20,32)) + img.paste(quote_img, (0,7)) + img.paste(author_img, ((quote_img.size[0] - author_img.size[0] - 5), 21)) + image_list.append(img) + else: + quote_img = self.textImage(each['quote'], font, 248, 152, 128) + author_img = self.textImage(each['author'], font2, 64, 181, 173) + img = Image.new('RGB', (sun_img.size[0] + 5+ max(quote_img.size[0], author_img.size[0]) + 20,32)) + img.paste(sun_img, (0, 0)) + img.paste(quote_img, (sun_img.size[0] + 5,7)) + img.paste(author_img, (sun_img.size[0] + 5+(quote_img.size[0] - author_img.size[0] - 5), 21)) + image_list.append(img) + except: + img = Image.new('RGB',(180,32)) + no_quotes = self.textImage('No quotes available.', font, 255, 255, 255) + img.paste(no_quotes,(0,7)) + image_list.append(img) + pass return self.stitchImage(image_list) @@ -7749,12 +7775,39 @@ class StockTicker(): f = open('csv/quotes_settings.json', 'r') quotes_settings = json.load(f) f.close() - + if quotes_settings['title']: title_img = self.openImage('feature_titles/small_feature_titles/quotes.png') image_list = [title_img] else: image_list = [] + font = ImageFont.load("./fonts/5x8.pil") + font2 = ImageFont.load("./fonts/4x6.pil") + sun_img = self.openImage('logos/sun_quote_small.png') + + try: + for index, each in enumerate(quotes_settings['quotes']): + if index == 0: + quote_img = self.textImage(each['quote'], font, 248, 152, 128) + author_img = self.textImage(each['author'], font2, 64, 181, 173) + img = Image.new('RGB', (max(quote_img.size[0], author_img.size[0]) + 15,16)) + img.paste(quote_img, (0,0)) + img.paste(author_img, ((quote_img.size[0] - author_img.size[0] - 5), 10)) + image_list.append(img) + else: + quote_img = self.textImage(each['quote'], font, 248, 152, 128) + author_img = self.textImage(each['author'], font2, 64, 181, 173) + img = Image.new('RGB', (sun_img.size[0] + 5+ max(quote_img.size[0], author_img.size[0]) + 15,16)) + img.paste(sun_img, (0, 0)) + img.paste(quote_img, (sun_img.size[0] + 5,0)) + img.paste(author_img, (sun_img.size[0] + 5+(quote_img.size[0] - author_img.size[0] - 5), 10)) + image_list.append(img) + except: + img = Image.new('RGB',(180,16)) + no_quotes = self.textImage('No quotes available.', font, 255, 255, 255) + img.paste(no_quotes,(0,0)) + image_list.append(img) + pass return self.stitchImage(image_list)