Add rotate option to blf module #21867

Closed
opened 2010-04-01 09:04:39 +02:00 by Dan Eicher · 7 comments
Member

%%%Added an optional angle argument to the blf.draw function to allow the text to be rotated.

I tried to wrap the BLF_default_rotation directly but it sets the global text rotation angle and if you don't reset it then... well, not really intended behavior results.

So this patch sets the angle, calls the draw function and then resets the rotation angle back to 0 which is a lot safer than the alternative.%%%

%%%Added an optional angle argument to the blf.draw function to allow the text to be rotated. I tried to wrap the BLF_default_rotation directly but it sets the global text rotation angle and if you don't reset it then... well, not really intended behavior results. So this patch sets the angle, calls the draw function and then resets the rotation angle back to 0 which is a lot safer than the alternative.%%%
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

%%%Version #2 with wrappers for rotate, shadow and clipping along with the helper functions to get them to work.

No idea what BLF_KERNING_DEFAULT does but threw that in as well for completeness.%%%

%%%Version #2 with wrappers for rotate, shadow and clipping along with the helper functions to get them to work. No idea what BLF_KERNING_DEFAULT does but threw that in as well for completeness.%%%

%%%Could you please make these 2 changes.

  • invalid blur level raise an error.
  • move constants into their own module eg: blf.modes.ROTATION

%%%

%%%Could you please make these 2 changes. - invalid blur level raise an error. - move constants into their own module eg: blf.modes.ROTATION %%%
Author
Member

%%%Ok, did #1, if blur != 0, 3 or 5 it throws an error.

On change #2, this would break consistency with the bgl module where all the constants are in the same flat namespace as the functions.

And, as we all know, Consistency is King...

Based on my own usage of this module the chances are good that the user will also be using the bgl module as well and will expect them to behave similarly when it comes to constants since they both fulfill a nearly identical roll.

Having different methods for the same thing like bgl.glEnable(bgl.GL_BLEND) and blf.enable(blf.modes.ROTATION) will just lead to confusion IMHO.

I did however remove the BLF_ prefix as per your request since blf.ROTATION is pretty nearly the same thing.%%%

%%%Ok, did #1, if blur != 0, 3 or 5 it throws an error. On change #2, this would break consistency with the bgl module where all the constants are in the same flat namespace as the functions. And, as we all know, Consistency is King... Based on my own usage of this module the chances are good that the user will also be using the bgl module as well and will expect them to behave similarly when it comes to constants since they both fulfill a nearly identical roll. Having different methods for the same thing like bgl.glEnable(bgl.GL_BLEND) and blf.enable(blf.modes.ROTATION) will just lead to confusion IMHO. I did however remove the BLF_ prefix as per your request since blf.ROTATION is pretty nearly the same thing.%%%

%%%applied patch to trunk, /w small fix, exception needed to return NULL, not -1.

re: opengl consistency, we have a number of python api's so its a choice to which once you want to match, but since this is probably used with OpenGL I can see the rationale. %%%

%%%applied patch to trunk, /w small fix, exception needed to return NULL, not -1. re: opengl consistency, we have a number of python api's so its a choice to which once you want to match, but since this is probably used with OpenGL I can see the rationale. %%%
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

%%%This might come a liitle late, but I just noticed, that the "invalid blur level" error doesn't show up when using blf.blur() inside the Game Engine.%%%

%%%This might come a liitle late, but I just noticed, that the "invalid blur level" error doesn't show up when using blf.blur() inside the Game Engine.%%%
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#21867
No description provided.