Skip to content

Drawing ascii 0xA #6568

Answered by nulano
ZX-80 asked this question in Q&A
Discussion options

You must be logged in to vote

There is currently no way to do this with ImageDraw, and I'm not sure how much interest there would be in adding support for it.

I'd suggest you just copy the relevant code from ImageDraw.text:

        def text_force_singleline(draw, xy, text, font, fill, **kwargs):
            class FakeBitmap:
                def load():
                    pass
            bitmap = FakeBitmap()
            mask, offset = font.getmask2(text, "L", **kwargs)
            bitmap.im = mask
            coord = xy[0] + offset[0], xy[1] + offset[1]
            draw.bitmap(coord, bitmap, fill)

(Note that your use of font.getbbox does not actually give you the size, but that is probably fine with your font. For y…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ZX-80
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants