Monkey patch in draw_text to save us some trouble (and avoid loading imagemagick stuff unless we really need it).

This commit is contained in:
yrriban 2025-07-04 12:08:25 -04:00
parent 1ac3851065
commit 105be2c5fd
2 changed files with 8 additions and 12 deletions

View file

@ -1,15 +1,16 @@
import dcc.config
import dcc.doom_base
import sys
import wand.drawing
import wand.image
def draw_text(img, text, font, text_fill, text_stroke, font_size=64):
def draw_text(self, img, text, font_size=64):
with wand.drawing.Drawing() as draw:
draw.font = font
draw.font = self.thumbnail_font
draw.font_size = font_size
draw.fill_color = wand.color.Color(text_fill)
draw.stroke_color = wand.color.Color(text_stroke)
draw.fill_color = wand.color.Color(self.thumbnail_text_fill)
draw.stroke_color = wand.color.Color(self.thumbnail_text_stroke)
draw.stroke_width = font_size * 5 / 32
draw.text_interline_spacing = -font_size / 4
draw.text(5, int(draw.font_size) + 5, text)
@ -19,6 +20,7 @@ def draw_text(img, text, font, text_fill, text_stroke, font_size=64):
draw.text(5, int(draw.font_size)+5, text)
draw(img)
dcc.config.Base.draw_text = draw_text
class Text(dcc.doom_base.WadMap):
def get_parser(self, prog_name):
@ -36,11 +38,8 @@ class Text(dcc.doom_base.WadMap):
height=self.thumbnail_height,
width=self.thumbnail_width
) as img:
draw_text(
self.draw_text(
img, text,
self.thumbnail_font,
self.thumbnail_text_fill,
self.thumbnail_text_stroke
)
img.trim()
img.reset_coords()