Scroll Phat HD - how to scroll the buffer exactly one time


#1

[original question] I would like to scroll a message exactly once, so that it scrolls off the left of the screen and does not reappear. With graphics, this is relatively easy because I know how many pixels wide the thing is that I drew. But with text, no such luck. How can I determine the number of pixels to scroll a given message in a given font? (Or any alternative method to scroll the buffer exactly once).

[edit] I figured it out — scrollphathd.write_string returns the width of the string in pixels.


#2

I was about to give the answer you’d figured out before I finished reading!

Indeed write_string returns the width of the string.

Also if you’ve just printed one string (since the last time you called clear) then the buffer will generally be the same width so get_buffer_shape might work for you- granted this is probably only useful if you’ve also drawn some pixel-based stuff at the end of your string.