New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for ofBitmapFont getBoundingBox(); #5611
Fixes for ofBitmapFont getBoundingBox(); #5611
Conversation
roymacdonald
commented
May 18, 2017
- incorrect use of numeric_limits::min() caused wrong results. Replaced for numeric_limits::lowest()
- Added ofDrawBitmapMode mode = ofGetStyle().drawBitmapMode, bool vFlipped = ofIsVFlipped() arguments to getBoundingBox. This allows to get the correct mesh and doesn't break previous way of use of this function.
- incorrect use of numeric_limits<float>::min() caused wrong results. Replaced for numeric_limits<float>::lowest() - Added ofDrawBitmapMode mode, bool vFlipped arguments to getBounding.
@@ -418,11 +418,11 @@ ofMesh ofBitmapFont::getMesh(const string & text, int x, int y, ofDrawBitmapMode | |||
if(text[c] == '\n'){ | |||
|
|||
sy += lineHeight*newLineDirection; | |||
if(mode == OF_BITMAPMODE_SIMPLE) { | |||
// if(mode == OF_BITMAPMODE_SIMPLE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove of the commented parts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't remove this because I really don't understand why it it is there in first place although the most logical thing is that it shouldn't be there. If there's no problem removing it I will.
const ofMesh & mesh = getMesh(text,x,y); | ||
glm::vec2 max(numeric_limits<float>::min(),numeric_limits<float>::min()); | ||
const ofMesh & mesh = getMesh(text,x,y, mode, vFlipped); | ||
glm::vec2 max(numeric_limits<float>::lowest(),numeric_limits<float>::lowest()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
@@ -22,7 +23,7 @@ class ofBitmapFont{ | |||
~ofBitmapFont(); | |||
ofMesh getMesh(const string & text, int x, int y, ofDrawBitmapMode mode=OF_BITMAPMODE_MODEL_BILLBOARD, bool vFlipped=true) const; | |||
const ofTexture & getTexture() const; | |||
ofRectangle getBoundingBox(const string & text, int x, int y) const; | |||
ofRectangle getBoundingBox(const string & text, int x, int y, ofDrawBitmapMode mode = ofGetStyle().drawBitmapMode, bool vFlipped = ofIsVFlipped()) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ofGetStyle().drawBitmapMode
looks funny, but I'm assuming it's the only way to do this to preserve backward compatibility right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... to clarify "looks funny" .. to call a member variable of a global instance as a default parameter in a function. Typically I avoid non-constant default parameters because they are ... not constant :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and therefore the idea of a "default" gets murky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, right. There seems to be no other way to get the current bitmap mode. And right, it also looked funny to me, but it is there to keep backwards compatibility.