Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

savasozer
Copy link

I hope I've implemented correctly.

@BobLd BobLd self-requested a review August 11, 2023 17:09
Copy link
Collaborator

@BobLd BobLd left a 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)
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Author

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 ?

Copy link
Collaborator

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

Copy link
Author

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 :)

Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jerrosenberg
Copy link

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 ClipText option so that this functionality is opt in for now, and people can open new issues for additional cases that don't seem to be covered. Thoughts? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants