Font strangeness

VEXcode V5 Blocks 1.0.0-2460

“set font” is not respected when responding to a message.

If you set font to large and print something on the screen, then broadcast a message in that context print something the size is back to default.

event handlers run in their own threads. Every thread has a graphics context that keeps some of the basic parameters (font, color etc.) separate. The event handler needs to set font size explicitly if you want to print large text in it. some properties of the brain class are not thread safe, specifically cursor position and origin.

edit: and I now see you are using blocks. What that means is that you need to set font size after the When(message) block.

1 Like

Thanks for the background information, that all makes sense.

“Thread safe” isn’t exactly something most block coders will understand, so having some text attributes maintained (cursor position) while others are not (size, etc) is going to seem buggy.

yea, I realize it’s not ideal. vexos stores all the things like font size for every thread, it had no knowledge about things like cursor position as everything inside vexos is pixel based. Cursor row and column were added as part of the brain class for VCS (I’m talking about programming in text again) and it was requested to have row and column as properties, cursor position is actually a difficult thing to deal with when there is a choice of fonts, some of which are proportional, so it ended up being part of that class. The same with the concept of origin (not available in blocks, but the 0,0 pixel position can be moved to an arbitrary point). As blocks is based on the same SDK and running on the same vexos in the V5 brain, it has inherited some of this inconsistent behavior.

we could go back and make cursor and origin part of vexos, but that would change significantly how code that was developed over the last year behaves, so it’s sort of a no win situation it terms of deciding how to deal with this but I will give it some more thought.

VCS blocks did not have these issues because it was running as a single thread on the brain, “when” blocks were handled very differently using other techniques created by its developer.

2 Likes