-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
freetype: fix for huge CtoL param. #3585
base: 4.x
Are you sure you want to change the base?
Conversation
modules/freetype/src/freetype.cpp
Outdated
std::pow( dx1 * dx1 + dy1 * dy1, 0.5 ) + | ||
std::pow( dx2 * dx2 + dy2 * dy2, 0.5 ) |
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.
pow 0.5 is sqrt. I propose to use sqrt as it's faster and more obvious.
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.
Thank you for your review! Yes, it is better, I fixed it.
modules/freetype/src/freetype.cpp
Outdated
// Split Bezier to lines ( in FreeType coordinates ). | ||
double u = (double)i * 1.0 / (p->mCtoL) ; | ||
double u = (double)i * 1.0 / (iCtoL) ; |
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.
*1.0 is redundant.
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.
Yes, I fixed it. And I replaced from (double)i
that is C-style-cast, to static_cast<double>(i)
.
modules/freetype/src/freetype.cpp
Outdated
std::pow( dx1 * dx1 + dy1 * dy1, 0.5 ) + | ||
std::pow( dx2 * dx2 + dy2 * dy2, 0.5 ) + | ||
std::pow( dx3 * dx3 + dy3 * dy3, 0.5 ) |
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.
the same for pow.
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 fixed it, thank you!
modules/freetype/src/freetype.cpp
Outdated
// Split Bezier to lines ( in FreeType coordinates ). | ||
double u = (double)i * 1.0 / (p->mCtoL) ; | ||
double u = (double)i * 1.0 / (iCtoL) ; |
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.
*1.0 is redundant.
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 fixed it, thank you!
I believe that iCtoL is determined with font glyph path data, so it should be care about the range of it more than before.
I think that such a case is basically impossible. However, it's not absolute, so I'd like to put in some protection just in case. |
Test is failed, but it is about unexpected module/function. Maybe it is missjudgement. I believe this file doesn't reference to freetype module. Test result is here.
|
The freetype module uses CtoL param to split bezier curve segment to polylines.
This patch makes local upper limitation for each segments. It is determined with total length of polylines at anchors.
And skip to push_back() same points, likes imgproc::ellipse2Poly().
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.