peterhinch / micropython-font-to-py

A Python 3 utility to convert fonts to Python source capable of being frozen as bytecode
MIT License
368 stars 67 forks source link

Freely write at different coordinate #58

Closed hunter40415 closed 5 months ago

hunter40415 commented 5 months ago

I suggest add this line into the code to avoid having to call out a coordinate every time which make the code look messy image which turn the code from this image to this image

peterhinch commented 5 months ago

The reason set_textpos is a separate method is that, having set the text position, the application might perform many printstring calls with the text being added each time at the current cursor point. In other words, printstring should not be constrained to an absolute location.

hunter40415 commented 5 months ago

thanks for your explanation. I still a amateur at coding so I haven't thought about that. Anyway thanks to your work I have done many cool thing on my pico pi. (Mind my bad English vocabulary).

On Tue, Jan 9, 2024, 01:44 Peter Hinch @.***> wrote:

Closed #58 https://github.com/peterhinch/micropython-font-to-py/issues/58 as completed.

— Reply to this email directly, view it on GitHub https://github.com/peterhinch/micropython-font-to-py/issues/58#event-11421266993, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCPSMINGJB73VT6NLI3IHX3YNQ47XAVCNFSM6AAAAABBQM7OX2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGQZDCMRWGY4TSMY . You are receiving this because you authored the thread.Message ID: @.*** .com>

peterhinch commented 5 months ago

You can always write your own function:

def print_at(wri, text, row, col):
    Writer.set_textpos(display, row, col)
    wri.printstring(text)

then you can write

wri = Writer(display, roman20)
print_at(wri, "Hello world", 0, 5)

I notice you use x and y. Graphics systems usually use row, col. The mathematical x coordinate is col, y is row. Just to confuse us :)