-
Notifications
You must be signed in to change notification settings - Fork 223
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
Enabled ClipPaths option to filter letters. #681
base: master
Are you sure you want to change the base?
Conversation
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.
Is it possible to add unit tests too? If you cannot, just let me know I'll have a look
{ | ||
var currentClipping = GetCurrentState().CurrentClippingPath; | ||
|
||
if (!currentClipping?.Contains(transformedGlyphBounds) ?? true) |
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.
No need to call currentState GetCurrentState()
again here, you can reuse the currentState
variable from line 246
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 think for the corner case where the clipping path would be null, we need to render the text (i.e. we don't skip). You can achieve that using something like
currentState.CurrentClippingPath?.Contains(transformedGlyphBounds) == false
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.
Hi,
Sorry for delay. I was out of office. I've just added a unit test. I couldn't find a more proper name :) You may change it if you need.
I'm not sure we should use .Contains
because of semi-clipped letters. Should we use .Intersect
? What do you think ?
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.
@savasozer no worries at all! I agree with you, using Intersect()
makes more sense
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 couldn't find a PdfPath PdfRectangle Intersection testing method. So I made it myself using your Contains method :)
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.
@savasozer thanks a lot for that, that's very helpful.
Maybe 1 remark on your function (I'm away so I could not actually test it):
- There is a (very rare) edge case I think where the clipping path is completely inside the letter's rectangle, leading your function to return false instead of true. Same if the clipping path is smaller than the letter and partially inside and outside of the letter. In both cases all letters point would be outside but actually overlap. There might be other edge cases but I could only think about this one.
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.
Maybe this link would be useful https://stackoverflow.com/questions/38382777/how-do-i-determine-if-two-polygons-intersect-using-clipper#38382810
Anything I can help with to rework or tie this up? The change works for my case. Does it just need more comprehensive tests or you want coverage of more cases? I'm not sure all cases will be covered first round. Could add a |
I hope I've implemented correctly.