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

@ -85,12 +85,9 @@ class Concat(dcc.doom_base.Wad):
) )
mapstring = v.name[-6:-4] mapstring = v.name[-6:-4]
text = self._config["map_names"][f"map{mapstring}"] text = self._config["map_names"][f"map{mapstring}"]
dcc.text.draw_text( self.draw_text(
img, img,
f"MAP{mapstring}: {text}", f"MAP{mapstring}: {text}",
self.thumbnail_font,
self.thumbnail_text_fill,
self.thumbnail_text_stroke,
font_size=120 font_size=120
) )
img.trim(reset_coords=True) img.trim(reset_coords=True)

View file

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