1
$\begingroup$

I'm using blf in a modal operator to draw help text on the 3D viewport. Here's a snippet:

FONT_ID = 0
bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
try:
    blf.position(FONT_ID, x, y, 0)
    blf.draw(FONT_ID, line)
finally:
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)

This works well, but when the user moves the mouse, the text flickers: when the mouse is moving it's a bit bigger, and when it stops it goes smaller. When it's bigger it also appears a little blurry. I think the texture that the text is being painted onto is being scaled incorrectly when the mouse moves. I've checked the parameters that I'm passing to blf.draw and blf.position, and they're not changing.

Is there any way I can stop this from happening?

$\endgroup$
1
$\begingroup$

Oops, I should have been setting the font size.

blf.size(FONT_ID, 14, 72)

My guess is that some other text code is not resetting the font size properly. Similarly, when using text shadow, you have to set the blf.shadow_offset (even if you want to leave it at 0, 0) to avoid the shadow flickering.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.