mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-05-03 08:51:16 -05:00
png: change font settings
This commit is contained in:
parent
706aa78ba2
commit
cb5a09b6de
@ -365,7 +365,7 @@ class ASCII(callbacks.Plugin):
|
|||||||
text = text.replace('\t', ' ')
|
text = text.replace('\t', ' ')
|
||||||
self.strip_colors_regex = re.compile('(\x03([0-9]{1,2})(,[0-9]{1,2})?)|[\x0f\x02\x1f\x03\x16]').sub
|
self.strip_colors_regex = re.compile('(\x03([0-9]{1,2})(,[0-9]{1,2})?)|[\x0f\x02\x1f\x03\x16]').sub
|
||||||
path = os.path.dirname(os.path.abspath(__file__))
|
path = os.path.dirname(os.path.abspath(__file__))
|
||||||
defaultFont = "{0}/hack.ttf".format(path)
|
defaultFont = "{0}/DejaVu.ttf".format(path)
|
||||||
def strip_colors(string):
|
def strip_colors(string):
|
||||||
return self.strip_colors_regex('', string)
|
return self.strip_colors_regex('', string)
|
||||||
_colorRegex = re.compile('(([0-9]{1,2})(,([0-9]{1,2}))?)')
|
_colorRegex = re.compile('(([0-9]{1,2})(,([0-9]{1,2}))?)')
|
||||||
@ -373,9 +373,8 @@ class ASCII(callbacks.Plugin):
|
|||||||
lineLens = [len(line) for line in strip_colors(text).splitlines()]
|
lineLens = [len(line) for line in strip_colors(text).splitlines()]
|
||||||
maxWidth, height = max(lineLens), len(lineLens)
|
maxWidth, height = max(lineLens), len(lineLens)
|
||||||
font = ImageFont.truetype(defaultFont, size)
|
font = ImageFont.truetype(defaultFont, size)
|
||||||
fontX, fontY = font.getsize('█')
|
fontX = 10
|
||||||
fontX -= 1
|
fontY = 20
|
||||||
fontY -= 1
|
|
||||||
imageX, imageY = maxWidth * fontX, height * fontY
|
imageX, imageY = maxWidth * fontX, height * fontY
|
||||||
image = Image.new('RGB', (imageX, imageY), self.rgbColors[defaultBg])
|
image = Image.new('RGB', (imageX, imageY), self.rgbColors[defaultBg])
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user